Initial validation or initialErrors prop
See original GitHub issueWhat if the user has set some field values, and we do store them somewhere, and when the user returns to the app those values are invalid. Is there no way to run validate
on initialization?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:22
- Comments:50 (13 by maintainers)
Top Results From Across the Web
Initial validation or initialErrors prop · Issue #154 · final-form ...
Displaying validation errors & disable form submission for a record that is already persisted, and will now be newly invalid based on some ......
Read more >Formik validate initial values on page load - Stack Overflow
This worked for me to show validation error on form load. useEffect(() => { if (formRef.current) { formRef.current.validateForm() } }, []).
Read more >Validation of Initial Arrival in J-1 Status - ECFMG
The initial arrival of each EV physician to the United States must be immediately validated by ECFMG in the Student and Exchange Visitor....
Read more >Validating Initial Values - VeeValidate
Input validation for Vue.js. ... Validating Initial Values ... Show case of all vee-validate official examples. logaretm.
Read more >Validation - Formik
<Formik> and withFormik() take a prop/option called validate that accepts either ... 23 errors.username = 'Nice try'; ... 28 // same shape as...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
+1 for this use case.
I would like to display validation errors & disable form submission for a record that is already persisted, and will now be newly invalid based on some recent changes in the underlying business logic.
So I would like the initial form load to reflect this, but ran into the same issue where the validator function is not run until some field is touched. This has the effect of leaving the form’s submit button initially enabled for what we consider to be an invalid record.
For now I am working around this by moving logic out of the validator function and into various form components, which seems a shame given all the wins we’ve enjoyed by relying on Formik’s awesome default behavior so far.
I think
initialErrors
makes a lot of sense. Feel free to submit a PR. It should be almost identical toinitialValues
.