Skip to content

fix: intersected union schemas#283

Merged
mnahkies merged 4 commits intomainfrom
mn/282/intersected-unions
Dec 21, 2024
Merged

fix: intersected union schemas#283
mnahkies merged 4 commits intomainfrom
mn/282/intersected-unions

Conversation

@mnahkies
Copy link
Copy Markdown
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
Copy Markdown
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
@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