Hacker News new | ask | show | jobs
by ncallaway 1085 days ago
If you’re taking in data from an external source that needs to be validated, I highly recommend a schema library like zod, that can produce a typescript type.

That way you can define the type in a single place, have runtime validation for that type, but also be able to use the type in typescript at compile time.

1 comments

Can you use something like Zod with the newtype pattern? I use DDD-style types for domain specific data over primitives.