How to Validate Requests in Node JS (with Joi validator) | Node JS Tutorial

Ғылым және технология

In this video you'll learn how to validate API requests using the Joi validator library!
Joi: joi.dev/api/?v=17.6.0
Code: github.com/nikitapryymak/basi...
Contact Me: onelightwebdev@gmail.com
Github: github.com/nikitapryymak
Support Me: www.paypal.com/paypalme/nikit...
#nodejs #joivalidator #nodevalidation

Пікірлер: 47

  • @onigbindedavid6630
    @onigbindedavid663026 күн бұрын

    My first time watching ds n d explanation is top notch

  • @exrocker47
    @exrocker47 Жыл бұрын

    Hey man! I just wanted to say THANK YOU! Your content quality is seriously awesome. I have noticed you dont share too many vids. Dont let the algorithm get you and keep up the good work!

  • @nikita-dev

    @nikita-dev

    Жыл бұрын

    thanks so much!

  • @maxralph01
    @maxralph01 Жыл бұрын

    Thank you so much for this. Now, I will replace the "express-validator" with "joi".

  • @Sir_Pickle
    @Sir_Pickle Жыл бұрын

    Just want to say thank you. You deserve way more subscribers! Really helping me with my software development course

  • @nikita-dev

    @nikita-dev

    Жыл бұрын

    thank you!

  • @frogfood24
    @frogfood242 жыл бұрын

    Extremely concise, thanks!

  • @matthewakahomen1964
    @matthewakahomen19642 жыл бұрын

    Thanks for this, it was so helpful. I wish I could ask you some questions privately.

  • @JoshuaMusau
    @JoshuaMusau11 ай бұрын

    Thank you so much for this. You're super concise and eloquent. +1 subscriber

  • @FirozAhamed
    @FirozAhamed4 ай бұрын

    Nice work. That is lots of informative video

  • @sneezsloth
    @sneezsloth Жыл бұрын

    Very simple and helpful! 😊

  • @zaxpeedy2852
    @zaxpeedy2852 Жыл бұрын

    very professional and helpful.

  • @sultanmatthews-cy8uz
    @sultanmatthews-cy8uz Жыл бұрын

    Loved this!! Keep it up

  • @KelechiNwaji-fg3vn
    @KelechiNwaji-fg3vn Жыл бұрын

    This was really helpful, thanks

  • @WellingtonRogatiOficial
    @WellingtonRogatiOficial Жыл бұрын

    Thanks! You helped me a lot!

  • @nourkamal1412
    @nourkamal141211 ай бұрын

    thank u so much for that amazing tutorial.

  • @brayancantor4109
    @brayancantor41092 жыл бұрын

    Excellent video!

  • @osifojohn1513
    @osifojohn1513 Жыл бұрын

    Very helpful bro, keep it up

  • @vitaly-
    @vitaly-2 жыл бұрын

    Thanks! It's very useful)

  • @medAmineRg
    @medAmineRg Жыл бұрын

    awesome tut thankyou so much

  • @mehmetaltinsoy525
    @mehmetaltinsoy525 Жыл бұрын

    Great video. Thanks

  • @edu.paixao
    @edu.paixao11 ай бұрын

    Thank you! 🎉

  • @lannguyen-xr1xl
    @lannguyen-xr1xl Жыл бұрын

    thank you so much

  • @newtechnology452
    @newtechnology452 Жыл бұрын

    Thanks!

  • @CaptainSlowbeard
    @CaptainSlowbeard Жыл бұрын

    Nice job!

  • @nikita-dev

    @nikita-dev

    Жыл бұрын

    thank you!

  • @kakhatezelashvili3368
    @kakhatezelashvili3368 Жыл бұрын

    Great video. I just wonder why could not we just export a validator(payload) function that would validate the payload against predefined schema. What's the point of returning a function instead of validation result itself ?

  • @nikita-dev

    @nikita-dev

    Жыл бұрын

    you could definitely export a function that takes in a schema and payload, for example: const validate = (schema, payload) => schema.validate(payload); but then you would have to pass in the same schema every time you want to use it, as opposed to defining it once, and then using the function that is returned. Hope that makes sense

  • @runyalen
    @runyalen10 ай бұрын

    thanks, could you do the same video but creating a middleware validator these time programmed in OOP. Also can we create custom message responses with joi ?

  • @nikita-dev

    @nikita-dev

    10 ай бұрын

    yes, you can add custom error messages using Joi: stackoverflow.com/questions/48720942/node-js-joi-how-to-display-a-custom-error-messages

  • @AbaijanAlimbekov
    @AbaijanAlimbekov24 күн бұрын

    Nikita Hi , Is this methot working with chenging data on server too . If not how can I make that? Pls can you make new video about that : " how to patch data on next js with Joi libruary"

  • @ABUTAHER-wg7gz
    @ABUTAHER-wg7gz Жыл бұрын

    we can use async direct inside of Joi schema? mean user fetch form db

  • @nikita-dev

    @nikita-dev

    Жыл бұрын

    A Joi schema is not the right place to make a database call. You should first validate the incoming request (make sure they passed a valid userId, email, etc.), and once the Joi schema validates it, then you should make the database call. You only want to make database calls after you've verified that it was a proper request.

  • @muhammadfahad3483
    @muhammadfahad34832 ай бұрын

    How can I validate files?

  • @anothergamerbyjaman
    @anothergamerbyjaman Жыл бұрын

    What should I use if I want an unique value? if I signup with an email and I don't want you to have to create an account with the same email what should I use?

  • @nikita-dev

    @nikita-dev

    10 ай бұрын

    First you would validate that the email from the request is actually a valid email. Then in your controller make sure to add some business logic that verifies that the email is not in use (ie: fetching a user for that email, verifying that no user exists with that email)

  • @namikaze5374
    @namikaze53742 жыл бұрын

    How to implement custom message for each property?

  • @nikita-dev

    @nikita-dev

    2 жыл бұрын

    you can call the messages() method at the end of the Joi field, and pass in an object with the different error types as the keys, and the custom error message as the value. Here is an example: runkit.com/embed/fnfaq3j0z9l2 Here is the list of error types: github.com/sideway/joi/blob/master/API.md#list-of-errors

  • @eurisko7119
    @eurisko7119 Жыл бұрын

    which is better express validator or joi

  • @nikita-dev

    @nikita-dev

    Жыл бұрын

    Joi is a bit more popular and can be used for general object schema validation, while express-validator is used specifically as express middleware and is tightly coupled to express JS. I would recommend using Joi in most cases

  • @yazanali1454
    @yazanali1454 Жыл бұрын

    Can you share your font and theme and terminal theme please 🙁💚

  • @nikita-dev

    @nikita-dev

    10 ай бұрын

    VSC theme: "Atom One Dark" with the "Material Font Icons" extension. Font: "MonoLisa, Menlo, Monaco, 'Courier New', monospace" The terminal theme is a custom one I made using iTerm2

  • @yazanali1454

    @yazanali1454

    10 ай бұрын

    @@nikita-dev 💚

  • @alefali542
    @alefali5427 ай бұрын

    Hi🎉

  • @2A_American
    @2A_American Жыл бұрын

    Do some Udemy courses

  • @nikita-dev

    @nikita-dev

    Жыл бұрын

    I plan to make some courses in the upcoming months

  • @danielgabay8816
    @danielgabay8816 Жыл бұрын

    Thanks! You helped me a lot!

Келесі