Accessing Zod Field Descriptions #888
-
|
I would like to access the Use CaseCurrently, Conform provides an easy way to access field names and errors: <div>{fields.password.errors}</div>However, I would also like to access descriptions that I define in my Zod schema, like this: const schema = z.object({
username: z.string().describe("Your unique identifier"),
password: z.string().describe("At least 8 characters long"),
});On the client side, I would ideally be able to render the description: <div>{fields.password.description}</div>This would improve the user experience by displaying additional contextual information. Additionally, in my project, I use components from <FormDescription>
{fields.username.description}
</FormDescription>For example, in my current setup, I manually define the description like this: <FormDescription>
This is your public display name.
</FormDescription>If Conform could automatically retrieve the description from the Zod schema, it would make integration much smoother. QuestionIs there currently a way to access Thanks for your work on this library! Looking forward to your insights. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Thank you for your suggestion. I have checked whether the proposed function can be implemented at present. To conclude, it will be difficult to implement immediately. Also, how about using the following as an alternative? const schema = z.object({
username: z.string().describe("Your unique identifier"),
password: z.string().describe("At least 8 characters long"),
});
console.log(schema.shape.username.description);First of all, Conform, i.e. Conform is made up of several packages, and considering the dependencies between each package, it would be better to place such a process to obtain the description in If I were to implement this proposal, I think I would implement a process in |
Beta Was this translation helpful? Give feedback.
Thank you for your suggestion.
I have checked whether the proposed function can be implemented at present. To conclude, it will be difficult to implement immediately. Also, how about using the following as an alternative?
First of all, Conform, i.e.
useForm, does not access Schema. Therefore, to implement this proposal, a new process is required to obtain the description data of the Schema passed from APIs such asuseForm. Furthermore, not only Zod but also Valibot can define descriptions, s…