Replies: 1 comment 1 reply
-
|
In Zod v4, descriptions and other metadata are no longer stored directly on schema fields, so const schema = z.object({
name: z.string().describe("User's name"),
});
// Access the description:
const desc = schema.shape.name.meta()?.description; // "User's name"If you've chained methods like const nameSchema = z.string().describe("User's name").optional();
const desc = nameSchema.unwrap().meta()?.description; // "User's name"You can also retrieve descriptions from the JSON Schema output using More details in the Zod v4 metadata docs and related GitHub issue. If this answers your question, feel free to close the issue! To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
in v3 I used to do something like
in order to access the description assigned to a field using
.describewhat is the equivalent in v4Beta Was this translation helpful? Give feedback.
All reactions