This repository contains sample code on how to perform request body validation with the Node.js express framework and yup
This repository is part of the Request body validation in Node tutorial series provided by productioncoder.com.
For updates, please reach out to @_jgoebel on Twitter.
Make sure to install the dependencies with npm
npm install
You can then run the project by executing
npm run dev
Expected payload
{
"email": "john@example.com",
"firstName": "John",
"dob": "12-31-1950",
"countryCode": "US"
}
The server will return a 400
bad request error if the request body does not conform to the expected DTO (data transfer object).
Please check out the ./dto
directory to learn more about the expected request body.