Does onMount not show validation errors?
Hi! I'm working on a form with an onChange validator and our issue is that validation is running only onChange (expectedly) so the user could submit an empty form. I saw the discussion on GH and added the same validator onMount.
I am happy I do not see the validation errors we have defined (eg 'field required') onMount. However, I am not sure if this is expected with 'onMount' validation or I have done something wrong elsewhere?
I couldn't find anything on the docs, so could someone please clarify - do validation errors now show onMount?
Thank you 🙂
1 Reply
round-purpleOP•8mo ago
Ok I understand now and will answer here for posterity. The current behaviour is described here:
By passing your validation function to both onMount and onChange, the validator runs on mount and:
will set canSubmit to false if there are errors but will not set isTouched to fields so the user can control if they want to show the error or no
GitHub
Do we need an API to define that the onChange validator is launched...
In some cases we might want our form to run the onChange validator as soon as the component mounts, do we need a specific API to handle that? After #726 (version 0.34.4) you can easily achieve that...