express-validate-schema
api
const validateSchema = require('express-validate-schema')
validateSchema([options])
options plain js object
- validationOptions an optional object, see
options
for joi.validate on joi repo - processHttpCallOnError false by default means you should use an error-handling middleware, in case you don't use it you should set this to true and when gets an error/exception on the validation
express-validate-schema
will process the http call immediate
each validation should be define before your route function (see examples) either the response
validation
route
validating query string
validateSchema([options]).query(some joi schema)
validating params
validateSchema([options]).params(some joi schema)
validating body
validateSchema([options]).body(some joi schema)
validating headers
validateSchema([options]).headers(some joi schema)
validating a custom key in the req object
validateSchema([options]).custom('key', some joi schema)
validating response
validateSchema([options]).response(some joi schema)
example
const express = const validateSchema = const app = const router = express // validating the querystringrouter // validating the paramsrouter // validating the bodyrouter // validating the headersrouter // validating the foobar custom req keyrouter // validating params, body and headerrouter