Replies: 1 comment
Please send a full reproducible example. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
If I have a schema like the following...
z.object({ name : z.string(), description: z.string(), permissions: z.union([z.string(), z.literal('')] })I'm running a custom superRefine and trying to add an error to a specific field in the permissions object.
The object key (the field name) is held in
pID. But when trying to set an error on that field, it just creates an array on the 'permissions' path. This is the ctx:ctx.addIssue({ code: z.ZodIssueCode.custom, message:not cool bro, path: ['password', pID], fatal: true, })The error always comes up on
fieldErrors > permissions > 0instead of 'fieldErrors > permissions.{pID string}`What am I missing here?
All reactions