Request body validation in Node with yup | validating JSON schema

preview_player
Показать описание

Learn how to validate the request body of incoming HTTP requests and return proper errors if the request body is incomplete or does not meet our expectations. We will use the joi library to validate our incoming requests. This is episode 1 of our series in which we are setting up an example project.

00:00 Why do we need to validate request body validation
01:20 creating a Node project with npm
02:50 creating a simple express server with one endpoint
06:22 testing our server with Postman
08:03 how to validate a request body
08:50 defining the format of the request body with yup
12:00 creating a request body validation middleware
15:53 defining expected API errors
17:32 creating an error handling middleware
20:56 plugging our DTO validation middleware into our router
21:43 testing our request validation with Postman
23:45 yup caveats: applying default values to the request body
Рекомендации по теме
Комментарии
Автор

Let me know what you think about this video.
As always, feel free to write a comment if you want me to cover a particular topic

jgoebel
Автор

You're amazing, thank you for such good content that is for free... :)

patrykszindler
Автор

Nice video! I'll be looking for that Dependency Injection video!

joeygarcia
Автор

Congratulations, or as they say here in Brazil, "Você está de Parabéns"... very good

RicksSolutions
Автор

Great video always teaching us something useful, thanks for everything

arifali
Автор

Great . I just felt its only for me. :) thanks you so much

ghumakkad_baccha
Автор

Nice. But I'm looking for a way to generate that schema from an open api spec. This way, it would all depend on the spec. Is there a way to do it?

rao
Автор

Would you repeat the validation logic in Mongoose's model (using the inbuilt validator functions) or is that obsolete with this approach?

codinginflow
Автор

Amazing, I have been studying node for a while, and for sure your content is on the top list. Thanks for sharing such good knowledge.
What you commonly use for document an API? openSwagger or another tool.
What are your thoughts about moving from express to KOA or other library?
Could you indicate some good books about node.
And again AWASOME. Thanks a million.

douglasricardo
Автор

Great Video. Is this approach we get only single error back after validation when the request body actually has many errors. How to validate all fields and return all errors by using yup validation? Is it possible?

harikrishnan-prqk
Автор

Very good ... and how would you do for the function to validate the data sent by parameter ? Id for example...

RicksSolutions
Автор

thank you very much sir!
can you please open repository for this video?

makeit_studio
Автор

The github repo isn't available anymore. Good video btw

IranzinhoBRG
join shbcf.ru