Zod resolver and required fields #10041
Unanswered
wilson-webdev
asked this question in
Q&A
Replies: 1 comment 3 replies
-
Hello! Did you find a solution? |
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
-
As part of a React app, it's pretty common to have a
FormField
wrapper 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
FormFeld
component, it takes a prop calledisRequired
which 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