-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Feat/1768 discriminated union object functions <<please review>> #1845
Feat/1768 discriminated union object functions <<please review>> #1845
Conversation
✅ Deploy Preview for guileless-rolypoly-866f8a ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site settings. |
9ffa384
to
b8d2ed9
Compare
@JacobWeisenburger or @colinhacks , can I please get a review? |
I don't feel like I have enough experience to approve this big of a change. Sorry |
b8d2ed9
to
63eb288
Compare
Anything holding this PR up? We've been waiting on it for a while 👀 |
Good question. It was already taking long, but now there's also this discussion: #2106 That being said... I also needed it, so I decided to just publish it myself as zod.discriminatedunion. That package also includes the work done by @maxArturo in GH-1075, which adds the option to use nested discriminated union. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Still waiting for review. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Not stale |
This is an impressive PR @teunmooij, but I'm against merging at this time. Apologies, and thanks for the great work here. I wish I had a long and complex answer to explain why but ultimately it's simple. This is a ton of code and complexity for a feature that most people will never use. On top of that, ZodDiscriminatedUnion is likely to go away in Zod 4, specifically because it invites such complexity as this: #2106 So improving DX here isn't a priority. |
Implements #1768
This PR adds the following functions to the
ZodDiscriminatedUnion
with same functionality as the ones onZodObject
:The discriminator is not affected by any of these functions.
I've also added an
expectShape
test util to validate the shape of a schema.