NestJs Full Course 2024 -2: Validation In NestJs (ZOD Included)
HTML-код
- Опубликовано: 8 фев 2025
- This video is part two of a NestJS full course and covers validation in NestJS applications, including using Zod.
Here are the key points covered in the video:
Transform Pipes:
Used to automatically transform the type of request parameters or query strings.
Examples include parseIntPipe to convert a string to a number and parseBoolPipe to convert a string to a boolean.
Validation with Class Validator and Class Transformer:
Requires creating a DTO (Data Transfer Object) to define the expected structure of the request body.
Class validator decorators are used to enforce validation rules on the DTO properties.
The @UsePipes decorator is used to apply the validation pipe to a controller method.
Custom Validation Pipe:
Can be created to implement specific validation logic.
The pipe should implement the transform method, which takes the value to be transformed and metadata as arguments.
The method can perform validation checks and throw exceptions if the validation fails.
Validation with Zod:
Zod is a library for creating validation schemas.
A Zod validation pipe can be created to perform validation using a Zod schema.
The schema defines the expected structure and validation rules for the request body.
The pipe's transform method uses the schema's parse method to validate the request body and throws a BadRequestException with specific error messages if validation fails.
Key takeaways:
To implement Zod validation:
Create a Zod validation pipe with a schema property.
Implement the transform method to use the schema's parse method and handle validation errors.
Infer the DTO type from the Zod schema using z.infer.
GitHub Repo(Please Give It a Star⭐ on GitHub): github.com/vah...
This is what I was looking for, essence collected in easy to understand way. Great job!
Thank you so much, I am really glad that you like it ❤️
Hi, I'm at the second video of this course and I have to tell so far it's just a great course on Nest JS.
Thanks 🙏🙏🙏. I am very glad to hear that.
As usual, great and respected effort
I don't know if the list's videos will be kinda independent from each other - like each video covers a whole topic from A to Z- or each video will build on the previous one, but for me, this video seems like a complete reference for the validation process
not gonna lie, kinda felt lost in the middle, maybe because I wasn't following on my vscode, but, overall, very very inclusive and direct explanation, really really respected effort
You asked me there if I watched any other videos, actually am taking it slowly, to apply and understand, but I can say that your list is considered as a top rated reference for me, really appreciate it, Well Done : )
Thank you so much for your thoughtful and detailed feedback, Ahmed! I really appreciate you taking the time to share your thoughts.
To address your question: the videos in this series are designed to stand on their own, meaning each video covers a topic comprehensively from A to Z. However, there is a subtle progression in the series, so watching them in order can help build a stronger understanding of the overall concepts.
The most awaited course on this channel. 🔥🔥
Glad you think so!
very greate video!!! I couldn't stop watching after one episode
Glad you enjoyed it!
This was awesome. Specially zod validation part. Thanks!
Glad it was helpful!
@@SakuraDev Waiting for you next video. Do you have any schedule for publish this playlist video?
Very good explanation. Thank you
You're very welcome! Feel free to ask if you have any other questions.
Great Video Brother. Thanks for the video 🫡
Thank you, glad you like it
Amazing, love this serie! How many episodes will it be? 😄
Thanks, it will be +10 episodes
Hi Sakura, waiting of your next episode. Because we tasted the blood and now we cannot wait so long for next episodes. Please try to post episodes in 2 to 3 days.
Yeah, I want to say that also, thanks!
I will do that
Excellent lesson… thank you 🔥💯 let me ask you… you have amazing project of real estate. Is it possible to recreate that project with Nestjs typeORM and sql db? This can be like Udemy course or on own platform for your courses and projects… !? When I browse RUclips… it seems that existing only Prisma and MongoDB … if it possible, it will amazing teaching example how to recreate from Prisma to typeORM… 🔥💯
I will do that
@@SakuraDev 🤩 wow … thank you so very very much 🙏🌈💯🙏❤️
You need to use time stamps
where is the git repo? thanks!
I've just put it in the description
@@SakuraDev thank you so much!!! :D
next episode when sakura ?
Hi, I am recording that