diff --git a/lib/attribute.js b/lib/attribute.js index 67f526a..87da4de 100644 --- a/lib/attribute.js +++ b/lib/attribute.js @@ -63,11 +63,14 @@ validators.type = function validateType (instance, schema, options, ctx) { function testSchemaNoThrow(instance, options, ctx, callback, schema){ var throwError = options.throwError; var throwAll = options.throwAll; + var throwFirst = options.throwFirst; options.throwError = false; options.throwAll = false; + options.throwFirst = false; var res = this.validateSchema(instance, schema, options, ctx); options.throwError = throwError; options.throwAll = throwAll; + options.throwFirst = throwFirst; if (!res.valid && callback instanceof Function) { callback(res); diff --git a/test/combinators.js b/test/combinators.js index 4d66808..cd717c0 100644 --- a/test/combinators.js +++ b/test/combinators.js @@ -42,6 +42,12 @@ describe('Combinators', function () { }.bind(this)).should.not.throw(); }); + it('should not throw if valid when throwFirst is set', function () { + (function() { + this.validator.validate({ 'name': 'test2' }, this.schema, { throwFirst: true }); + }.bind(this)).should.not.throw(); + }); + it('should throw if invalid when throwError is set', function () { (function() { this.validator.validate({ 'name': 'test3' }, this.schema, { throwError: true }); @@ -81,6 +87,12 @@ describe('Combinators', function () { }.bind(this)).should.not.throw(); }); + it('should not throw if valid when throwFirst is set', function () { + (function() { + this.validator.validate({ 'name2': 'test2' }, this.schema, { throwFirst: true }); + }.bind(this)).should.not.throw(); + }); + it('should throw if invalid when throwError is set', function () { (function() { this.validator.validate({ 'name1': 'test1', 'name2': 'test2' }, this.schema, { throwError: true });