Open ziriax opened 3 years ago
I think I might need this behavior for my application as well. I'm building a form which constructs validation rules from a DB call to a table representing Yup validation rules. My easiest, ideal, and most performant option would be to provide my formik context with the validation schema after the formik context has been constructed, but it would appear that my only option is to construct the formik context after waiting for my validation schema to be ready
One other alternative to solving this problem that might be worth considering is to add a method useFormik().setValidationSchema(schema) which can trigger an effect to revalidate the formik context
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 60 days
Feature request
Current Behavior
Currently
validateYupSchema
calls Yup'sschema.validate
method:However, it is impossible in the current Formik implementation to pass the
maybeCb
callback.This callback is needed to customize the behavior of async validation.
Desired Behavior
It should be possible to configure the Yup async validation callback.
Suggested Solution
Add an optional
validationSchemaCallback
property to theFormikConfig
to customize this behavior.Who does this impact? Who is this for?
This should be fully backwards compatible.
In our project we need this behavior to ignore aborted promises, or any other custom behavior where an async validation should be completely ignored.
Describe alternatives you've considered
We can return a promise that never resolves, but that can result in memory leaks.
Additional context
I can provide a PR if that helps.