Skip to content

demonstrates how to validate the request body of requests in Node

Notifications You must be signed in to change notification settings

jangbl/node-request-body-validation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Node request body validation

This repository contains sample code on how to perform request body validation with the Node.js express framework and yup

Please help this repo with a ⭐️ if you find it useful! 😁

This repository is part of the Request body validation in Node tutorial series provided by productioncoder.com.

Request body validation in Node

For updates, please reach out to @_jgoebel on Twitter.

How to run this application

Running the project

Make sure to install the dependencies with npm

npm install

You can then run the project by executing

npm run dev

API

POST /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.