Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@thedevminertv/body-validator

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@thedevminertv/body-validator

Validate Express request bodies easily

latest
npmnpm
Version
1.2.0
Version published
Maintainers
1
Created
Source

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'));

Keywords

express

FAQs

Package last updated on 10 Aug 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts