Description
Bug, Feature, or Question?
Feature/Question
Current Behavior
Currently, validation is running asynchronously on the whole schema (assuming you use ValidationSchema of yup). It is reasonable to run the validation on submit, however, It is extremely cumbersome to run it on every field change/blur.
Especially if you have some backend validation (using yup.test). Assuming you have a couple of fields, field A, and field B - the later must go through backend validation. Every time you change field A, the validation runs both on A and B which will cause unnecessary backend calls.
I also tried using the new alpha version's handleChange('fieldName') but I still experience the same behavior.
Suggested Solutions
-
Using yup schema, using yup.reach seems reasonable, even though I'm not sure how is its performance (https://github.com/jaredpalmer/formik/issues/35)
-
Formik validate function - pass the event's field name. It will allow the developer to validate only one field at a time.
Environment
- Formik Version: 0.11.11 /1.0.0-alpha.2
- React Version: 16.2
- TypeScript Version: 2.7.2
- CodeSandbox Link:
- OS: macOS High Sierra
- Node Version: 8.9.4
- Package Manager and Version: