fixing form error message issue (#2047)
This commit is contained in:
parent
7ba10c1b7a
commit
2a51f0ee14
3 changed files with 4 additions and 4 deletions
|
@ -24,7 +24,7 @@ enum Filters {
|
|||
|
||||
const New: React.FC = () => {
|
||||
const methods = useForm<TopicFormData>({
|
||||
mode: 'all',
|
||||
mode: 'onChange',
|
||||
resolver: yupResolver(topicFormValidationSchema),
|
||||
});
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ const CustomParamField: React.FC<Props> = ({
|
|||
newExistingFields.push(nameValue);
|
||||
setExistingFields(newExistingFields);
|
||||
setValue(`customParams.${index}.value`, TOPIC_CUSTOM_PARAMS[nameValue], {
|
||||
shouldValidate: true,
|
||||
shouldValidate: !!TOPIC_CUSTOM_PARAMS[nameValue],
|
||||
});
|
||||
}
|
||||
}, [existingFields, index, nameValue, setExistingFields, setValue]);
|
||||
|
@ -92,7 +92,7 @@ const CustomParamField: React.FC<Props> = ({
|
|||
</FormError>
|
||||
</div>
|
||||
<div>
|
||||
<InputLabel>Value</InputLabel>
|
||||
<InputLabel>Value *</InputLabel>
|
||||
<Input
|
||||
name={`customParams.${index}.value` as const}
|
||||
hookFormOptions={{
|
||||
|
|
|
@ -61,7 +61,7 @@ export const topicFormValidationSchema = yup.object().shape({
|
|||
maxMessageBytes: yup.number().min(1).required(),
|
||||
customParams: yup.array().of(
|
||||
yup.object().shape({
|
||||
name: yup.string().required(),
|
||||
name: yup.string().required('Custom parameter is required'),
|
||||
value: yup.string().required('Value is required'),
|
||||
})
|
||||
),
|
||||
|
|
Loading…
Add table
Reference in a new issue