question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Initial validation or initialErrors prop

See original GitHub issue

What 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:closed
  • Created 6 years ago
  • Reactions:22
  • Comments:50 (13 by maintainers)

github_iconTop GitHub Comments

47reactions
anandaroopcommented, Dec 12, 2017

+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.

10reactions
jaredpalmercommented, Jun 25, 2018

I think initialErrors makes a lot of sense. Feel free to submit a PR. It should be almost identical to initialValues.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found