in the validateDto function, you might want to change "res.status(400).json(errors);" to "return res.status(400).json(errors);" to prevent next being called and immediately return the response to the client
Thanks for the video! If you are getting a error that says "Cannot set headers after they are sent to the client", you can add an 'else' in front of the 'next()' in validate-dto.js.
this error means that you have basically instructed the server to send a response and shortly after it you are trying to modify the response by adding an additional header
this is ultimately a matter of taste. I'd go with some library. Some people use Ajv, others use yup or express-validator. Any of them works. Ajv has the additional advantage that it is standardized
What do you think about this video?
Was the explanation clear?
amazing explanations. very nice and clean way to handle input validation
Glad it was helpful!
Great video, thanks a lot for clearly explaining why the error reference needs to be copied.
thx Saketh 👍
Awesome!! The video helped me a lot. Thanks!
Glad it helped!
in the validateDto function, you might want to change "res.status(400).json(errors);" to "return res.status(400).json(errors);" to prevent next being called and immediately return the response to the client
I get a consistent-return eslint error after implementing your change. Would instead putting the "next();" under an else statement be ideal?
@@TakingItCasual can you send your code snippet after the change?
Can I send the sample json data with the request instead using postman?
Thanks for the video!
If you are getting a error that says "Cannot set headers after they are sent to the client", you can add an 'else' in front of the 'next()' in validate-dto.js.
this error means that you have basically instructed the server to send a response and shortly after it you are trying to modify the response by adding an additional header
ajv-sanitizer is also a nice library to use with ajv
Thank you soo much, Ajv concept cleared
thx Mohammed 👍
Nice video, thanks.
Glad you liked it!
Is it also possible to use AJV for FRONTEND data validation?
Thanke vier mach
you're most welcome
А что лучше использовать по вашему опыту для валидаций тела запроса в nodeJS?
this is ultimately a matter of taste. I'd go with some library. Some people use Ajv, others use yup or express-validator. Any of them works. Ajv has the additional advantage that it is standardized
Good video
thx abh! 👍
Sporer Expressway
whenever I hear AJV my mind thinks of JAV
Howell Knolls
Maximillian Path
Douglas Road
Halvorson View
Furman Forks
904 Jody Street
Reggie Mountain
Lonnie Forest
893 Arch Roads
Carter Radial
Hane Knolls
Aida Stravenue
Emmitt Points
Ariel Spur
Hector Crossroad
Axel Lakes
Moore Mall
Gracie Flats
Conn Road
Shanahan Way
Ondricka Inlet
Heaney Islands
Wilton Bypass
Lubowitz Stream
Pagac Fall
Ardith Manor
Hammes Station
Herman Viaduct
2789 Collin Orchard