koa-router-joi-validator
v0.0.4
Published
Koa Middleware for route validation using Joi with super simple JSON schemas!
Downloads
13
Readme
koa-router-joi-validator
Install:
npm i koa-router-joi-validator
if you are using yarn:
yarn add koa-router-joi-validator
Usage:
import { validator } from 'koa-router-joi-validator';
const usersSchema = {
id: {
type: 'number',
options: { integer: true, max: 10 }
},
username: {
type: 'string',
options: { required: true }
}
};
router.post('/users', validator(usersSchema), ctx => {
ctx.body = 'Users route after validation!';
})