-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Error on nested discriminated unions #3804
New issue
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
Comments
|
Yes, that's intended, as both are of type
|
If you combine all of them, you can't use type alone to distinguish between them. What you need is something like this: z.discriminatedUnion(z.union(['type', 'subType']), [
vegetableSchema,
...discriminatedFruitSchema.options,
]); However, currently, it only supports a single string as the discriminator. |
Yeah, I'm guessing nested discriminated unions with different discriminators aren't currently supported? |
Yes. |
any update on this? |
It's really needed. Any update? |
Hi guys, I believe this will be fixed as part of Zod v4. |
Until now, in beta, is it fixed? |
Hi,
I have a schema like so:
All is good at first, but when I parse using the schema I get the following error:
The text was updated successfully, but these errors were encountered: