Is it possible to preprocess discriminator in zod discriminated union?
I need to coerce string
formatted numbers to number
before using a value in z.discriminatedUnion
. Is this possible? Here is a simplified code snippet:
How to Extend a Zod Object with Another Object and Pick Certain Entries?
I’m using Zod, a TypeScript schema validation library, to validate objects in my application. I have a scenario where I need to validate an object with nested properties and extend it with another object while picking only certain entries from the second object.