-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run low-pri validation at a given field / path in schema #1578
Conversation
@jquense does validate at properly degrade with .when? |
If you are using The only edge case is when field a change to field |
@jquense my solution to that is to use the function form of validationSchema anyways. |
nice yeah, I'd say that covers workarounds then? It's not a super common thing to deal with anyway, idk that there is a lot of value in yup trying to be smarter to handle it? |
Probably not. We should document this situation and make an example of the solution. |
i would love to have some examples for this. |
…)" This reverts commit 7ba657c.
Can we have some example of it ? |
@jaredpalmer Could you share an example of how to use it? For me it seems both input and form level validations are executed together. |
For anyone coming in from Google, it appears that this PR was reverted by 377c36e. @jaredpalmer, what was the reason for the revert? |
@jaredpalmer Any info on this? |
@earksiinni looks like the related MR references #1654 as the reason it was reverted |
This PR tweaks validation so that Formik runs low-priority validation at the field level. That means that only the slice of the Yup schema and/or a single
<Field validate>
will be executed for a given change/blur. During pre-submit (i.e. high-priority validation), the entire schema is validated against values and all field-level validate fns are run (this is the current behavior). (I think) Yup is smart enough now that to deal with dependent schema paths (when
andrefs
) so this should be non-breaking.Continues v1 work by @jquense in #780
Details
validateAt
to validate the schema at a given path (instead of the entire schema) during run low-priority validation.<Field validate>
fn during low-priority validation (instead of running all registered field-level validation fns)Next Steps
I rushed through this initially to get an MVP going. We may want to refactor some stuff to make things easier.