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

Поділитися
Вставка
  • Опубліковано 2 лис 2024

КОМЕНТАРІ • 82

  • @mohankadolkar1227
    @mohankadolkar1227 4 роки тому +6

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

  • @BlackZero880
    @BlackZero880 2 роки тому +1

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

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

  • @dontargetme2416
    @dontargetme2416 4 роки тому +2

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

  • @eyesight2073
    @eyesight2073 3 роки тому

    5:11
    You got a good rhyme there 😃

  • @ABUTAHER-wg7gz
    @ABUTAHER-wg7gz Рік тому +1

    we can use doesExist direct inside of Joi schema?

  • @pranavjoshi7697
    @pranavjoshi7697 3 місяці тому

    Does Joi provide a whitelisting feature for fields?

  • @Pareshbpatel
    @Pareshbpatel 3 роки тому +1

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

  • @ze_chooch
    @ze_chooch 3 роки тому +1

    Joi is cool. Pretty easy to use.

  • @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 ?

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

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

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

    Thank you very very much 🌻

  • @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

      ua-cam.com/video/elp-SbrKe-g/v-deo.html

  • @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

  • @isidme
    @isidme 3 роки тому +1

    Thanks, great tutorial.

  • @MohitYadav-by2hx
    @MohitYadav-by2hx 2 роки тому

    what vscode theme is this? and also the font?

  • @Issanjeewa
    @Issanjeewa 2 роки тому

    Great tutorial Thanks a lot...

  • @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🌀

  • @preyaskansara
    @preyaskansara 3 роки тому

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

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

  • @ignacioswboada660
    @ignacioswboada660 3 роки тому

    Which extension do you use to make requests in VSC?

  • @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?

  • @NamanUpadhyay-hp6dd
    @NamanUpadhyay-hp6dd Рік тому

    Joi.string is not a function, getting this error

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

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

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

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

  • @narcissisticnarcissus4956
    @narcissisticnarcissus4956 3 роки тому +1

    This package is deprecated. Please use joi instead.

  • @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

  • @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

  • @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

  • @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

  • @j.k.ravshanovich
    @j.k.ravshanovich 3 роки тому

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

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

  • @eronwhitefield-byuidahostu5745

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

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

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

  • @eyesight2073
    @eyesight2073 3 роки тому

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

  • @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

  • @minalchhetri3878
    @minalchhetri3878 4 роки тому

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

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

  • @AmitYadav-oh2vj
    @AmitYadav-oh2vj 2 роки тому

    @hapi/joi is also deprecated

    • @mafiacodes
      @mafiacodes  2 роки тому

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

  • @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

  • @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}