3 ms·
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.
by ncallaway 3y 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.
- sk0g 3y agoCan you use something like Zod with the newtype pattern? I use DDD-style types for domain specific data over primitives.