See the entire conversation

Just learned about Zod, a #TypeScript schema declaration and validation library. Zod is a simple way to validate API response shapes. Declare a validator once, and Zod infers the type. Zod throws an error when the data doesn’t match the schema. 👍
31 replies and sub-replies as of Dec 28 2021

This article is confusing yup is also parsing the object and will throw an error if the schema doesn't match...admittedly I'm biased as the author of yup but the difference between "parsing" vs "validation" seems more like word play
The examples seem to intentionally use the less useful methods from yup to make a distinction between functionality that doesn't exist, picking `isValid` instead of `validate` which is the equivalent to zods `parse`.
no shade to zod, it's great, just dropping by to say that the idea that yup "only validates" is not accurate, yup was built _primarily_ as a tool to do parsing, based on a schema definition.
Thanks for clarifying Jason!
I've been using Zod for a year now and it's proven incredibly useful and very easy to use. And the maintainers are wonderful and responsive!
Didn’t hear about these libraries, but looks very interesting
Zod I would consider the successor to Joi
Oh shit I’ve been looking for something like this
I can also recommend schemawax. It leans a bit in the direction of Elm style. Non-Matching gives null by default but you can make it throw.
Zod is one of the MVP’s in the default @blitz_js setup
Loving Zod to write our own schema project and use throughout our multiple projects like react native, etc.
Very solid tools to have, especially when tech teams are divided into front end and back end
Exactly, I've been using Zod with trpc and React a lot recently, and it feels great!
It works really well with hook form 🔥
Zod with react hook form is the perfect combination
Hoe is it different from Joi?
README has a comparison section
Still on the fence between this and runtypes and io-ts. None of which appear to support parser/validator generation from openapi 3 api docs
runtime validation + types is an amazing thing to have in your arsenal. I personally use io-ts by @GiulioCanti, which allows both encoding and decoding, and sharing common "types" (io-ts-types) between apps, like `DateFromISOString` which takes a stringified date and validate it
but Zod is amazing too. Anything that makes our code safer is amazing. Much appreciation to the maintainers 👏
Are zod schemas serializable? At @VulcanJS we historically use SimpleSchema (it was used a lot in @meteorjs) but we have to move away from it in order to be able to store schemas in a database. This is necessary if you want to build a schema-based app generator.
Fun fact ... whats it called when an API returns the wrong data?