Zod resolver and required fields #10041
Unanswered
wilson-webdev
asked this question in
Q&A
Replies: 1 comment 4 replies
-
|
Hello! Did you find a solution? |
Beta Was this translation helpful? Give feedback.
4 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.
-
As part of a React app, it's pretty common to have a
FormFieldwrapper for displaying labels, error messages etc. I have paired Zod with React Hook Form via the resolver. Is it possible to dynamically fetch whether a field is required based on the Zod schema?For example, I have this code sandbox with a
FormFeldcomponent, it takes a prop calledisRequiredwhich renders a red asterisk iftrue. Of course, I could passisRequired"manually", but I would like the schema to drive everything e.g. a small util likeisFieldRequired(key)would be great, but I can't find anything in the docs that would help with this.Beta Was this translation helpful? Give feedback.
All reactions