JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3099
  • Score
    100M100P100Q122914F
  • License MIT

a koa params validate middleware.

Package Exports

  • koa-validate

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (koa-validate) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

koa-validate

validate koa request params and format request params

[![build status][travis-image]][travis-url] [![Test coverage][coveralls-image]][coveralls-url]

##installcation

$ npm install koa-validate

basic usage:

    app.use(require('koa-body')());
    app.use(require('koa-validate')());
    app.use(require('koa-router')(app));
    app.post('/signup',function*(){
        this.checkBody('name').optional().len(3,20);
        this.checkBody('email').isEmail();
        this.checkBody('password').notEmpty().len(3,20);
        this.checkBody('nick').optional().empty().len(3,20);
        this.checkBody('age').toInt();
        if(this.errors){
            return this.body = this.errors;
        }
        this.body= 'ok';
    });