Not a fan of this for reasons I describe briefly in #403
In your particular case, you could implement a maybe function to avoid some verbosity:
const maybe = <T extends z.ZodTypeAny>(schema: T)=>{
return schema.optional().nullable();
};
// equivalent
maybe(z.string());
z.string().optional().nullable();
Source Feature request: “.maybe()” type · Issue #391 · colinhackszod at 2023-11-29.