1.2.0 • Published 5 years ago

@thedevminertv/body-validator v1.2.0

Weekly downloads
2
License
MIT
Repository
-
Last release
5 years ago

BodyValidator

BodyValidator allows you to easily check if the request body has certain properties.

Installation

npm install @thedevminertv/body-validator

Usage

const app = require('express')();
const BodyParser = require('body-parser');

const BodyValidator = require('@thedevminertv/body-validator');

// Apply BodyParser to parse JSON
app.use(BodyParser.json());

// Apply the BodyValidator to a route
// This will check that the body should have the "name" property
app.get('/api/test', BodyValidator(['name']), (request, response) => {
	res.send(`Hello ${req.body.name}`);
});

app.listen(3000, () => console.log('Server listening on port 3000'));
1.2.0

5 years ago

1.1.0

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago