/body-schema-validator

About Body parser middleware for MongoDB, Express and Nodejs

Primary LanguageJavaScriptOtherNOASSERTION

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