-
-
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
add onValidationFail in <Formik/> #1670
Comments
@xurei How did you get this to only fire on the form submit? Using your code it's displaying alerts after |
@kieranmaine Does it matter with the subject ? I mean it could be useful for |
@xurei @kieranmaine I think both of these scenarios are perfect candidates for using a Formik Effect, basically creating your own component which listens to formik props and triggers a callback when certain conditions are met. I made an example here: https://codesandbox.io/s/formik-v2-onvalidationfail-s7zy1 Unfortunately, Formik doesn't always trigger |
Any update on this? Id like to run a function whenever the form validation fails when I press the submit button, and let it be handled by Formik. |
🚀 Feature request
Context
I'm using Formik with yup for validation. I would like to show an alert when validation fails, but only on submit. I didn't find any easy way to do that.
Current Behavior
Right now the best way I found is to write a custom validate() fucntion that basically reproduce the code in Formik and call a function if an error is found.
Desired Behavior
Formik could send an event in case of a validation fail. The context of the validation (submitting or not) should be useful as well.
Suggested Solution
Who does this impact? Who is this for?
This is mostly useful in conjunction with Yup. A custom validation function can already deal with these cases.
The text was updated successfully, but these errors were encountered: