express-joi-validator
Simple validation middleware for express using the Joi validation suite.
Installation
npm install express-joi-validator
Dependencies
npm install joi
Usage
var Express = ;var BodyParser = ;var ExpressJoi = ;var Joi = ; var app = ;app; // Use Joi to create your schemasvar querySchema = query: limit: Joi offset: Joi ; // Attach the validator like other middlewareapp; // Use Joi to create your schemasvar bodySchema = body: name: Joi ; // Attach the validator like other middlewareapp; // Example error handlerapp; app;
If a validation error occurs it will either be handled by your express error handling middleware or thrown.
Joi
Since this middleware is just a wrapper around the Joi validate
method all the options
are supported.
Running Tests
npm install
npm test