mastercheck
Advanced tools
Comparing version 0.2.5 to 0.2.6
@@ -41,2 +41,3 @@ /** | ||
* max: 10, // Maximum value check. | ||
* integer: true, // Integer check. | ||
* select: [ 1, 3, 7 ], // Select match check. Default do not check. | ||
@@ -63,2 +64,5 @@ * }; | ||
} | ||
if (this.option.integer && data % 1 !== 0) { | ||
return data + ' should be integer'; | ||
} | ||
if (this.option.hasOwnProperty('select') && !~this.option.select.indexOf(data)) { | ||
@@ -65,0 +69,0 @@ return data + ' should match ' + this.option.select.join(' or '); |
{ | ||
"name": "mastercheck", | ||
"version": "0.2.5", | ||
"version": "0.2.6", | ||
"description": "mastercheck", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -62,7 +62,8 @@ MasterCheck | ||
``` | ||
// For a number values of 0-10. | ||
// For a integer number values of 0-10. | ||
mastercheck.format('Number', { | ||
required: true, // Existence check. Default do not check. | ||
min: 0, // Minimum value check. Default do not check. | ||
max: 10 // Maximum value check. Default do not check. | ||
min: 0, // Minimum value check. Default do not check. | ||
max: 10, // Maximum value check. Default do not check. | ||
integer: true // Integer check. Default do not check. | ||
}); | ||
@@ -69,0 +70,0 @@ |
@@ -10,3 +10,3 @@ var should = require('should'); | ||
_id: masterCheck.format('String', { required: true }), | ||
num: masterCheck.format('Number', { min: 0, max: 100 }), | ||
num: masterCheck.format('Number', { min: 0, max: 100, integer: true }), | ||
obj: { | ||
@@ -114,2 +114,23 @@ code: masterCheck.format('String', { minLength: 1, maxLength: 10 }), | ||
}); | ||
it('Integer check test.', function(done) { | ||
var dataList = [ | ||
{ | ||
_id: 'test1', | ||
num: 10, | ||
arr: [ 1, 2 ] | ||
}, | ||
{ | ||
_id: 'test2', | ||
num: 10.1, | ||
arr: [ 3, 4 ] | ||
} | ||
]; | ||
masterCheck.check('A', dataList, function(err, result) { | ||
should.not.exist(err); | ||
should.exist(result); | ||
result.should.eql({ test2: [ { key: 'num', value: 10.1, message: '10.1 should be integer' } ] }); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
@@ -116,0 +137,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34978
651
136