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!
Can I send the sample json data with the request instead using postman?
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?
Thank you soo much, Ajv concept cleared
thx Mohammed 👍
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
Nice video, thanks.
Glad you liked it!
ajv-sanitizer is also a nice library to use with ajv
Is it also possible to use AJV for FRONTEND data validation?
Thanke vier mach
you're most welcome
Good video
thx abh! 👍
А что лучше использовать по вашему опыту для валидаций тела запроса в 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
whenever I hear AJV my mind thinks of JAV
Sporer Expressway
Schowalter Mission
Stanton Hill
Maximillian Path
Douglas Road
Howell Knolls
Furman Forks
Aida Stravenue
Lonnie Forest
893 Arch Roads
Carter Radial
Hane Knolls
Clyde Place
Axel Lakes
Koelpin Loop
Shields Rest
Halvorson View
Sipes Wall
Charley Keys
Emmitt Points
Dorris Overpass
Reggie Mountain
Spinka Road
Kayden Landing
Hector Crossroad
Moore Mall
Hansen Valleys
Ariel Spur
Harber Court
Shanahan Way
Feest Road
Ondricka Inlet
Conn Road
Carter Mountains
Wilton Bypass
Audreanne Landing
Gracie Flats
Wilfred Key
Aisha Corner
Heaney Islands
Halie Valley
Pagac Fall
Hammes Station
Brigitte Parkways
Ardith Manor
Cleo Keys
Yost Cape
Hilma Pine
Giles Unions
Michale Pike
Herman Viaduct
Anne Bypass
01285 Queenie Coves
30479 Melisa Glens