How I replaced 200 lines of Zod refinements with 12

typescript dev.to

Every project I start ends up with the same validation code. Email with disposable domain blocking. Password with strength rules. Phone number via libphonenumber-js. Username with reserved word checks. All built with .refine() and .superRefine() chains on top of Zod. Different projects, different defaults, forgotten edge cases. The same bugs are showing up in different codebases because I copied the wrong version of the email regex. Here's what a typical registration form looked like before:

Read Full Tutorial open_in_new
arrow_back Back to Tutorials