DEV Community

Cover image for ZOD is Typescript for Runtime - Less code but more Reliable
DX Knight
DX Knight

Posted on

ZOD is Typescript for Runtime - Less code but more Reliable

Zod is a schema validator, it means you give your object to it and it checks that if it is exactly the same as the interface that you defined or not, and if it isn't, it gives you an error!

What does it mean? It means that you don't need to use if-elses anymore like before, e.g.

if(name=== null || name==="")
...
if(name.length>5 && name.length<10)
...
if(number && number !==0 || number >0 ...)
Enter fullscreen mode Exit fullscreen mode

It does all this by itself only with the following command:

z.safeParse(formdata);
Enter fullscreen mode Exit fullscreen mode

more examples:

IP check example

Introduction ~7min 👌

To get to know it better, watch this video from WebDevelopSimplified:

7min ZOD introduction

Learn it completely ~30 min 🤩✨

To learn it completely, and use it to save alot of time from yourself and also shipping reliable code watch this video

ZOD in 30 min


VSCode Pro for Frontend developers: 🎖️

ZPack

Top comments (0)