RocksonZeta / koa-validate

validate koa request params and format request params
https://github.com/RocksonZeta/koa-validate
MIT License
284 stars 32 forks source link

object validation #1

Open dehbmarques opened 9 years ago

dehbmarques commented 9 years ago

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.

coveralls commented 9 years ago

Coverage Status

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

coveralls commented 9 years ago

Coverage Status

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

whatyoubendoing commented 9 years ago

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

danneu commented 9 years ago

+1 Nice idea

AJCStriker commented 9 years ago

Is there any progress with this being merged?

brasilikum commented 9 years ago
paambaati commented 9 years ago

+1 for merging this.

whatyoubendoing commented 9 years ago

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

dehbmarques commented 9 years ago

@b3njamin, merged :+1:

hyzhak commented 8 years ago

very useful feature :+1: