@qiwi/mware-validator

1.15.0 • Public • Published

@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

Readme

Keywords

Package Sidebar

Install

npm i @qiwi/mware-validator

Weekly Downloads

6

Version

1.15.0

License

MIT

Unpacked Size

9.03 kB

Total Files

6

Last publish

Collaborators

  • antongolub
  • qiwibot