0.0.1 • Published 9 years ago

body-schema v0.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
9 years ago

NPM version Build Status Dependency Status

JSON schema based validation for express routes. Validate req.body declaratively using JSON schemas. Uses tv4 to create body validation middelware.

Install

$ npm install --save body-schema

Usage

var bodySchema = require('body-schema');

var loginSchema = {
    'type': 'object',
    'properties': {
        'username': {
            'type': 'string'
        },
        'password': {
            'type': 'string'
        }
    },
    'required': ['username', 'password']
};

app.post('/login', bodySchema(loginSchema), login);

License

MIT © Andrew Lavers