How to access another item in a zod object

For example If condition.type is X I want the ID to be required Is this possible to do this in the side zod object with a refine or something else
No description
3 Replies
Samathingamajig
the keyword you're looking for is "discriminated union"
gave_one
gave_oneOP2y ago
not in different objects
Samathingamajig
here's an example, there are other ways to do it https://codesandbox.io/s/restless-framework-c48qjc?file=/src/index.ts

Did you find this page helpful?