3 ms·
It's not a must, you can absolutely model IO and roll your own class validation/serializers methods and get both build time type safety and runtime validations
by evilduck 3y ago
It's not a must, you can absolutely model IO and roll your own class validation/serializers methods and get both build time type safety and runtime validations without including a library for it. It's typical old school JS style validation we've done for decades with just some stylistic adaptations to stay type safe.
However, grabbing Zod or io/ts is a lot less work and with tools like https://quicktype.io/typescript https://quicktype.io/typescript or https://transform.tools/json-to-zod https://transform.tools/json-to-zod you can paste in an API response, copy over a validator and export a type. My homegrown validator classes won't be nearly as clean or as quick.