koa-validate icon indicating copy to clipboard operation
koa-validate copied to clipboard

object validation

Open dehbmarques opened this issue 9 years ago • 10 comments

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.

dehbmarques avatar Oct 18 '14 03:10 dehbmarques

Coverage Status

Coverage increased (+0.04%) when pulling 55f6ee367f9b2ab110c7003526cca14d2d38cb72 on dehbmarques:feat into 64e41a39a82f55d3dcf7d1168185758493ee12f5 on RocksonZeta:master.

coveralls avatar Oct 18 '14 03:10 coveralls

Coverage Status

Coverage increased (+0.05%) when pulling 95262f38b7f6461b0e5ca3a4c1c3f9812e5778f6 on dehbmarques:feat into 53dfc7853a26db24b20e9a32e48317481ef11713 on RocksonZeta:master.

coveralls avatar Jan 02 '15 21:01 coveralls

:+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.

00defeat avatar Jan 19 '15 13:01 00defeat

+1 Nice idea

danneu avatar Jan 22 '15 19:01 danneu

Is there any progress with this being merged?

AJCStriker avatar Mar 26 '15 18:03 AJCStriker

  • 1 for merging this

brasilikum avatar May 18 '15 09:05 brasilikum

+1 for merging this.

paambaati avatar Jul 24 '15 11:07 paambaati

@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.

00defeat avatar Sep 01 '15 02:09 00defeat

@b3njamin, merged :+1:

dehbmarques avatar Sep 01 '15 23:09 dehbmarques

very useful feature :+1:

hyzhak avatar Mar 06 '16 20:03 hyzhak