Hacker News new | ask | show | jobs
by ShadowBanThis01 1042 days ago
I just checked out the Zod intro pages but I still don’t know what problem it’s trying to solve. What is it adding to TypeScript (which I am not conversant in either)?

Thanks for any insight!

1 comments

runtime
"Runtime" is not a problem.
TypeScript-first schema validation with static type inference
There you go.

But schemas for what?

> Schema validation provides assurance that data is strictly similar to a set of patterns, structures, and data types you have provided. It helps identify quality issues earlier in your codebase and prevents errors that arise from incomplete or incorrect data types.

From: https://blog.logrocket.com/schema-validation-typescript-zod/

Most common use case I’ve seen is using schema validation for user input (like forms) so you don’t send junk off to the api, you can validate data at runtime (whereas typescript checks your types statically when compiled).

Thanks for the reply! I know what schema validation is, but didn't see what kind of schemas Zod was intended for. In other words, what is it parsing? That post you linked to looks very informative.