I've been using Joi for validation in my NodeJS projects for quite some time now. Lately, I've been hearing a lot about Zod and other libraries, and I'm curious if Joi is still the best choice. I've tried Zod but found it somewhat unintuitive compared to Joi—maybe I'm just too accustomed to how Joi works. I would love to hear your opinions on whether I should stick with Joi or consider switching to Zod. What are the pros and cons you've experienced?
1 Answer
If you're using TypeScript a lot, Zod really shines because it integrates your validation schemas directly with types. So you get runtime validation and compile-time type safety all from one schema—no need for separate TypeScript interfaces. This can help reduce duplication and potential drift in your code.

That makes a lot of sense! So Zod actually generates types from the schema itself? That’s a game-changer since TypeScript doesn't exist at runtime. I've struggled with keeping my validators aligned in the past.