-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Description
When throwing a ZodError it would be very useful to return with it's defined meta().
So when using it with treeifyError, would return like:
const tree = z.treeifyError(result.error);
// =>
{
meta: { title: "This is the title" },
errors: [ 'Unrecognized key: "extraKey"' ],
properties: {
username: { errors: [ 'Invalid input: expected string, received number' ] },
favoriteNumbers: {
meta: { title: "Favorite numbers", description: "The favorites numbers" },
errors: [],
items: [
undefined,
{
meta: {},
errors: [ 'Invalid input: expected number, received string' ]
}
]
}
}
}Or error.issues
[
{
origin: "string",
code: "too_small",
minimum: 10,
inclusive: true,
path: [ "name" ],
message: "Too small: expected string to have >=10 characters",
meta: { title: "Name", ... }
},
...
]
Metadata
Metadata
Assignees
Labels
No labels