guillaumepotier / validator.js

Powerful objects and strings validation in javascript for Node and the browser
http://validatorjs.org
MIT License
255 stars 39 forks source link

Fix nested strict validation #39

Closed nunofgs closed 9 years ago

nunofgs commented 9 years ago

This PR passes the options object to nested constraints so that they may inherit the strict property.

Take, for example, the following constraints:

{
  user: {
    name: {
      first: new Assert().Required(),
      last: new Assert().Required()
    }
  }
}

If you try to validate with the object: { user: {} }, this will return true, even in strict mode, which is not desired.

This fix allows the nested name object to receive the strict mode validation from its parent.

guillaumepotier commented 9 years ago

Thanks a lot for your PR.

I'll release it in a new tag once #40 gets merged too.

Best