koa2-joi

1.0.0 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i koa2-joi

Weekly Downloads

1

Version

1.0.0

License

MIT

Last publish

Collaborators

  • olessavluk