@qiwi/mware-validator
v1.15.0
Published
JSON-schema based validator middleware
Downloads
39
Keywords
Readme
@qiwi/mware-validator
JSON-schema based validator middleware
Install
yarn add @qiwi/mware-validator
npm i @qiwi/mware-validator
Usage
import validator from '@qiwi/mware-validator'
import express from 'express'
const app = express()
const schema = {
type: 'object',
properties: {
params: {
id: {
type: 'string',
pattern: '[abc]^\d{2}',
required: true
}
},
query: {
data: {
type: 'object',
required: true
}
}
}
}
app.get('/foo/:id', validator({schema}), (req, res) => {
...
res.send({...})
})
app.listen(...)
License
MIT