Open harleenarora opened 4 years ago
use
object({}).test()
You can also use when.
For example, add a required validation on foo
if bar
is present :
foo: mixed().when("bar", {
is: value => !!value,
then: mixed().required()
}),
so what i just did
<Formik onSubmit={actualSubmitFunction} . .
<button onClick={vales.valueExists? submitForm(): actualSubmitFunction(values)}>submit </button>
I want to add validation if a particular field exists in the form, otherwise, there should not be any validation or skip validation for that field.
How can I achieve this?