Stop Using Zod!! This is 10x Smaller!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
Zod was one of my favorite discoveries of the last year but good things come and go let's check out a new library that may make you say bye bye Zod [Music] hello and welcome I'm Dave today we'll explore a new library that may easily replace Zod for type safe schema validation and I'll provide links to all resources in the description below I'll also provide a link for you to join my Discord server where you can discuss web development with other students and you can ask questions that I can answer and receive help from other viewers too I look forward to seeing you there today I'm providing a quick introduction to valobot by Fabian Hiller valibot provides typesafe schema validation which is the same thing we use Zod for and I have a Zod tutorial if you want to check it out but there is one big difference between Zod and vallabot with Zod we typically import Z which is an instance of Zod and that means we've imported all of the methods that we can call on Zod as well but maybe we don't need all of those methods in contrast valabot is modular so instead of being built as a large instance with many methods for example that alibot has many small functions and you only import what you need and you can see that import size is very small now validbot has many similarities to typescript and we can see some of that in this example where here we have a line of typescript that uses a partial and then below that we have valobot and here we're calling a partial function that we imported above and then we're calling the object function here and we have a key and a string and a second key and a number so it looks a lot like typescript in that regard likewise below we have a second line that is typescript and it's using pick on an object and a key and Below then we have valobot where it uses a pick function on an object and a key and much like with Zod we can infer our types from our schemas so here you can see we have a login schema in this example valibot code and we're importing in the type output and then below we Define our login data type and then we use output and type of login schema and then when we want to parse data from valobot we import parse and then we have our schema in this example a login schema and they show several examples here that we'll throw an error and then one successful example of the login schema as well so you can see it's expecting an email and a password and it expects those not to be blank so credit goes to Fabian and his team for creating valobot and for thanking the creator of Zod as you see that he does right here in this article there we go and Colin McDonald is the creator of Zod and of course this inspired the creation of valobot and that's how good code and good projects comes about one project can Inspire the other and so I think this is great and I do love using Zod as well but I'm going to use this valibot library on some code that I've used zodon maybe refactor that code and see how I like using valobot as well because because there is one big difference and that difference is the modular design of vallabot lets us only import what we need and it keeps this size of JavaScript that we ship to the client very small and that's a good thing anytime we can do that overall I think the ease of use for the developer experience seems good and time will tell how much adoption this gets good things have come along in the past and they haven't necessarily been adopted but I like this and I'm going to try valabot out the project did gain around a thousand GitHub stars in the first day it was announced and that is good and the word continues to grow and spread and if you take into account the big benefit between Zod and valabot of the size reduction that is valobot can be up to 10 times smaller than an import of Zod I think it's worth trying out so you give it a try let me know what you think in the comments and I'll make sure to leave links to this article the GitHub page and valobot.dev all in the description of this video so you can check it all out remember to keep striving for Progress over Perfection and a little progress every day will go a very long way please give this video a like if it's helped you and thank you for watching and subscribing you're helping my channel grow have a great day and let's write more code together very soon
Info
Channel: Dave Gray
Views: 15,687
Rating: undefined out of 5
Keywords: zod, valibot, type safety, type validation, schema validation, typescript, type safe schema validation, zod equivalent, zod vs valibot, javascript schema validation, data validation, infer types, zod type inference, type inference, valibot type inference, valibot infer types, schema validation library, validate schema, zod typescript, zod ts, zod tutorial, zod validation, valibot typescript, valibot ts, valibot tutorial, valibot validation, zod js, zod javascript, js, ts
Id: nCZ06oegzeM
Channel Id: undefined
Length: 4min 37sec (277 seconds)
Published: Fri Jul 28 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.