var koa = require('koa');
var koaValidator = require('lib/koa-validator');
var app = koa();

// adding middleware extends Context with validation methods
app.use(koaValidator());

app.use(function *(){
  this.checkQuery('getparam', 'Invalid getparam').isInt();
  this.checkParams('urlparam', 'No url param').notEmpty();
  this.checkBody('postParam', 'Invalid postparam').isAlpha();
  var errors = this.validationErrors();
  yield errors if errors
  yield next;
});

app.listen(3000);

@@ -27,67 +27,210 @@
 var 
-koaValidator = require('lib/koa-validator');%0Avar app = koa(
+bodyParser = require('koa-body-parser');%0Avar router = require('koa-router');%0Avar koaValidator = require('./lib');%0Avar app = koa();%0A%0A// body needs to be parsed before using checkBody%0Aapp.use(bodyParser()
 );%0A%0A
@@ -339,13 +339,16 @@
 n *(
+next
 )%7B%0A
-  
+%09
 this
@@ -398,20 +398,30 @@
 .isInt()
-;%0A  
+.notEmpty();%0A%09
 this.che
@@ -469,18 +469,17 @@
 mpty();%0A
-  
+%09
 this.che
@@ -530,18 +530,17 @@
 lpha();%0A
-  
+%09
 var erro
@@ -573,35 +573,97 @@
 ();%0A
-  yield errors if errors%0A  
+%09if (errors) %7B%0A%09%09this.body = errors%0A%09%7D%0A%09else %7B%0A%09%09this.body = 'No validation errors'%0A%09%7D%0A%0A%09
 yiel

Extend example