We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Currently, a discriminated union schema, when given a value with a bad discriminator, does not spit out the given value in the ZodError:
const SomeSchema = z.discriminatedUnion('type', [ z.object({ type: z.literal('foo'), foo: z.string() }), z.object({ type: z.literal('bar'), bar: z.string() }), z.object({ type: z.literal('baz'), baz: z.string() }), ]); SomeSchema.parse({ type: 'qux' });
[ { "code": "invalid_union_discriminator", "options": [ "foo", "bar", "baz" ], "path": [ "type" ], "message": "Invalid discriminator value. Expected 'foo' | 'bar' | 'baz'" } ]
It would be nice if this error included the invalid value.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Currently, a discriminated union schema, when given a value with a bad discriminator, does not spit out the given value in the ZodError:
It would be nice if this error included the invalid value.
The text was updated successfully, but these errors were encountered: