1.0.0 • Published 7 years ago

koa2-joi v1.0.0

Weekly downloads
13
License
MIT
Repository
github
Last release
7 years ago

koa2-joi

CircleCI

NPM version

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 => {...})