hapi-joi-common-schema
v1.0.1
Published
Sets common Join validation schema for all routes
Downloads
4
Maintainers
Readme
common-headers
Description
Node.js hapi.js common Joi validation schema plugin
Common Joi validation schema: Allows to set common Joi validation schema for routes that doesn't have skipTag or doesn't have skipPath
Usage example:
In manifest.js
const Joi = require('joi');
module.exports = {
server: {
app: {
slogan: 'New shiny service'
}
},
plugins: {
'hapi-joi-common-schema': {
skipTags: ['hapi-swagger'],
skipPath: [/^\/swaggerui/, /^\/documentation/, /^\/swagger\.json/],
schema: {
headers: Joi.object()
.label('x-request and x-correlation-id headers')
.keys({
'x-request-id': Joi.string().required(),
'x-correlation-id': Joi.string().required()
})
}
}
}