Current Behavior
Formik validates only during onChange events
Desired Behavior
As a user of the library, I'd like to be able to configure whether validation runs during onChange or onBlur events and their respective imperative functions ( setFieldValue and setFieldTouched).
Ideas:
// Single option
export interface FormikConfig<Props, Values, Payload> {
...
/**
* Tells Formik to validate the form on each input's onChange
* event INSTEAD of the onBlur event
*/
validateOnChange?: boolean;
}
// Two options
export interface FormikConfig<Props, Values, Payload> {
...
/**
* Tells Formik to validate the form on each input's onChange
* event. Default is `false`
*/
validateOnChange?: boolean;
/**
* Tells Formik to validate the form on each input's onBlur
* event. Default is `true`
*/
validateOnBlur?: boolean;
}
I'm a fan of option 2. More flexible, including offering the option to turn off both change and blur validation, which option 1 doesn't support.
Much agreed, Option 2 looks like the better option. I just started using Formik, which I love, but validating only onChange can provide a poor user experience, especially when evaluating required fields.
Most helpful comment
I'm a fan of option 2. More flexible, including offering the option to turn off both change and blur validation, which option 1 doesn't support.