Skip to content
Discussion options

You must be logged in to vote

@devklick

No, there is no support to get description from zod schema via react-hook-form but you extract zod schema into a separated module then import it everywhere you need to access schema field.

For example:

// schema.ts

const schema = z.object({
  name: z.string().describe('This is a name')
})

export default schema;


// Form.tsx

import schema from './schema';

const Form = () => {
   console.log(schema.shape.name.description);

   return <form>...</form>;
}

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by devklick
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants