yield this.validateBody({ password: 'required', email_id: 'required' });tratando de validar el cuerpo de la solicitud, pero cuando todo está en él, todavía dice que los campos son obligatorios. todo está en él.
nodo 12.20.0
validación de koa 0.1.9
// Usar validación de koa
'use strict'; var koa = require('koa'); var app = koa(); var router = require('koa-router')(); require('koa-validate')(app); app.use(require('koa-body')({multipart:true , formidable:{keepExtensions:true}})); app.use(router.routes()).use(router.allowedMethods()); router.post('/signup', function * () { //optional() means this param may not in the params. this.checkBody('name').optional().len(2, 20,"are you kidding me?"); this.checkBody('email').isEmail("your enter a bad email."); this.checkBody('password').notEmpty().len(3, 20).md5(); //empty() mean this param can be a empty string. this.checkBody('nick').optional().empty().len(3, 20); //also we can get the sanitized value var age = this.checkBody('age').toInt().value; yield this.checkFile('icon').notEmpty().size(0,300*1024,'file too large').move("/static/icon/" , function*(file,context){ //resize image }); if (this.errors) { this.body = this.errors; return; } });