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...

Комментарии • 31

  • @jakubrakowski3429
    @jakubrakowski3429 Месяц назад +1

    This is what I was looking for, essence collected in easy to understand way. Great job!

    • @SakuraDev
      @SakuraDev  Месяц назад +1

      Thank you so much, I am really glad that you like it ❤️

  • @samadbouss8842
    @samadbouss8842 3 месяца назад +1

    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.

    • @SakuraDev
      @SakuraDev  3 месяца назад

      Thanks 🙏🙏🙏. I am very glad to hear that.

  • @AhmedMansour-tg5ez
    @AhmedMansour-tg5ez 27 дней назад

    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 : )

    • @SakuraDev
      @SakuraDev  27 дней назад

      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.

  • @belkocik
    @belkocik 7 месяцев назад

    The most awaited course on this channel. 🔥🔥

    • @SakuraDev
      @SakuraDev  7 месяцев назад

      Glad you think so!

  • @AndresYan-o1u
    @AndresYan-o1u 3 месяца назад

    very greate video!!! I couldn't stop watching after one episode

    • @SakuraDev
      @SakuraDev  2 месяца назад

      Glad you enjoyed it!

  • @muhammadyeasin722
    @muhammadyeasin722 7 месяцев назад

    This was awesome. Specially zod validation part. Thanks!

    • @SakuraDev
      @SakuraDev  7 месяцев назад

      Glad it was helpful!

    • @muhammadyeasin722
      @muhammadyeasin722 7 месяцев назад

      @@SakuraDev Waiting for you next video. Do you have any schedule for publish this playlist video?

  • @Coolmoments-gv1mk
    @Coolmoments-gv1mk 6 месяцев назад +2

    Very good explanation. Thank you

    • @SakuraDev
      @SakuraDev  6 месяцев назад

      You're very welcome! Feel free to ask if you have any other questions.

  • @techwithsaketh
    @techwithsaketh 2 месяца назад

    Great Video Brother. Thanks for the video 🫡

    • @SakuraDev
      @SakuraDev  2 месяца назад

      Thank you, glad you like it

  • @w3mw
    @w3mw 7 месяцев назад

    Amazing, love this serie! How many episodes will it be? 😄

    • @SakuraDev
      @SakuraDev  7 месяцев назад +1

      Thanks, it will be +10 episodes

  • @shivendersharma7317
    @shivendersharma7317 7 месяцев назад

    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.

  • @Mahadev-x7u
    @Mahadev-x7u 7 месяцев назад +2

    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… 🔥💯

    • @SakuraDev
      @SakuraDev  7 месяцев назад +3

      I will do that

    • @Mahadev-x7u
      @Mahadev-x7u 7 месяцев назад +2

      @@SakuraDev 🤩 wow … thank you so very very much 🙏🌈💯🙏❤️

  • @AlanDanielx
    @AlanDanielx 3 месяца назад +1

    You need to use time stamps

  • @javierrenteria3195
    @javierrenteria3195 6 месяцев назад

    where is the git repo? thanks!

    • @SakuraDev
      @SakuraDev  6 месяцев назад +1

      I've just put it in the description

    • @javierrenteria3195
      @javierrenteria3195 6 месяцев назад

      @@SakuraDev thank you so much!!! :D

  • @prashlovessamosa
    @prashlovessamosa 7 месяцев назад

    next episode when sakura ?

    • @SakuraDev
      @SakuraDev  7 месяцев назад

      Hi, I am recording that