feat(zod/zod4): support @oneOf directive#1354
feat(zod/zod4): support @oneOf directive#1354AlexZasorin wants to merge 4 commits intoCode-Hex:mainfrom
Conversation
|
Hi! We're actively depending on this feature and would love to see it land. It looks like there's a merge conflict. @AlexZasorin, would you be open to rebasing? Happy to help if needed. Thanks for the work here! |
|
Closing this because @OneOf support landed in #1423, which closed #1262. The merged version handles Zod and Zod v4 as exactly-one-field union schemas and includes regression coverage. This PR also carried an old Vitest downgrade to get the tests moving at the time. That is no longer the direction of the repo after #1428, which keeps Vitest 4 and fixes the GraphQL module resolution issue instead. Thanks for pushing this forward when the repo was quiet. The final implementation is different, but the problem and examples here were useful. |
This PR introduces support for the @OneOf directive as documented in #1262 for zod and zodv4 schemas.
yup and myzod don't have a
neverequivalent, so validation must be implemented using a custom validator. I gave it a shot, but ultimately I didn't feel like trying to dive into yup, myzod, and valibot. I feel that support for zod/zodv4 is already pretty valuable and might be worth merging. I may eventually come back to support the rest, and obviously others are free to do the same based on the changes in this PR.Needed to downgrade vitest due to test failures with Vite v4.