1.0.6 • Published 6 years ago

koa-validate-json v1.0.6

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

koa-validate-json

NPM version license

  • koa拦截校验字段

使用

const schema = require('koa-validate-json')

router.post('/article', schema({
  type: 'object',
  properties: {
    title: { type: 'string', maxLength: 100 },
    content: { type: 'string' },
    tags: {
      type: 'array',
      items: { type: 'string', maxLength: 20 }
    },
    public: { type: 'boolean' }
  },
  required: [ 'title', 'content', 'tags' ],
  additionalProperties: false
}), async () => { 
  //controller function
})
  • 通常这个schema中的json校验可以通过Joi和jsonschema来生成
1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago