Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #52 from bjnortier/required-property-with-zero-val…

…ue-generates-error

Fix required properties with zero value errors.
  • Loading branch information...
commit dc0de361cd4c897feccc3abfab8d57dfa9bb8800 2 parents 7410d02 + 8812353
@Baggz authored
View
2  src/engines/json/getProperty.js
@@ -6,7 +6,7 @@
*/
Validation.prototype.getProperty = function(property, source) {
if (source) {
- return (source[property]) ? source[property] : undefined;
+ return (source[property] !== undefined) ? source[property] : undefined;
} else {
return undefined;
}
View
7 tests/json/attributes/required/objects.js
@@ -23,6 +23,10 @@ suite('JSON/Attribute/required#objects', function() {
},
surname: {
required: true
+ },
+ age: {
+ required: true,
+ type: 'number'
}
}
}
@@ -41,7 +45,8 @@ suite('JSON/Attribute/required#objects', function() {
jsonSchemaValidator.validate({
user: {
name: 'František',
- surname: 'Hába'
+ surname: 'Hába',
+ age: 0,
}
}, schema, function(error) {
count += 1;
Please sign in to comment.
Something went wrong with that request. Please try again.