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

Let isLength have 0 has min. #5

Closed danneu closed 9 years ago

danneu commented 9 years ago

If I want to ensure a parameter is 0-100 chars long with .isLength(0, 100), isn't this line messing that up?

https://github.com/RocksonZeta/koa-validate/blob/0a95252b119babb97623268f97b424e2e5c43a3d/lib/validate.js#L123

Example: this.checkBody('markup').trim().isLength(0, 100) will always trigger isLength error when { markup: '' }. optional() didn't change anything.

RocksonZeta commented 9 years ago

this problem has fixed in 0.2.7,and I add a test case, thanks a lot!