0.2.0 • Published 3 years ago
body-schema-validator v0.2.0
body-schema-validator
Install
npm install --save body-schema-validator
Usage
Bodymen allows you to define a schema to control the fields sent through the request body.
import { body } from "body-schema-validator"
app.post('/posts', body({
title: {
type: String,
required: true,
trim: true,
minlength: 3
},
content: {
type: String,
required: true,
minlength: 32
},
tags: [String]
}),
(req, res) => {
console.log(req.bodymen.body) // will contain the parsed body
})
License
MIT © Jose Eduardo Soria