Skip to content

Commit 7613fdb

Browse files
committed
Merge pull request validatorjs#174 from tbasse/fix/addMissing
Add is(), not() and isFloat() to node-version
2 parents 9f41828 + f2cc507 commit 7613fdb

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/validators.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ var validators = module.exports = {
8989
isDecimal: function(str) {
9090
return str !== '' && str.match(/^(?:-?(?:[0-9]+))?(?:\.[0-9]*)?(?:[eE][\+\-]?(?:[0-9]+))?$/);
9191
},
92+
isFloat: function(str) {
93+
return validators.isDecimal(str);
94+
},
9295
isDivisibleBy: function(str, n) {
9396
return (parseFloat(str) % parseInt(n, 10)) === 0;
9497
},
@@ -117,9 +120,15 @@ var validators = module.exports = {
117120
}
118121
return str.match(pattern);
119122
},
123+
is: function(str, pattern, modifiers) {
124+
return validators.regex(str, pattern, modifiers);
125+
},
120126
notRegex: function(str, pattern, modifiers) {
121127
return !validators.regex(str, pattern, modifiers);
122128
},
129+
not: function(str, pattern, modifiers) {
130+
return validators.notRegex(str, pattern, modifiers);
131+
},
123132
len: function(str, min, max) {
124133
return str.length >= min && (max === undefined || str.length <= max);
125134
},

0 commit comments

Comments
 (0)