You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Maybe<T> not undefined for optional strings using z.string().nullish() with zod #1086
@ChrisEnglert Sorry for the late reply. I just released 0.18.0, so please try it. If you can still reproduce the issue, it would be very helpful if you could provide an environment where you can reproduce it, such as on codesandbox.
IMO there should be a setting that defaults to .nullish() and can be overriden, just like custom scalars. For those that need .optional() or .nullable() (depending on the case). Right now I'm handling in a post-processing script, which is not ideal
Fixed in #1423. Zod nullable field generation is now configurable, so projects whose Maybe type does not include undefined can opt into nullable instead of nullish.
Activity
Code-Hex commentedon Sep 23, 2025
@ChrisEnglert Sorry for the late reply. I just released 0.18.0, so please try it. If you can still reproduce the issue, it would be very helpful if you could provide an environment where you can reproduce it, such as on codesandbox.
supernaut commentedon Oct 8, 2025
I have the same issue in version 0.18.1. Replacing
.nullishwith.nullablefixes the issue.flesler commentedon Oct 22, 2025
IMO there should be a setting that defaults to
.nullish()and can be overriden, just like custom scalars. For those that need.optional()or.nullable()(depending on the case). Right now I'm handling in a post-processing script, which is not idealCode-Hex commentedon Apr 25, 2026
Fixed in #1423. Zod nullable field generation is now configurable, so projects whose Maybe type does not include undefined can opt into nullable instead of nullish.