fixing form error message issue (#2047)

This commit is contained in:
Robert Azizbekyan 2022-05-31 13:32:41 +04:00 committed by GitHub
parent 7ba10c1b7a
commit 2a51f0ee14
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 4 deletions

View file

@ -24,7 +24,7 @@ enum Filters {
const New: React.FC = () => { const New: React.FC = () => {
const methods = useForm<TopicFormData>({ const methods = useForm<TopicFormData>({
mode: 'all', mode: 'onChange',
resolver: yupResolver(topicFormValidationSchema), resolver: yupResolver(topicFormValidationSchema),
}); });

View file

@ -59,7 +59,7 @@ const CustomParamField: React.FC<Props> = ({
newExistingFields.push(nameValue); newExistingFields.push(nameValue);
setExistingFields(newExistingFields); setExistingFields(newExistingFields);
setValue(`customParams.${index}.value`, TOPIC_CUSTOM_PARAMS[nameValue], { setValue(`customParams.${index}.value`, TOPIC_CUSTOM_PARAMS[nameValue], {
shouldValidate: true, shouldValidate: !!TOPIC_CUSTOM_PARAMS[nameValue],
}); });
} }
}, [existingFields, index, nameValue, setExistingFields, setValue]); }, [existingFields, index, nameValue, setExistingFields, setValue]);
@ -92,7 +92,7 @@ const CustomParamField: React.FC<Props> = ({
</FormError> </FormError>
</div> </div>
<div> <div>
<InputLabel>Value</InputLabel> <InputLabel>Value *</InputLabel>
<Input <Input
name={`customParams.${index}.value` as const} name={`customParams.${index}.value` as const}
hookFormOptions={{ hookFormOptions={{

View file

@ -61,7 +61,7 @@ export const topicFormValidationSchema = yup.object().shape({
maxMessageBytes: yup.number().min(1).required(), maxMessageBytes: yup.number().min(1).required(),
customParams: yup.array().of( customParams: yup.array().of(
yup.object().shape({ yup.object().shape({
name: yup.string().required(), name: yup.string().required('Custom parameter is required'),
value: yup.string().required('Value is required'), value: yup.string().required('Value is required'),
}) })
), ),