A collection of validation middlewares for koa.
import {NotEmpty, Size} from 'koa-validator-middleware';
import KoaRouter from 'koa-router';
const router = new KoaRouter();
router.post('/users',
NotEmpty('request.body.username'),
Size('request.body.password', 6, 20),
function (ctx) {
if(!ctx.validation.pass) {
console.log(ctx.validation.errors);
console.log(ctx.validation.error.username);
console.log(ctx.validation.error.password);
}
}
);