NestJs - Pipes & Validation [07]

Поділитися
Вставка
  • Опубліковано 5 сер 2024
  • We cover the 2 different use cases for pipes. Using the built-in out of the box pipes, and creating your own custom pipe. We also cover 2 different ways of validating request inputs in our application.
    If this video was helpful, make sure to leave a like & subscribe :)
    Timestamps:
    ---------------------
    0:00- What is a pipe?
    2:30- Understanding the Pipe arguments
    4:43- Using a transformation pipe
    8:12- Introducing Built-in pipes
    9:28- Quick recap
    10:53- Configuring pipes
    11:44- Handling Multiple Arguments
    13:42 -Throwing errors from our pipes
    15:02- Using ValidationPipe
    21:11- Using Joi validation
    24:28- Summary

КОМЕНТАРІ • 20

  • @quang.luu.179
    @quang.luu.179 4 місяці тому +1

    Hei I love the way you make the chapters out of the video. Really easy to follow.

  • @lclkn
    @lclkn 2 дні тому

    thank you very much!

  • @omarps6622
    @omarps6622 5 місяців тому +1

    I hope you continue. I have not found anyone better than you in explaining and simplifying concepts. Even though before watching your lessons I read the documentation, but you always add something new for me, whether I did not understand it sufficiently or neglected to understand it.

    • @Computerix
      @Computerix  5 місяців тому +1

      I'm really happy I'm able to help! And I'm confident you'll enjoy the multitenancy and best practices videos after the series :)

    • @omarps6622
      @omarps6622 5 місяців тому

      @@Computerix Very excited to get there, I'm sure I'll see something great 💫

  • @juliusngwu
    @juliusngwu 10 місяців тому +1

    You are a born teacher. Thank you

  • @algorfernand2483
    @algorfernand2483 6 місяців тому

    I have really loved this series, I would love it more if you continued on testing.

    • @Computerix
      @Computerix  6 місяців тому

      Thank you! I'm confident you will enjoy the rest of the series, inluding multitenancy and caching with redis :)

  • @brytebee1
    @brytebee1 9 місяців тому

    I couldn't resist commenting😏You're an amazing creator. Thanks for this content/video.

  • @MohamedSaqr
    @MohamedSaqr 7 місяців тому

    Thanks. Excellent explanations for the pipes.🙏🙏
    I have a question: When should I use DTOs or JOI schema?

    • @Computerix
      @Computerix  7 місяців тому +1

      Thanks for the comment !
      It comes down to personal preference.
      Using DTOs is more strongly typed and can provide better integration with NestJS, it not only provide validation for the request payload (if you are using the class-validator class with it of course), but also helps you by setting constraints on the data you transfer (typescript would complain if you try to send a Person object instead of a Produt object for example) .It's always better to use specific types for your data rather than "any" for example.
      If you are familiar with Joi and know it well, you can use it to provide complex validation to your request payload.
      I personally go with Joi for my validation because I am used to creating complex validation with different conditions using it. BUT, I also use DTOs (without the class-validator) to specify types and add constraints in my code (typescript would complain if I do not respect the DTOs when passing data from one place to another).
      If you haven't used Joi much before, I recommend you go with DTO + class-validator.
      If you're comfortable with Joi and have used it for complex validation with different conditions (not just basic types..) and would like to use it, then go for it to validate the request +use DTOs as well (for typescript) without the class-validator.
      But it really is a personal choice at the end of the day :)
      I hope this helps!

    • @MohamedSaqr
      @MohamedSaqr 7 місяців тому +1

      @@Computerix
      Thanks for the detailed response; I will go with DTO + class-validator. When anytime I need complex validation, I will use JOI.
      Thanks for your help

  • @bmxdeveloper
    @bmxdeveloper Рік тому

    thanks for this video, I have a question, at the minute 17:40 when you show the error message, how do I get these errors messages in the HttpExceptionsFilter

    • @bmxdeveloper
      @bmxdeveloper Рік тому

      at find it, at the exception.response object, thanks

    • @Computerix
      @Computerix  Рік тому

      If you want more details about the custom http exception filter, feel free to watch this episode ua-cam.com/video/AWqqg9Dtnc4/v-deo.html :))

  • @badralwattar5799
    @badralwattar5799 2 місяці тому

    Thank you for the videos 🫶🏻.
    Could you please use postman’s dark theme? ☠️

    • @Computerix
      @Computerix  2 місяці тому

      Dark mode feels weird on postman 😭