4.3.2 • Published 9 years ago

json-schema-validation-middleware v4.3.2

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

json-schema-validation-middleware

NPM version Build status Test coverage Dependencies

Validate your incoming requests using a json schema. Tested with restify.

Usage

Create your restify server and your json schema. Adding a validation middleware to an endpoint couldn't be simpler:

var validationMW = require('json-schema-validation-middleware');
server.post('/foo', [
    validationMW(schema),
    myRealHandler
]);

You can optionally configure the middleware to use a custom error handler:

validationMW.configure({
    errorHandler: function (error, res, next) {
        //Do whatever you like here, for instance:
        res.send(400);
    }
});

Formats

The middleware uses the tv4-formats library, so the formats defined there are supported.

Accessing tv4

You can access tv4 directly, for instance to add schema definitions or formatters:

var tv4 = require('json-schema-validation-middleware').tv4;

Development

Style

An .editorconfig and .jshintrc enforce a coding style.

Tasks

Gulp is used as a task runner. Install it globally using npm install -g gulp. To see a list of gulp commands, run gulp help.

Git hooks

Upon commiting or pushing, a git hook wil automatically runt code linting or tests.

4.3.2

9 years ago

4.3.1

9 years ago

4.3.0

10 years ago

4.2.1

11 years ago

4.2.0

11 years ago

4.1.0

11 years ago

4.0.0

11 years ago

3.0.0

11 years ago

2.0.0

11 years ago

1.1.0

11 years ago

1.0.0

11 years ago