Do we need an API to define that the onChange validator is launched also on mount? #1005
Unanswered
Balastrong
asked this question in
Ideas
Replies: 1 comment 1 reply
-
I think so. I'm having to do this right now (little cludgy workaround using radashi's objectify, but obviously another helper could be written): validators={objectify(['onMount', 'onBlur'], identity, () =>
v.pipe(v.number(), v.minValue(1), v.maxValue(999))
)} I don't think it's particularly ideal. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
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 by defining your validating function and passing it to both validators
This will set
canSubmit
to false if there are errors but will not setisTouched
to fields so the user can control if they want to show the error or not.(See Stackblitz with zod)
Is that enough or we need something at Form/Field level to declare that? Suggestions and ideas are welcome!
Beta Was this translation helpful? Give feedback.
All reactions