Use RHF validation mode onTouched
instead of all
#1770
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #1761
Does not do #1289 because it still validates on that first blur even if you didn't type anything.
onTouched
validates first on blur, and after that on change. I think I like that, but I'm flexible.onBlur
is almost the same except it always validates on blur instead of change. The annoying thing to me about blur only is that if you go into a field with a validation error and correct it, the error won't go away until you blur. I find that a little surprising.On the implementation side I considered just replacing
mode: 'all'
withmode: 'onTouched'
in all the call sites, and could definitely change it to that, but it feels slightly less error-prone to me to use the shared wrapper, and then you don't have the noise of themode
at every call site.Full table of
mode
options from the RFD docs2023-10-04-rhf-onTouched.mp4