Skip to content
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

fix: intersected union schemas #283

Merged
merged 4 commits into from
Dec 21, 2024
Merged

fix: intersected union schemas #283

merged 4 commits into from
Dec 21, 2024

Conversation

mnahkies
Copy link
Owner

merge is only available on ZodObject and so we must use intersect if a ZodIntersection or ZodUnion is involved.

it'd probably be simpler to just always use intersect but that comes with drawbacks like being unable to pick or omit the resulting schema.

solves #282

@mnahkies mnahkies force-pushed the mn/282/intersected-unions branch from 3921e8d to e21f566 Compare December 21, 2024 09:17
await expect(execute({foo: "bla"})).rejects.toThrow('"bar" is required')
})

// TODO: https://github.com/hapijs/joi/issues/3057
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skipping this test so that I can merge the fix for the zod side without blocking on the joi builder. Raised an issue hapijs/joi#3057 to hopefully get some feedback on any existing ways to solve this

@mnahkies mnahkies marked this pull request as ready for review December 21, 2024 09:24
@mnahkies mnahkies enabled auto-merge (squash) December 21, 2024 09:25
@mnahkies mnahkies merged commit 2a610c5 into main Dec 21, 2024
4 checks passed
@mnahkies mnahkies deleted the mn/282/intersected-unions branch December 21, 2024 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant