koa2-joi
v1.0.0
Published
Joi validation middleware for Koa
Downloads
5
Readme
koa2-joi
Koa middlevare for request validation using Joi. Have similar to koa-joi interface, but with support for koa2 with async/await
Installation
npm install --save koa2-joi
Usage
const validate = require('koa2-joi');
const schema = {
headers: joi.object().keys({
'my-custom-header': joi.string().required(),
}),
body: joi.object().keys({
email: joi
.string()
.email()
.required(),
password: joi
.string()
.required(),
}),
};
route.post('/login', validate(schema), async ctx => {...})