Chris Cook @zirkelc.dev · Nov 6

Hey @colinhacks.com in some other post you mentioned how to extend Zod. I used it to add an `empty()` onto the ZodString like `z.string().email().empty()` Is there any way to extend ZodOptional<z.ZodString> so I can use something like `z.string().email().optional().empty()`?

0 likes 1 replies

?

Replies

Colin McDonnell 💎 Zod · Nov 6

i wouldn't recommend it...it's a weird pattern to put a string-specific method like .empty() on ZodOptional, which can wrap anything. and there's no practical way to conditionally add a method to ZodOptional if it wraps a ZodString instance