1.0.2 • Published 5 years ago

@salecycle/koa2-joi-validator v1.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

koa2-joi-validator

joi validation middleware for koa2

Owned by the the assets team

Koa middlevare for request validation using Joi.

Contains full typescript definitions

Installation

npm install --save @salecycle/koa2-joi-validator

Usage

const validate = require('@salecycle/koa2-joi-validator');

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