Permalink
Browse files

Change the way the ‘maximum’ attribute reports errors

  • Loading branch information...
1 parent 1fc9fb2 commit 2423b2d3371bda697687708f124548e4f3f20cc4 @Baggz committed Mar 12, 2012
Showing with 7 additions and 6 deletions.
  1. +7 −6 src/engines/json/attributes/maximum.js
@@ -2,14 +2,15 @@
* Maximum
*/
Validation.prototype.addAttributeConstructor('required', function maximumConstructor() {
-
return function maximum(property, propertyValue, attributeValue, propertyAttributes, callback) {
+
if (isNumber(propertyValue)) {
- var condition = (propertyAttributes.exclusiveMaximum) ? propertyValue < attributeValue : propertyValue <= attributeValue;
- return (condition) ? callback() : callback(true);
- } else {
- return callback(true);
+ if ((propertyAttributes.exclusiveMaximum && propertyValue >= attributeValue) || (propertyValue > attributeValue)) {
+ this.addError();
+ }
}
- };
+
+ return callback();
+ };
});

0 comments on commit 2423b2d

Please sign in to comment.