Proper way to declare with Zod
hi guys, Noob question:
Is it better to: A) create types and then check them with zod? or B) better to create Zod objects and then infer types from them?
I think i would prefer to do A since it appears cleaner to me, but i also dont see them doing it like this in the docs, so i wonder why?
2 Replies
Zod schemas can include a lot more information than you'd be able to provide with just one example of an object.
For example this declares that thing must match an email regex and be at least 5 chars long. While otherThing must be a string | null | undefined
Thank you! Agreed - the draw back is harder to incrementally adopt but this will be better