Closed lbk-yuuki-nakamura closed 1 month ago
I can't provide support for formik. If you can reduce the problem to just yup i'm happy to help.
thank you.
I tried to run Yup validation, but it turned out to be an error. We can assume that this is a problem with formik.
const schema = Yup.object({
hoge: Yup.boolean(),
}).test('e-key1', 'error', () => {
return false;
});
schema
.validate({ hoge: true })
.then((value) => {
console.log('Validation succeeded:', value);
})
.catch((err) => {
console.log('Validation failed:', err.errors);
});
This is the formik and yup definition in package.json
As shown below, running a test on a single field usually results in a validation error. Therefore, there is no problem in building the environment.
However, if validation causes an error for object as shown below, it will be ignored and onSubmit will be executed.
The same is true if you do the following
In the sample, validation is checked for one field.
Actually, I would like to refer to several boolean fields and generate an error across fields, such as ``If all boolean fields are false, display an error in all fields.''