Permalink
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...
2 parents 7410d02 + 8812353 commit dc0de361cd4c897feccc3abfab8d57dfa9bb8800 @Baggz committed Feb 4, 2013
Showing with 7 additions and 2 deletions.
  1. +1 −1 src/engines/json/getProperty.js
  2. +6 −1 tests/json/attributes/required/objects.js
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;

0 comments on commit dc0de36

Please sign in to comment.