jsonschema
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -104,4 +104,7 @@ 'use strict'; | ||
var prop; | ||
// Don't validate undefined's | ||
// Only validate undefined's if they are required | ||
if (!helpers.isDefined(instance)) { | ||
if (helpers.isDefined(schema) && schema.required === true) { | ||
this.addError(helpers.createError(schema, undefined, options.propertyName, "is required", instance)); | ||
} | ||
return; | ||
@@ -186,2 +189,2 @@ } | ||
module.exports = Validator; | ||
module.exports = Validator; |
{ | ||
"author": "Tom de Grunt <tom@degrunt.nl>", | ||
"name": "jsonschema", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"dependencies": { | ||
"mocha": "~1.3.0", | ||
"mocha": "~1.3", | ||
"should": "~0.6.3", | ||
@@ -8,0 +8,0 @@ "deep-equal": "0.0.0" |
@@ -104,2 +104,23 @@ 'use strict'; | ||
}); | ||
describe('undefined but required object', function () { | ||
it('should NOT validate an undefined object', function () { | ||
var ret = this.validator.validate( | ||
{'foo': {'baz': 1}}, | ||
{ | ||
'type': 'object', | ||
'required': true, | ||
'properties': { | ||
'foo': { | ||
'type': 'object', | ||
'required': true, | ||
'properties': { | ||
'bar': {'type': 'object', 'required': true}, | ||
'baz': {'type': 'number', 'required': true} | ||
} | ||
} | ||
} | ||
} | ||
).should.not.be.empty; | ||
}); | ||
}); | ||
}); |
51662
1233
Updatedmocha@~1.3