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

Add deep required option #40

Closed promag closed 9 years ago

promag commented 9 years ago

Enabling this option causes the Constraint to fail if it has at least one Required assert, no matter the validated data.

In the following example, the validation will fail because bar node is required even if foo is not.

var constraint = new Constraint({
  foo: {
    bar: new Assert().Required()
  }
}, { deepRequired: true });

var result = validator.validate( { }, constraint );

Depends on #39

guillaumepotier commented 9 years ago

Hi !

This is a great feature indeed !

Could you please do two small things please before merge:

Thanks a lot

Best

promag commented 9 years ago

@guillaumepotier you are welcome

promag commented 9 years ago

@guillaumepotier are you planning a new release with this?

guillaumepotier commented 9 years ago

Hi @promag, sorry, I did not see your latest commit :)

This PR looks great, I'm merging it and release a version for it.

Thanks for your work!

Best