Validating user input with Zod

  Рет қаралды 22,864

Leigh Halliday

Leigh Halliday

2 жыл бұрын

In this video we use Zod to validate incoming user data sent to an API route in Next.js.
---------- Course
Want to go deeper with Next.js? Join me in my Next Level Next.js course where over 29 videos and 8 hours of content we'll build a full application from start to finish. We use TypeScript, GraphQL, Prisma, Apollo, Mapbox, Firebase and lots more. courses.leighhalliday.com/nex...
---------- Links
Zod - www.npmjs.com/package/zod
Starter Code - github.com/leighhalliday/next...
Source Code - github.com/leighhalliday/next...
---------- Connect
Join this channel - / @leighhalliday
Join me on Discord - / discord

Пікірлер: 60
@leighhalliday
@leighhalliday 2 жыл бұрын
Check out my course called Next Level Next.js! A full stack course covering GraphQL, TypeScript, Apollo, Prisma, auth and lots more! next.leighhalliday.com
@codernerd7076
@codernerd7076 2 жыл бұрын
It needs updates ☹
@kissmyussr1993
@kissmyussr1993 Жыл бұрын
Thanks a lot. Never again gonna data manually!
@VincentFulco
@VincentFulco 2 жыл бұрын
Outstanding example. I was just starting to dip into Yup this week, and this seems so much easier!
@leighhalliday
@leighhalliday 2 жыл бұрын
Thanks so much Vincent!
@lvgsredarmy8776
@lvgsredarmy8776 2 жыл бұрын
Thanks so much for the video Leigh! Short, sweet, well-explained, and included some use cases that were more than just the most basic code snippets you could find in the docs. Gave me a good idea that this is exactly the tool I'm looking for. Appreciate seeing you walk through your thoughts on it!
@MaxProgramming
@MaxProgramming 2 жыл бұрын
Just at the time I was building the app! Thank you so much for this one Leigh! I was looking for something like this!!!!
@leighhalliday
@leighhalliday 2 жыл бұрын
Nice! Glad it was helpful!
@CoryTheSimmons
@CoryTheSimmons 2 жыл бұрын
Cool library. Thanks for sharing, Leigh!
@leighhalliday
@leighhalliday 2 жыл бұрын
Thanks Cory!
@succatash
@succatash Жыл бұрын
I'm just leaving tutorial he'll and you explaining the "why" were doing stuff instead of just the what has been amazing for me. Keep releasing more content
@alexawunor8853
@alexawunor8853 Жыл бұрын
Nice and precise. Loved it. Thank you
@satindersingh9671
@satindersingh9671 2 жыл бұрын
I like the way you approach a problem, very cool
@leighhalliday
@leighhalliday 2 жыл бұрын
Thanks Satinder!
@harshpatel7704
@harshpatel7704 2 жыл бұрын
It was a really awesome and detailed video. Thanks for making such high quality content.
@leighhalliday
@leighhalliday 2 жыл бұрын
Thanks Harsh! Glad you enjoyed it
@vladyslavkarpenko9372
@vladyslavkarpenko9372 Жыл бұрын
Great explanation, Leigh🤝 I've already used Yup, so when starting to here about Zod the main question for me is: how the zod differs from Yup and what benefits that provide. Your overview gives me some clarification, thanks for that!
@TheMazanec
@TheMazanec Жыл бұрын
Nice! Just use the http semantics - the POST request, in its nature, should be for creating resources, thus the endpoint should just be "/api/users/". Also, http response codes have meaning - 200 = OK, no need for the {success: true}.
@blewis7454
@blewis7454 Жыл бұрын
This is great, thanks, best zod tute!
@umarchy
@umarchy Жыл бұрын
Appreciate the video. On spot. Thanks.
@namikazedevj46
@namikazedevj46 2 жыл бұрын
Thanks, really helpful
@sourabhshah9881
@sourabhshah9881 2 жыл бұрын
Amazing tutorial
@devmrin
@devmrin 2 жыл бұрын
Thanks Leigh!
@leighhalliday
@leighhalliday 2 жыл бұрын
Glad you enjoyed it!
@kamertonaudiophileplayer847
@kamertonaudiophileplayer847 2 жыл бұрын
It is a priceless advice, watch this guy.
@leighhalliday
@leighhalliday 2 жыл бұрын
Thanks! Appreciate the kind words!
@mtin79
@mtin79 Жыл бұрын
Awesome 👍🏻
@thedevdudeyt
@thedevdudeyt 2 жыл бұрын
thank you for share this information
@leighhalliday
@leighhalliday 2 жыл бұрын
Glad you enjoyed it!
@tech3425
@tech3425 Жыл бұрын
Cool stuff
@paulbird2772
@paulbird2772 Жыл бұрын
Useful tutorial, perfect to get an overview of the what and why of zod. One question what would be the use case for sending confirmEmail to the api.
@dennisgonzales9521
@dennisgonzales9521 Жыл бұрын
thanks!
@buddy.abc123
@buddy.abc123 2 жыл бұрын
this is awesome just like django-rest-framework serializers
@leighhalliday
@leighhalliday 2 жыл бұрын
Cool! I haven’t done much python dev but I really enjoyed Zod
@ifelseprog
@ifelseprog 2 жыл бұрын
Wow, I just got into zod too
@leighhalliday
@leighhalliday 2 жыл бұрын
It's pretty cool eh?
@royz_1
@royz_1 2 жыл бұрын
I might just use this instead of joi in my next project!
@leighhalliday
@leighhalliday 2 жыл бұрын
As far as I know, Zod works especially well with typescript
@manoj-k
@manoj-k 2 жыл бұрын
🔥🔥🔥
@leighhalliday
@leighhalliday 2 жыл бұрын
Thanks Manoj!
@shrestha0144
@shrestha0144 2 жыл бұрын
This is just like 'Yup'
@leighhalliday
@leighhalliday 2 жыл бұрын
Yea! They mention Yup and Joi on their main readme
@Fiddel
@Fiddel Жыл бұрын
Does Zod sanitize input?
@hayskapoy
@hayskapoy 2 жыл бұрын
Please do turborepo! Thanksssss
@leighhalliday
@leighhalliday 2 жыл бұрын
All in good time my friend
@radedev
@radedev 2 жыл бұрын
Thunder client is awesome
@leighhalliday
@leighhalliday 2 жыл бұрын
I agree! First time I had used it :)
@almuslax
@almuslax 2 жыл бұрын
Just heard it. Will give a try.
@Nurtylek
@Nurtylek 2 жыл бұрын
What abt joi? Could u compare them?)
@leighhalliday
@leighhalliday 2 жыл бұрын
I don’t know Joi but perhaps at some point. If a tool works for me, I don’t care so much about comparing all the options though, I’d rather just build stuff :)
@jehontanda
@jehontanda 2 жыл бұрын
Thanks for this video Leigh. though you havent replied my tweet
@leighhalliday
@leighhalliday 2 жыл бұрын
Hey Jeho! Just replied.
@abdelhameedhamdy
@abdelhameedhamdy 2 жыл бұрын
Is that kind of schema validation !
@leighhalliday
@leighhalliday 2 жыл бұрын
Indeed! Or data validation in general
@sridharkatta3461
@sridharkatta3461 2 жыл бұрын
what could be the difference between typescript and zod, I am not sure can we not accomplish the same in typescript ? @leigh Haliday
@leighhalliday
@leighhalliday 2 жыл бұрын
Typescript analyses your code, but Zod parses and validates external user data against a defined schema
@johnpatrickmadrigal477
@johnpatrickmadrigal477 2 жыл бұрын
@@leighhalliday so, which is better for you?
@ronniesunshine1163
@ronniesunshine1163 2 жыл бұрын
@@johnpatrickmadrigal477 well if you want to write all of your own validators from scratch go ahead. Zod just does this for you. For example, trying to write some complex regex to make sure a string is an email. Goodluck have fun. Or dates. Or credit card numbers. Or currencies. Sure you could do it yourself but why?
React Hook Form - Complete Tutorial (with Zod)
28:22
Cosden Solutions
Рет қаралды 84 М.
Learn Zod In 30 Minutes
31:03
Web Dev Simplified
Рет қаралды 133 М.
Пробую самое сладкое вещество во Вселенной
00:41
Can teeth really be exchanged for gifts#joker #shorts
00:45
Untitled Joker
Рет қаралды 13 МЛН
Please be kind🙏
00:34
ISSEI / いっせい
Рет қаралды 115 МЛН
How To Use TypeScript With Express & Node
17:05
Colt Steele
Рет қаралды 64 М.
Fixing TypeScript's Blindspot: Runtime Typechecking
15:44
Jack Herrington
Рет қаралды 28 М.
Learn Typescript with React | Quick Crash Course
16:59
developedbyed
Рет қаралды 89 М.
SvelteKit Authentication with Lucia & Prisma
23:46
Huntabyte
Рет қаралды 47 М.
Zod Goes Where TypeScript Can't
8:11
Theo - t3․gg
Рет қаралды 54 М.
Map vs Object in JavaScript
14:33
Leigh Halliday
Рет қаралды 21 М.
You might not need useEffect() ...
21:45
Academind
Рет қаралды 151 М.
Пробую самое сладкое вещество во Вселенной
00:41