Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

Commit

Permalink
Fix NaN incorrectly passing validation as a number.
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Lau committed Jun 2, 2015
1 parent 49460c7 commit 8610045
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/utils/isNumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
* @param {object} input
*/
var isNumber = function(input) {
return typeof input === 'number';
return typeof input === 'number' && !isNaN(input);
};
7 changes: 4 additions & 3 deletions tests/json/attributes/type/number.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ suite('JSON/Attribute/type#number', function() {
true,
{},
[],
NaN,
function() {}
].forEach(function(instance) {
Validator.validate(instance, schema, function(error) {
Expand All @@ -64,8 +65,8 @@ suite('JSON/Attribute/type#number', function() {
});
});

test('should run 21 times', function() {
expect(count).to.be.eql(21);
test('should run 22 times', function() {
expect(count).to.be.eql(22);
});

});
});

0 comments on commit 8610045

Please sign in to comment.