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

If using jsonpath, properties aren't properly marked as existing #19

Closed neonerd closed 8 years ago

neonerd commented 8 years ago

When using jsonpath, the library still uses key in body to determine whether given key exists.

return new Validator(this, key, getValue(body,key,transFn), key in body , body);

Therefore, with a body like this:

{"foo":{"bar":"hello world"}}

Following code will return an error:

this.checkBody('/foo/bar', true).first().exist()

Because the property is marked as exists:false.

neonerd commented 8 years ago

Wrote a fix in #20

neonerd commented 8 years ago

Merged.