Last active
April 25, 2024 22:36
-
-
Save ciiqr/ee19e9ff3bb603f8c42b00f5ad8c551e to your computer and use it in GitHub Desktop.
zod optional/nullable/nullish differences
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// zod schema | |
z.object({ | |
// valid if string or: | |
optional: z.string().optional(), // field not provided, or explicitly `undefined` | |
nullable: z.string().nullable(), // field explicitly `null` | |
nullish: z.string().nullish(), // field not provided, explicitly `null`, or explicitly `undefined` | |
}); | |
// type | |
{ | |
optional?: string | undefined; | |
nullable: string | null; | |
nullish?: string | null | undefined; | |
} |
very useful. Thanks!
this is brilliant
👍
Thanks :)
hero! ⭐️
Thank you so much! Very helpful! 💯
very helpful!
Oh I see, now it's time to refactor all the schema 🤣
Thanks bro, you are the best
thanks bro
thank you
thank you!!!
thank you :)
thank you :)
Yes!!
thanks mate
thanks mate!
Thanks mate!
thanks mate!
Thanks!
Thank you
Beautiful
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks!