koa-validate
koa-validate copied to clipboard
object validation
It's an object validation and sanitization for checkBody.
request.body: {
prop: 'name',
object: {
property: 'property test',
child: {
property: 'child property test',
child: {
property: 'child property test'
}
}
}
}
this.checkBody('name').notEmpty().len(3,20);
this.checkBody('object.property').notEmpty().len(3,20);
this.checkBody('object.child.property').notEmpty().len(3,20);
Also, this.body = this.errors;
at line 198 was causing an error when running tests.
The next line returns this.body = 'ok';
, so I commented the first one.
Coverage increased (+0.04%) when pulling 55f6ee367f9b2ab110c7003526cca14d2d38cb72 on dehbmarques:feat into 64e41a39a82f55d3dcf7d1168185758493ee12f5 on RocksonZeta:master.
Coverage increased (+0.05%) when pulling 95262f38b7f6461b0e5ca3a4c1c3f9812e5778f6 on dehbmarques:feat into 53dfc7853a26db24b20e9a32e48317481ef11713 on RocksonZeta:master.
:+1: is there an easy way we can get this to support objects in arrays. This is by far the cleanest validation library out there for KOA.
+1 Nice idea
Is there any progress with this being merged?
- 1 for merging this
+1 for merging this.
@dehbmarques are you able to merge the most recent master into your feat branch? Might make this a little more easier for @RocksonZeta to update.
@b3njamin, merged :+1:
very useful feature :+1: