How to check if field is required using useField? #3667
Unanswered
SimmeNilsson
asked this question in
Q&A
Replies: 1 comment 3 replies
-
I moved this to discussions since it is a question more than an issue. At the moment, vee-validate v4 doesn't have a concept of special rules like |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Is your feature request related to a problem? Please describe.
I have a custom component that is using useField internally.
It renders both label and input element.
I would like to add a * to the label text if the field is required.
Is there some way I can figure out if this field is required (for example if yup.required was used on the field in the schema)?
Describe the solution you'd like
It might already be available, only that I haven't found it.
But I would like to look at something from useField and be able to figure out if this field is required or not.
Without having to pass a property to my component for it that might get out of synch with the schema if someone makes code changes.
Describe alternatives you've considered
I've searched for it in meta from useField.
Passing a boolean property to my component.
But I would like to use the name connection to avoid the "required flag" travelling another path (view model -> view -> component prop vs useField) to avoid mistakes.
Beta Was this translation helpful? Give feedback.
All reactions