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
Samathingamajig17mo ago
the keyword you're looking for is "discriminated union"
gave_one
gave_oneOP17mo ago
not in different objects
Samathingamajig
Samathingamajig17mo ago
here's an example, there are other ways to do it https://codesandbox.io/s/restless-framework-c48qjc?file=/src/index.ts
Want results from more Discord servers?
Add your server