You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have verified that I use latest version of all @mantine/* packages
What version of @mantine/* packages do you have in package.json?
7.12.2
What package has an issue?
@mantine/form
What framework do you use?
Next.js
In which browsers you can reproduce the issue?
Chrome
Describe the bug
The validation rules are: "If both fields have text or no field have text everything is ok. Otherwise show the validation message on both fields.". But it does not work.
Typing into the first field shows the validation on the first field but not on the other one and vice versa.
Then typing into the other field should remove the validation on the first field but it doesn't
So it seems that the validation happens only on the field that is currently written to. I also tried to use both field names within the path array in superRefine with no success.
constschema=z.object({descriptionEnglish: z.string().optional(),typeEnglish: z.string().optional(),}).superRefine((data,ctx)=>{const{ descriptionEnglish, typeEnglish }=data;constbothEmpty: boolean=!descriptionEnglish&&!machineTypeEnglish;constbothFilled: boolean=!!descriptionEnglish&&!!machineTypeEnglish;console.log('descriptionEnglish:',descriptionEnglish);console.log('typeEnglish:',typeEnglish);constres: boolean=bothEmpty||bothFilled;console.log('Validation result:',res);if(!res){ctx.addIssue({code: z.ZodIssueCode.custom,message: 'Both description and type must be filled or both must be empty',path: ['typeEnglish'],});ctx.addIssue({code: z.ZodIssueCode.custom,message: 'Both description and type must be filled or both must be empty',path: ['descriptionEnglish'],});}});
@HypeillingerChillinger I believe it's the default behavior to only trigger validation on the field that is being edited. To make sure the error message appears also on the other field, you should call form.validate() in a useEffect.
Dependencies check up
What version of @mantine/* packages do you have in package.json?
7.12.2
What package has an issue?
@mantine/form
What framework do you use?
Next.js
In which browsers you can reproduce the issue?
Chrome
Describe the bug
The validation rules are: "If both fields have text or no field have text everything is ok. Otherwise show the validation message on both fields.". But it does not work.
So it seems that the validation happens only on the field that is currently written to. I also tried to use both field names within the path array in superRefine with no success.
If possible, include a link to a codesandbox with a minimal reproduction
No response
Possible fix
No response
Self-service
The text was updated successfully, but these errors were encountered: