diff --git a/src/amanda.js b/src/amanda.js index b6fff47..71aee2c 100644 --- a/src/amanda.js +++ b/src/amanda.js @@ -640,7 +640,12 @@ * Maximum */ 'maximum': function(property, propertyValue, validator, propertyValidators, callback) { - return (typeof propertyValue !== 'number' || propertyValue > validator) ? callback(true) : callback(); + if (typeof propertyValue === 'number') { + var condition = (propertyValidators.exclusiveMinimum) ? propertyValue <= validator : propertyValue < validator; + return (condition) ? callback() : callback(true); + } else { + return callback(true); + } }, /** diff --git a/tests/validators/maximum.js b/tests/validators/maximum.js index ee44567..3d74594 100644 --- a/tests/validators/maximum.js +++ b/tests/validators/maximum.js @@ -15,13 +15,14 @@ exports['Test #1'] = function(test) { }; [ + 10, 11, 100, {}, null, [], function() {}, - 'Hello!' + 'Hello!' ].forEach(function(input) { amanda.validate(input, schema, function(error) { count += 1; @@ -34,11 +35,6 @@ exports['Test #1'] = function(test) { test.equal(error, undefined); }); - amanda.validate(10, schema, function(error) { - count += 1; - test.equal(error, undefined); - }); - test.equal(count, 9); test.done();