7. JOI Validation Schema to validate request body | Node JS API Authentication

แชร์
ฝัง
  • เผยแพร่เมื่อ 11 พ.ย. 2024

ความคิดเห็น • 83

  • @mohankadolkar1227
    @mohankadolkar1227 4 ปีที่แล้ว +6

    Excellent tutorial. Explains every small detail. Makes beginners understand nuts and bolts. Thanks a lot. Keep it up.

  • @Dan-codes
    @Dan-codes 2 ปีที่แล้ว

    This is a great series, thank you. Coming from Postgres this caught me up to speed much faster than reading forums. You're a great human.

  • @BlackZero880
    @BlackZero880 2 ปีที่แล้ว +1

    hey yoursTRULY You Are Truly Awesome man...i have downloaded the whole playlist, thank you soooo much

  • @eyesight2073
    @eyesight2073 3 ปีที่แล้ว

    5:11
    You got a good rhyme there 😃

  • @dontargetme2416
    @dontargetme2416 4 ปีที่แล้ว +2

    Youre doing a really nice job , thank you for sharing your knowledge !

  • @pranavjoshi7697
    @pranavjoshi7697 3 หลายเดือนก่อน

    Does Joi provide a whitelisting feature for fields?

  • @ABUTAHER-wg7gz
    @ABUTAHER-wg7gz ปีที่แล้ว +1

    we can use doesExist direct inside of Joi schema?

  • @ze_chooch
    @ze_chooch 3 ปีที่แล้ว +1

    Joi is cool. Pretty easy to use.

  • @Pareshbpatel
    @Pareshbpatel 3 ปีที่แล้ว +1

    Excellent video on Joi validation. Thanks
    {2021-06-19}

  • @tech_with_manindra
    @tech_with_manindra ปีที่แล้ว

    What's the font and color theme you are using ?

  • @ramiworkstation
    @ramiworkstation 5 หลายเดือนก่อน

    Thank you very very much 🌻

  • @olawumisegun5898
    @olawumisegun5898 2 ปีที่แล้ว

    Please how can I possibly validate a patch request with Joi.
    I created a registerValidation function with all fields required, how can I pass only fields that needs to be updated to the same function ?

  • @isidme
    @isidme 3 ปีที่แล้ว +1

    Thanks, great tutorial.

  • @NamanUpadhyay-hp6dd
    @NamanUpadhyay-hp6dd ปีที่แล้ว

    Joi.string is not a function, getting this error

  • @preyaskansara
    @preyaskansara 3 ปีที่แล้ว

    how can we send a custom error message when an invalid email is sent.

  • @MohitYadav-by2hx
    @MohitYadav-by2hx 2 ปีที่แล้ว

    what vscode theme is this? and also the font?

  • @SanjarKodirov-ww3le
    @SanjarKodirov-ww3le 3 ปีที่แล้ว

    Thank you for saving my time )))

  • @Green-rice
    @Green-rice ปีที่แล้ว

    Good afternoon. Please tell me what is the name of the extension for writing queries right inside vscode🌀

  • @Issanjeewa
    @Issanjeewa 2 ปีที่แล้ว

    Great tutorial Thanks a lot...

    • @mafiacodes
      @mafiacodes  2 ปีที่แล้ว

      Subscribe like share

  • @priyankapriya9945
    @priyankapriya9945 ปีที่แล้ว

    please help email().lowercase() is not working it not checking lowercase and upper case

  • @sachinredekar6349
    @sachinredekar6349 2 ปีที่แล้ว

    Sir.......Please help me not getting exactly what happening
    {
    "error": {
    "status": 500,
    "message": "Cannot read properties of undefined (reading 'validateAsync')"
    }
    }
    it was working properly
    but sometime it started giving this error while registration

  • @narcissisticnarcissus4956
    @narcissisticnarcissus4956 3 ปีที่แล้ว +1

    This package is deprecated. Please use joi instead.

  • @j.k.ravshanovich
    @j.k.ravshanovich 3 ปีที่แล้ว

    Has anyone come across with issue of validating unicode characters, yet?

  • @ignacioswboada660
    @ignacioswboada660 3 ปีที่แล้ว

    Which extension do you use to make requests in VSC?

  • @Ghummakad_bande
    @Ghummakad_bande ปีที่แล้ว

    Do we need to create two schema
    One for joi validation and second for mongoose schema
    Am I right?

    • @mafiacodes
      @mafiacodes  ปีที่แล้ว +1

      yeah I did that to validate request body even before hitting the db, otherwise if you have a simple fun api for local use , you can ignore JOI, but if ur building an enterprise grade app, then definitely use JOI/ZOD/Yup, now I recommend ZOD because of automatic type generation.

  • @its_me_purple
    @its_me_purple 3 ปีที่แล้ว

    hai sir, how to validate the form data request using joi

    • @mafiacodes
      @mafiacodes  3 ปีที่แล้ว

      This is exactly what is explained in this video. Or you want to validate on the frontend...

  • @Volksverse
    @Volksverse 3 ปีที่แล้ว

    Hello Sir, Could you help me to show the response error messages in Angular am getting response but unable to show Messages

    • @mafiacodes
      @mafiacodes  3 ปีที่แล้ว

      use a toast or something like that

  • @alaoabiodun8575
    @alaoabiodun8575 3 ปีที่แล้ว +1

    Hello love your tutorial, keep up the great work in help the developer, Please I want to ask which plugins are you using for testing your Nodejs application instead of the postman.

    • @mafiacodes
      @mafiacodes  3 ปีที่แล้ว +1

      th-cam.com/video/elp-SbrKe-g/w-d-xo.html

  • @kartikthakre7888
    @kartikthakre7888 4 ปีที่แล้ว

    can we use other method intends of validate method of Joi?

    • @mafiacodes
      @mafiacodes  4 ปีที่แล้ว

      U can use any method provided it validates

    • @mafiacodes
      @mafiacodes  4 ปีที่แล้ว

      U can use regex also in joi

  • @khushboogoyal27khush
    @khushboogoyal27khush 3 ปีที่แล้ว

    @yoursTRULY if I want to provide a login either by email or mobile number. then how can i required either one of them in joi validation schema?

    • @mafiacodes
      @mafiacodes  3 ปีที่แล้ว +1

      Mark not as required and check manually after that

    • @khushboogoyal27khush
      @khushboogoyal27khush 3 ปีที่แล้ว

      @@mafiacodes Thank You

  • @adriana7907
    @adriana7907 9 หลายเดือนก่อน

    If you happen to receive the {
    "error": {
    "status": 500,
    "message": "authSchema.validateAsync is not a function"
    }
    } then just change module.exports = { authSchema }; to module.exports = authSchema ; and it will work.

  • @steveanthonyluzquinosagama7450
    @steveanthonyluzquinosagama7450 4 ปีที่แล้ว

    Can we avoid the use of Joi by using TypeScript or am I wrong?

    • @mafiacodes
      @mafiacodes  4 ปีที่แล้ว +3

      You are wrong, typescript is a language while Joi is a validation library which can be used with both Javascript and typescript

  • @animaltechno
    @animaltechno 4 ปีที่แล้ว

    Is there any difference between using @hapi/joi and mongoose.schema itself ?

    • @mafiacodes
      @mafiacodes  4 ปีที่แล้ว

      Joi has multiple options plus it’s more intuitive

    • @animaltechno
      @animaltechno 4 ปีที่แล้ว +1

      @@mafiacodes thanks for reply. I definitely dive into @hapi/joi !

    • @tech_verse_official
      @tech_verse_official 2 ปีที่แล้ว

      joi validates data even before the data is sent to the server... in most cases i use it to prevent user from submitting the wrong data... or if another develper uses postman

  • @khushboogoyal27khush
    @khushboogoyal27khush 3 ปีที่แล้ว

    @yoursTRULY instead of isJoi, I am using, if (Joi.isError(new Error()) === true) by following joi documentation but still the errors are not handling properly. can you suggest some modifications here so it will work properly?

    • @mafiacodes
      @mafiacodes  3 ปีที่แล้ว +1

      I need to check the joi package since @hapi/joi is deprecated ⚠️

    • @mafiacodes
      @mafiacodes  3 ปีที่แล้ว +3

      well I saw it, u simply need to do this inside catch block:
      catch(error) {
      if(Joi.isError(error)) {
      //handle the Joi error
      return
      }
      handle other errors
      }
      and moreover still the thing which I mentioned in the video...that if error.isJoi still works as in the documentation joi.dev/api/?v=17.3.0#errors

    • @khushboogoyal27khush
      @khushboogoyal27khush 3 ปีที่แล้ว

      Thank You so much sir, 🙏🏼😇

    • @mafiacodes
      @mafiacodes  3 ปีที่แล้ว +1

      Don’t forget to subscribe like share

    • @khushboogoyal27khush
      @khushboogoyal27khush 3 ปีที่แล้ว

      @@mafiacodes I've tried this way also, but still it's not working properly, whenever i add some invalid datas then it can't send any post req.

  • @AmitYadav-oh2vj
    @AmitYadav-oh2vj 2 ปีที่แล้ว

    @hapi/joi is also deprecated

    • @mafiacodes
      @mafiacodes  2 ปีที่แล้ว

      you can use joi only, ignore Hapi....
      Subscribe like share

  • @eronwhitefield-byuidahostu5745
    @eronwhitefield-byuidahostu5745 ปีที่แล้ว

    Did anyone else hear the deep rumbling sound around 7:55? ;)

    • @mafiacodes
      @mafiacodes  ปีที่แล้ว

      I don't hear any...replayed the video twice...🙂

  • @aneeshere
    @aneeshere 3 ปีที่แล้ว

    Thanks for the awesome videos. just wondering if we can handle the joi error status change to 422 inside the global error handler middleware so that we just write the one line `if(error.isJoi) error.status = 422` in one place and do not have to repeat it anywhere else in the application?

    • @mafiacodes
      @mafiacodes  3 ปีที่แล้ว

      Yes u can do that but error message would remain same

    • @aneeshere
      @aneeshere 3 ปีที่แล้ว +1

      @@mafiacodes yeah i tried it works. Anyways thanks again for the awesome content. I am trying to implement this same using typescript and i am learning way lot more than i had imagined.

  • @kishorerenangi3664
    @kishorerenangi3664 4 ปีที่แล้ว

    I prefere using module.export.authSchema = Joi.object instead of module.exports in case I have to export multiple things

    • @mafiacodes
      @mafiacodes  4 ปีที่แล้ว

      You can but this way also you can export multiple things

  • @platek549
    @platek549 3 ปีที่แล้ว

    hi i have issue with joi

    • @platek549
      @platek549 3 ปีที่แล้ว

      "error": {
      "status": 500,
      "message": "Cannot read property 'validate' of undefined"
      }

    • @mafiacodes
      @mafiacodes  3 ปีที่แล้ว +1

      can u tell me exactly where its giving you the error, and also use the latest version of joi, and use npm install joi only and NOT npm install @hapi/joi, since it's deprecated now...

    • @platek549
      @platek549 3 ปีที่แล้ว

      @@mafiacodes yeah I had spelling issue I typed module. Export instead of module. Exports and app doesn't know what I mean

  • @minalchhetri3878
    @minalchhetri3878 4 ปีที่แล้ว

    and sir after making this api , and teach us how to use this api in app

  • @eyesight2073
    @eyesight2073 3 ปีที่แล้ว

    11:09
    Who is this famous John Doe?🙄
    I find this name in many tutorials...

  • @ngneerin
    @ngneerin 3 ปีที่แล้ว

    Make new one for Joi. Hapi joi is gone. It's gone.

    • @mafiacodes
      @mafiacodes  3 ปีที่แล้ว

      Bro joi remains the same only firstly it joined hapi and now it’s alone as before. So the methods do not change, u now only need to install joi instead of @hapi/joi

    • @ngneerin
      @ngneerin 3 ปีที่แล้ว +1

      @@mafiacodes somethings are changed. Like the error handling. errors are no more handled by isJoi

    • @mafiacodes
      @mafiacodes  3 ปีที่แล้ว

      Ok I’ll check, dint work with joi after that

  • @Pareshbpatel
    @Pareshbpatel 2 ปีที่แล้ว +1

    {2021-12-12}