Open alextrastero opened 4 years ago
Thanks for the great library btw
The second param to the .test()
method is the error message. This param must be a non-falsy value (ex: ""
, 0
, false
)
You can fix this issue by passing in a string as the second param
const schema = object({
iban: string().test('name', 'something is wrong with name...', () => false), // no message
})
<Formik validationSchema={schema} ...
📖 Documentation
Sorry if the format is wrong, I just wanted to write my findings regarding the
validationSchema
prop.I have an IBAN form input where I wanted to add a custom validation (aka
test
).In this example the form will submit ignoring the iban test.
I'm not sure this is a bug in yup, as using
schema.isValid
works fine.