Zod Makes TypeScript Even Better

Sdílet
Vložit
  • čas přidán 7. 06. 2024
  • Zod is amazing. It is not only an incredible validation library, but the direct interactions it has with TypeScript make it event better. Not having to define my types twice is a game changer and the simple yet powerful API of Zod is so nice. In this video I talk about what Zod is, show examples of how to use Zod, and talk about why it is so amazing.
    🌎 Find Me Here:
    My Blog: blog.webdevsimplified.com
    My Courses: courses.webdevsimplified.com
    Patreon: / webdevsimplified
    Twitter: / devsimplified
    Discord: / discord
    GitHub: github.com/WebDevSimplified
    CodePen: codepen.io/WebDevSimplified
    ⏱️ Timestamps:
    00:00 - Introduction
    00:28 - What Is ZOD?
    05:12 - ZOD Demo
    #Zod #WDS #TypeScript

Komentáře • 300

  • @hunterbertoson156
    @hunterbertoson156 Před rokem +195

    I would love to see a full tutorial on Zod! Also, an overview on your thoughts of the T3 stack.

  • @papadavis47
    @papadavis47 Před rokem +11

    Well done, Kyle. I have heard of zod, but I have not used it yet. I appreciate this concise video of what it is. A full tutorial with a React Typescript project would be great. Thanks for your work!

  • @remccs16
    @remccs16 Před rokem +5

    This is great, thank you Kyle! I would most certainly watch a full tutorial on Zod!

  • @codeNameMoose907
    @codeNameMoose907 Před rokem +1

    Awesome! I never heard of Zod! But more importantly... hope you feel much better soon Kyle! Your followers will be here waiting; we won't ever leave you. Thanks for everything you do! Sending you and yours super healthy and happy healing vibes, Buddy! 😊

  • @MrSwingbop
    @MrSwingbop Před rokem

    Full Tutorial is always welcome :D Thanks for all the precious tips!

  • @abdirahmann
    @abdirahmann Před rokem +3

    OMG OMG OMG OMG please do a full tutorial on this one, this is going to simplify my data validation logic on my node server, i also just migrated everything to ts yesterday, how awesome, also, i checked out express-validator and i didn't like how it did validation using middlewares and stuff soo this is a GOD send. Thanks GOD and thanks to you too for letting us know. love ya :)

  • @boian-inavov
    @boian-inavov Před rokem +17

    I love how Zod has picked up popularity lately. I’ve been using it it for a while and it’s been amazing! You just forget about the cumbersome validation part and focus on building your business logic. Also the way it’ll give you a ready made object in the way you’d been expecting it is just god sent! Glad that more people are covering it 👏

    • @BinaryReader
      @BinaryReader Před rokem

      Zod is no different to Yup, in fact, Zod is basically a clone of Yup with better static typing. Also, Zod is incredibly slow. Compare it to industry standard validators and it's like 300x slower to validate anything. You shouldn't be using Zod on the server side (it's that bad)
      The hype around Zod is real, but that doesn't make it good. It's just social media marketing and online influencers pushing it.

  • @arunavabanerjee6103
    @arunavabanerjee6103 Před rokem +35

    Hey Kyle, thanks for the video, zod seems super cool and I'd really like if could make a tutorial on it

  • @samuelwittlinger7790
    @samuelwittlinger7790 Před rokem +4

    Looks pretty good, personally I created a validator based on Joi which returns the object you are validating typecasted as the object type your validation schema is describing, which is a little more convenient than having to call infer every time.

  • @johnjohn7023
    @johnjohn7023 Před rokem

    i was waiting for this. thank you so much!!! We want full tutorial!

  • @souvlaki42
    @souvlaki42 Před rokem +5

    Very cool library. I really like the idea of a tutorial about it.

  • @fotoflo
    @fotoflo Před rokem +1

    Thank you for this great video! Wanted to note that Zod also offers a little bit of API around error messages as well.

  • @tsioryfitiavanaanhykrishna6992

    Aw longtime no see, I'm glad that u reach 1M sub ! Thanks for all your tutorials and keep up the good works !

  • @jayliu5432
    @jayliu5432 Před rokem

    Showing the form use case for Zod was super helpful. I finally get it!

  • @oleksandrluchytskyi6867
    @oleksandrluchytskyi6867 Před rokem +2

    Yes, please a video with most common recipes will be good to have 🤩

  • @akashsinha5148
    @akashsinha5148 Před rokem +8

    That would be wonderful 👍 please do a full tutorial. As your tutorials are small and feature packed.

  • @johnychinese
    @johnychinese Před rokem

    Yep Kyle, We want a full tutorial, I love how you simplify these things but still show how valuable and powerful they are

  • @ElliottTheUnicorn
    @ElliottTheUnicorn Před 8 měsíci

    thanks for the brief explanation. exactly what i was looking for 👍

  • @arryaz051
    @arryaz051 Před rokem +1

    Great tool, I use it a lot in NodeJS HTTP APIs to validate requests to the server and get the TypeScript type too.

  • @LasgCe
    @LasgCe Před rokem +2

    I remember watching the video 2 days ago and thinking, why would I ever need this ..
    Well, today I needed to create a very complex form validation and I gotta say, Zod is doing a great job so far

  • @blockstarter4745
    @blockstarter4745 Před rokem

    Always great content chief (Y) . . . Keep it up

  • @mikehill1114
    @mikehill1114 Před rokem

    I'm glad you said "comments below." I'm a full stack developer, but it wasn't until just now that I figured out where the CZcams comments were located ;)

  • @vsabhishek1
    @vsabhishek1 Před rokem

    Thank you, you are awesome👌 in explaining new concepts👏👏. Yes i would love to see you cover a full tutorial on zod using typescript.👍👍

  • @nmanikiran
    @nmanikiran Před rokem +5

    would love to see a full tutorial on Zod! And also please compare with Joi, ajv, zod

    • @BinaryReader
      @BinaryReader Před rokem

      Comparing Zod to Ajv would be embarrassing....for Zod >_>

  • @eschwinvanloon7826
    @eschwinvanloon7826 Před rokem

    Hey Kyle, Thank you for this video, i'd love to see a full tutorial on Zod!

  • @anatolydyatlov963
    @anatolydyatlov963 Před rokem +3

    Yep, I've been using it for the past few months and it's a must-have for schemaless dbs.

  • @mind_of_a_darkhorse
    @mind_of_a_darkhorse Před rokem +2

    I am intrigued! So, please make a tutorial on this game-changing way of doing things!

  • @martinpenev6750
    @martinpenev6750 Před rokem +1

    Hi Kyle
    Thx for showing us Zod, I really think it’s supercool!
    I was wondering: Which validation library have you been using before Zod?

  • @anthonyribeiro3918
    @anthonyribeiro3918 Před rokem

    I would love to see full tutorial too, your didatics is very good!

  • @sujoydutta920
    @sujoydutta920 Před rokem +3

    That would be really great to have a tutorial on Zod

  • @ReconNite
    @ReconNite Před rokem +13

    The problem I ran into with zod was that, not only was it super slow compared to other validators it was also very limiting as to what could be checked, or what could be coerced from one value to another. Although I still use it on some projects, I started to move over to superstruct for my more recent projects as it allows me to define custom refinements/coercions/types with little trouble. Of course this means that you lose the "built-in" or modular aspect of zod, superstruct makes it a lot easier for targeted validation.

    • @BinaryReader
      @BinaryReader Před rokem +1

      Try TypeBox, it's based on industry standards and it's also 300x faster than Zod.

  • @sohanbafna2282
    @sohanbafna2282 Před rokem

    I am using NestJs heavily for most of my codebase
    I define DTO's and nest js frameworks helps me to validate each of objects/types for request I make. In that case i would not need this
    Before that we have been using JSON schema validators where we define schema and validate the DTO's
    But now zod is permutation and combination of all - like even loash functions are wrapped, this is super useful and must give a try
    Thanks for quick overview

  • @shivamsahil3660
    @shivamsahil3660 Před rokem +1

    Hmm this seems more of a form validation library rather than improvement on typescript. Thanks a lot Kyle ❤️

  • @adisonmasih
    @adisonmasih Před rokem +1

    We really need a full tutorial! 🔥

  • @aram5642
    @aram5642 Před rokem

    Zod in a plain vanilla JS/TS project is definitely a win. No question about it. Would be interesting so see a video on how it integrates with framework like Angular and its built-in form validators.

  • @Jorgepr787
    @Jorgepr787 Před rokem

    Great intro to zod thanks!

  • @RandomActsOfWil
    @RandomActsOfWil Před rokem

    FULL TUTORIAL PLEASE!!!!! You are awesome!!!!

  • @tonyg_nerd
    @tonyg_nerd Před rokem +1

    Kyle, thanks for this. I'm tooling up for projects with React, MUI, Redux, and have been looking into Formik which validates (primarily) with Yup. I'm not loving the Formik/Yup side, so it'll be nice to give Zod a spin, especially since it's TS-first, as am I. As someone else noted, my primary questions will be about custom rules, field/field comparisons, and async/sync server validations. Zod MUST perform here or I need to go with an established standard.

    • @tonyg_nerd
      @tonyg_nerd Před rokem

      Looks like Zod is the winner with Hook Forms.

  • @FamilyGuyVids11
    @FamilyGuyVids11 Před rokem

    Great stuff. ill try it out

  • @twd2
    @twd2 Před rokem

    thanks ,Kyle a full tutorial would be greate 😍

  • @jawadshaikh1745
    @jawadshaikh1745 Před rokem

    definitely would love to have a full tut on Zod

  • @jtnovellis
    @jtnovellis Před rokem

    Yeah. I’d love to watch the full tutorial!

  • @NewHellz-
    @NewHellz- Před rokem

    hey there, may i ask something ??
    Is there possible if to create progress bar, with numered inside can change automatically with the date i want to??

  • @focusroom_
    @focusroom_ Před rokem

    Great! want to learn more about this

  • @allirey6196
    @allirey6196 Před rokem

    it's very interesting not just for frontend form validation but also for backend API validation

  • @morticie333
    @morticie333 Před rokem

    Great, please do the complex tutorial! I am looking forward! :)

  • @_the_one_1
    @_the_one_1 Před rokem +2

    You must be kidding! I was just trying to get deep with Zod and you posted a video! Great timing, thanks. I believe "everyone" would LOVE a full tutorial about Zod and why not... typing APIs both with static typing and validating the actual response

  • @arian5126
    @arian5126 Před rokem +3

    Great, exactly what I needed in the right time for a React project but for someone who's worked with Angular FormBuilder (which is a built-in module), you'd know how Angular is underrated.

    • @AmanSingh-px5if
      @AmanSingh-px5if Před rokem +1

      and exactly why react is so popular, not every project will need all the built in modules or even of the type that are baked in.

    • @arian5126
      @arian5126 Před rokem +5

      @@AmanSingh-px5if you don't have to use all built-in modules. The compiler removes unused modules from the bundle.

  • @josecongo9453
    @josecongo9453 Před rokem +1

    Please do a full Tuturial. I have a question, with zod do I still need create Interface(TS) for static checking? How can I reuse zod in multiple component(I thinking i react component).
    Thank you

  • @MultiPoiu
    @MultiPoiu Před rokem +4

    Erf, i'm sticking to AJV when doing api-first design and reusable component, because jsonSchema, even if it is a bit more tedious, it is reusable in all language, and can serve as first class API doc with swagger (jsonSchema are almost 100% compatible to swagger)
    And DTO with annotation are more readable for other stuff, I then use class-validator

  • @ColinRichardson
    @ColinRichardson Před rokem +3

    The problem I found with Zod is the transforms. It starts to blur the edges between validating and parsing.
    But my manager found a good library (I don't remember it's name for the top of my head) which uses the TS types and makes it a type validator at compile time, rather than runtime, using vite plugins. It seems like a better suit for us as we already have the types setup, rather than using Zod to Infer the types.

    • @hienluong9273
      @hienluong9273 Před rokem

      can you share what library you are using ?

  • @nomadshiba
    @nomadshiba Před rokem

    cool, i had made something similar years ago
    it was returning correct type after parse also
    but this is more solid and better than my ancient prototype thingy of course
    defiantly will use it!

  • @DillonRedding
    @DillonRedding Před rokem

    Super cool! This is like Joi, but specifically for TypeScript.

  • @daminipandey6490
    @daminipandey6490 Před rokem +2

    Hey. I'm just curious to know if it's possible to chain multiple regex expressions for the same input field and display different error messages .

  • @bouwensr
    @bouwensr Před rokem

    Love a full tutorial especially with a form generated out of json data and field required based on a ‘complete switch’

  • @nabinsaud4688
    @nabinsaud4688 Před rokem

    Yes Bring the zod validation video

  • @nickurchin9579
    @nickurchin9579 Před rokem

    At 1:25 ish I paused to read that Introduction off their site and once I read "The goal is to eliminate duplicative type declarations." - it clicked. As I'm on the tail end of the "learning" process, I hate getting comfortable with something (typescript in this case) only for a new/hot library to come along and improve it, because it also means I have yet another damn thing to learn before I feel ready to apply. However, I've actually recently run into that exact issue where I've had to declare the same type in two different places and it just felt gross, but I couldn't see a way around it; now we have Zod and that's awesome.

    • @nickurchin9579
      @nickurchin9579 Před rokem

      @@kishirisu1268 Shhhh, Typescript can hear you. You're real too, Typescript, we promise (don't worry, it won't resolve).

  • @pomprocks
    @pomprocks Před rokem +3

    You should show it with the same validation messages that your if/else validation has. Often certain messages need to be used, not just whatever messages your validation library produces.

  • @jimchapman4579
    @jimchapman4579 Před rokem

    Yes! Full tutorial please.

  • @dhaivathlal4870
    @dhaivathlal4870 Před rokem +1

    I'm about to do my first typescript form validation without any framework hence no framework provided form validation methods. This video just dropped right on time

  • @dephc0n1
    @dephc0n1 Před rokem

    Do you suggest using a query selector on MUI Typography? I see you're using it here.

  • @zhenglaowang8489
    @zhenglaowang8489 Před rokem

    I can't get over how clean your hair looks.

  • @j946atFIVEFOUR88AA
    @j946atFIVEFOUR88AA Před rokem

    Would be cool to see you have a talk with Theo and his T3 stack 🙂

  • @vizunaldth
    @vizunaldth Před rokem

    Kyle - full tut like you did on prisma would be nice to watch

  • @avinashmahananda8717
    @avinashmahananda8717 Před rokem

    Would love to see a full zod tutorial.

  • @DiegoBM
    @DiegoBM Před rokem

    Is it ok to gather then, that this would be runtime TypeScript that automatically generates the compile time types for you?

  • @0xSLN
    @0xSLN Před rokem

    great! full tutorial plz!!

  • @diegomiyt
    @diegomiyt Před rokem

    Can i use zod to 'autommaper' ( like automapper from c# ) for convert one type to another? (Ex: IUserResponse from api to IUserState to use in React )

  • @oswaldosoto4500
    @oswaldosoto4500 Před rokem +1

    would be nice have a zod tutorial for advanced user/passwords forms.

  • @avneet12284
    @avneet12284 Před rokem

    Cool. Full tutorial would be great

  • @mrcookie97
    @mrcookie97 Před rokem

    It can check if integer too that's quite nice

  • @paolocatalano2885
    @paolocatalano2885 Před rokem

    Hey Kyle! Please make a full tutorial of Zod including also Zorm (React form with Zod). Thank you!

  • @Zeee530
    @Zeee530 Před rokem

    In my previous project I used typescript, formik and yup for validation but Zod looks far more easier and manageable, I'll appreciate a full tutorial

    • @danhphamthanh197
      @danhphamthanh197 Před rokem

      I don't think so, Formik still make the form validate way more robust and manageble. Or maybe we can try Formik + Zod :D

  • @rand0mtv660
    @rand0mtv660 Před rokem +17

    Yeah Zod is cool, but it also kinda depends what you are doing IMO. If you use Zod to validate endpoints that you create with tRPC, then it seems to be great. If you use it for validating forms on frontend with react-hook-form, then yup might just be slightly better. That's at least from my personal experience comparing these two. yup also has a nice Typescript experience and the infer type from schema like the z.infer you shown here. Zod isn't the first schema validation library to utilize Typescript, but it seems people act like it is :)

  • @naezy316
    @naezy316 Před rokem

    Waiting for the full tutorial !!!

  • @nomiscph
    @nomiscph Před rokem +2

    In angular they have forms with full typescript support 🎉 for everyone working with angular

  • @paulo6069
    @paulo6069 Před rokem

    Seems quite useful, thanks for sharing. Although I do think you are abusing the ?. operator in your demo (why would your HTML elements be undefined?), making it more difficult to read.

  • @genc_emekli
    @genc_emekli Před rokem +1

    Hello. please do a full tutorial. I have already started to use zod. Many thanks.

  • @saimrgondal2360
    @saimrgondal2360 Před 2 měsíci

    I'd like a video comparing this with other form validation libs such as Joi. I;ve used Joi in the past and Im really curious to see if zod offers better usability. Thanks.
    Love your videos.

  • @MDFAYIZTP
    @MDFAYIZTP Před rokem

    Yup vs Zod , add a comparison in next video ❤ we are waiting

  • @MrFelipefsf
    @MrFelipefsf Před rokem

    Thanks Kyle, I would like to watch a tutorial with NodeJs data validation

  • @edwardalmanzar8382
    @edwardalmanzar8382 Před rokem +1

    Full tutorial 🙌

  • @FatahChan
    @FatahChan Před rokem

    Great video as always, can you make a video about PWA

  • @TundeEszlari
    @TundeEszlari Před rokem

    Magical video.

  • @paschalokafor9043
    @paschalokafor9043 Před 7 měsíci

    Can I use Zod in place of Yup when using formik?

  • @Dwafford01
    @Dwafford01 Před rokem

    I would also love to see a full tutorial on it

  • @chidimbamalu3490
    @chidimbamalu3490 Před rokem

    Good Video. Make a video on Zod like you did on Prisma

  • @wolraikoc
    @wolraikoc Před rokem

    How does it differ from joi apart from the ts integration?

  • @SpaceGravy
    @SpaceGravy Před 8 měsíci

    A comparison with yup would be appreciated!

  • @dansker5
    @dansker5 Před rokem

    zod reminds me a whole lot of joi.
    Are there any benefit to using zod over joi or vice versa?

  • @SoldierXfreedom
    @SoldierXfreedom Před rokem

    An essential for any API

  • @iapplethis
    @iapplethis Před rokem

    how is it different than other schema validations? just cuz of the infer?

  • @ivanjezakonful
    @ivanjezakonful Před rokem

    Full tutorial would be awesome

  • @jimg8296
    @jimg8296 Před rokem

    What's your thoughts on decorators vs zod?

  • @odisclemons9700
    @odisclemons9700 Před rokem +4

    If you truly love Zod then KNEEL before Zod. Note: I'm 100% sure no one on the internet thought to make that exact same joke

  • @wayneswildworld
    @wayneswildworld Před rokem

    So this is mainly for forms and user input correct???

  • @geforcesong
    @geforcesong Před rokem

    Waiting for full tutorial ❤

  • @dhawalparmar7117
    @dhawalparmar7117 Před rokem

    Can I use with pure javascript or in express js

  • @sumanbyravi8227
    @sumanbyravi8227 Před rokem +2

    Hey Kyle 🔥

  • @0xtz_
    @0xtz_ Před rokem

    Waiting for zod tutorial 👌