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 ?
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.
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
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.
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 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.
@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?
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
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
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.
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...
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
Excellent tutorial. Explains every small detail. Makes beginners understand nuts and bolts. Thanks a lot. Keep it up.
hey yoursTRULY You Are Truly Awesome man...i have downloaded the whole playlist, thank you soooo much
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.
Youre doing a really nice job , thank you for sharing your knowledge !
5:11
You got a good rhyme there 😃
we can use doesExist direct inside of Joi schema?
Does Joi provide a whitelisting feature for fields?
Excellent video on Joi validation. Thanks
{2021-06-19}
Joi is cool. Pretty easy to use.
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 ?
What's the font and color theme you are using ?
Thank you very very much 🌻
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.
ua-cam.com/video/elp-SbrKe-g/v-deo.html
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
Thanks, great tutorial.
what vscode theme is this? and also the font?
Great tutorial Thanks a lot...
Subscribe like share
Thank you for saving my time )))
Good afternoon. Please tell me what is the name of the extension for writing queries right inside vscode🌀
Restclient
how can we send a custom error message when an invalid email is sent.
Do we need to create two schema
One for joi validation and second for mongoose schema
Am I right?
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.
Which extension do you use to make requests in VSC?
Rest client
@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?
Mark not as required and check manually after that
@@mafiacodes Thank You
Joi.string is not a function, getting this error
please help email().lowercase() is not working it not checking lowercase and upper case
Add .string()
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?
Yes u can do that but error message would remain same
@@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.
@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?
I need to check the joi package since @hapi/joi is deprecated ⚠️
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
Thank You so much sir, 🙏🏼😇
Don’t forget to subscribe like share
@@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.
This package is deprecated. Please use joi instead.
Can we avoid the use of Joi by using TypeScript or am I wrong?
You are wrong, typescript is a language while Joi is a validation library which can be used with both Javascript and typescript
Hello Sir, Could you help me to show the response error messages in Angular am getting response but unable to show Messages
use a toast or something like that
Is there any difference between using @hapi/joi and mongoose.schema itself ?
Joi has multiple options plus it’s more intuitive
@@mafiacodes thanks for reply. I definitely dive into @hapi/joi !
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
can we use other method intends of validate method of Joi?
U can use any method provided it validates
U can use regex also in joi
Has anyone come across with issue of validating unicode characters, yet?
hai sir, how to validate the form data request using joi
This is exactly what is explained in this video. Or you want to validate on the frontend...
Did anyone else hear the deep rumbling sound around 7:55? ;)
I don't hear any...replayed the video twice...🙂
11:09
Who is this famous John Doe?🙄
I find this name in many tutorials...
I prefere using module.export.authSchema = Joi.object instead of module.exports in case I have to export multiple things
You can but this way also you can export multiple things
and sir after making this api , and teach us how to use this api in app
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.
@hapi/joi is also deprecated
you can use joi only, ignore Hapi....
Subscribe like share
hi i have issue with joi
"error": {
"status": 500,
"message": "Cannot read property 'validate' of undefined"
}
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...
@@mafiacodes yeah I had spelling issue I typed module. Export instead of module. Exports and app doesn't know what I mean
Make new one for Joi. Hapi joi is gone. It's gone.
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
@@mafiacodes somethings are changed. Like the error handling. errors are no more handled by isJoi
Ok I’ll check, dint work with joi after that
{2021-12-12}