How to use the isInt function from validator
Find comprehensive JavaScript validator.isInt code examples handpicked from public code repositorys.
GitHub: justinsisley/marshall
199 200 201 202 203 204 205 206 207 208
case String: isValid = typeof value === 'string'; break; case 'port': isValid = validator.isInt(stringValue, { min: 0, max: 65535 }); break; case 'nat': isValid = validator.isInt(stringValue, { min: 0 });
0
2
1
+ 63 other calls in file
98 99 100 101 102 103 104 105 106 107
} return true; }, isInt: function(rule, value) { if (rule) { return validator.isInt(value); } return true; }, isFloat: function(rule, value) {
0
2
2
+ 5 other calls in file
85 86 87 88 89 90 91 92 93 94
isIn: validator.isIn, // isInt(str [, options]) - check if the string is an integer. options is an object // which can contain the keys min and/or max to check the integer is within boundaries // (e.g. { min: 10, max: 99 }). isInt: function (str, options) { return validator.isInt(str, typeof options === 'object' ? options : undefined); }, // isJSON(str) - check if the string is valid JSON (note: uses JSON.parse). isJSON: validator.isJSON, // isLength(str, min [, max]) - check if the string's length falls in a range.
0
1
3
+ 17 other calls in file
104 105 106 107 108 109 110 111 112 113
return this; }; Validator.prototype.isLength = function(min, max, tip) { min = min || 0; max = v.isInt(max) ? max : Number.MAX_VALUE; tip = !v.isInt(max) ? max : tip; this.notEmpty(tip); if (this.goOn) { if (this.value.length<min || this.value.length>max) {
34
0
2
+ 5 other calls in file
20 21 22 23 24 25 26 27 28 29
* @param {String} id */ var validateID = module.exports.validateID = (id) => { if (!(id !== null && (typeof id === 'number' && id > 0 && Number.isInteger(id)) || // case when id is number (typeof id === 'string' && validator.isInt(id, {min: 1})) // case when id is a string )) { throw httpError(400, 'Invalid input.'); } }
6
11
0
+ 2 other calls in file
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
const validDecimal = url => validator.isDecimal(url); const validFloat = url => validator.isFloat(url); const validInt = url => validator.isInt(url); const validNumber = url => validator.isNumeric(url); const validOctal = url => validator.isOctal(url);
5
63
0
43 44 45 46 47 48 49 50 51 52
exports.isLessThanLength = function (value, length) { return validator.isLength(value, { max: length }) } exports.isInteger = function (value) { return validator.isInt(value) } exports.isMaxIntOrLess = function (value) { return value <= SQL_MAX_INT
2
5
35
75 76 77 78 79 80 81 82 83 84
// Simple predefined checks. // These are accessible to users by key names. var simpleChecks = { "*": function(x) { }, int: function(x) { check(x, "an integer", validator.isInt(x)); }, nat: function(x) { check(x, "a positive integer", validator.isInt(x, 0)); },
2
4
0
+ 4 other calls in file
80 81 82 83 84 85 86 87 88
amount: this.get('listingPrice'), bidderId, state: 'Active', }); } else { if (!(amount && validator.isInt(amount + ''))) { throw new BidError('Please specify the amount you want to bid'); } amount = validator.toInt(amount + '');
0
2
3
15 16 17 18 19 20 21 22 23 24
if (value === undefined || value === null) return false; const stringValue = value.toString(); const asInteger = stringValue.replace(/\./, ''); const isIntegerWhenRemovingDecimalPoint = validator.isInt(asInteger); return isIntegerWhenRemovingDecimalPoint; } module.exports = { isDate, isCorrectNumericValue };
0
1
2
+ 3 other calls in file
GitHub: BellSohn/booksvue
26 27 28 29 30 31 32 33 34
var validator_isbn = !validator.isEmpty(reqParams.isbn); var validator_title = !validator.isEmpty(reqParams.title); var validator_author = !validator.isEmpty(reqParams.author); var validator_editorial = !validator.isEmpty(reqParams.editorial); var validator_year = !validator.isEmpty(reqParams.year) && validator.isInt(reqParams.year,{gt:1,lt:Date.now}); var validator_pages = !validator.isEmpty(reqParams.pages) && validator.isInt(reqParams.pages,{gt:1}); if(validator_isbn && validator_title && validator_author && validator_editorial && validator_year && validator_pages){
0
0
1
GitHub: quan-kuang/rogge-bate
39 40 41 42 43 44 45 46 47 48
sshterm = req.body.sshterm; if (req.body.cursorBlink && validator.isBoolean(`${req.body.cursorBlink}`)) cursorBlink = parseBool(req.body.cursorBlink); if (req.body.scrollback && validator.isInt(`${req.body.scrollback}`, {min: 1, max: 200000})) scrollback = req.body.scrollback; if (req.body.tabStopWidth && validator.isInt(`${req.body.tabStopWidth}`, {min: 1, max: 100})) tabStopWidth = req.body.tabStopWidth;
0
0
0
+ 7 other calls in file
GitHub: Jeffrayeee/for-Bri
42 43 44 45 46 47 48 49 50 51 52
} function validatorType (type) { switch (type) { case 'int': return validator.isInt; case 'safe_string': return validator.isAlphanumeric; case 'boolean': return validator.isBoolean;
0
0
0
122 123 124 125 126 127 128 129 130 131
else { pool.query(signupQueries.getIdLieu, [lieu], ((error, results) => { if (error) return callback(error) else { if(result.rowCount != 0 && results.rowCount != 0 && validator.isInt(km) && validator.isInt(places) && validator.isDecimal(prix) && validator.isAscii(nom)) { if(id == ""){ pool.query(signupQueries.addCompetition, [nom, km, places, prix, result.rows[0].id_sport, results.rows[0].id_lieu], ((error, resultats) => { if (error) return callback(error)
0
0
0
GitHub: SubinY/koa-seed
316 317 318 319 320 321 322 323 324 325
if (typeof value === 'string') { this.parsedValue = validator1.toInt(value); return validator1.isInt(value, ...this.options); } else { this.parsedValue = value; return validator1.isInt(String(value), ...this.options); } case 'isFloat': if (typeof value === 'string') { this.parsedValue = validator1.toFloat(value);
0
0
0
+ 7 other calls in file
131 132 133 134 135 136 137 138 139 140
* 检查字符串是否为int * @param str 输入字符串 * @param options 参数项 */ isInt2(str, options) { return validator1.isInt(str, options); } /** * 检查number是否为int
0
0
0
+ 3 other calls in file
271 272 273 274 275 276 277 278 279 280
}) let is_chain_id_OK = validator.isInt(chain_id, { min: 1, allow_leading_zeroes: false }) let is_evolution_id_OK = validator.isInt(evolution_id, { min: 1, max: 3, allow_leading_zeroes: false })
0
0
0
+ 67 other calls in file
GitHub: marinakim4/eva
209 210 211 212 213 214 215 216 217 218
const filter = { "data.clientCode": escape(req.body.clientCode), "data.clientName": escape(req.body.clientName), "data.jobCode": escape(req.body.jobCode), "data.jobDescription": escape(req.body.jobDescription), "data.jobId": validator.isInt(req.body.jobId.toString()) && req.body.jobId, "data.staffCode": escape(req.body.staffCode), "data.dailyDate": escape(req.body.dailyDate), projectName: escape(req.body.projectName), };
0
0
0
+ 12 other calls in file
GitHub: lasuillard/accompany
24 25 26 27 28 29 30 31 32 33
&& validator.isLength(password, { min: 6, max: 100 }) && (validator.isAlphanumeric(nickname) && validator.isLength(nickname, { min: 2, max: 45 })) && validator.isEmail(email) && (validator.isAlphanumeric(username) && validator.isLength(username, { min: 1, max: 16 })) && validator.isIn(gender, ['M', 'F']) && validator.isInt(age, { min: 0, max: 200 })) ) return res.status(400).send({ message: 'Form validation has failed.' }) // preprocess gender = (gender === 'M') ? 1 : (gender === 'F') ? 0 : null
0
0
0
24 25 26 27 28 29 30 31 32 33
( (id !== null && typeof id === "number" && id > 0 && Number.isInteger(id)) || // case when id is number (typeof id === "string" && validator.isInt(id, { min: 1 })) ) // case when id is a string ) ) { throw httpError(400, "Invalid input.");
0
0
0
+ 8 other calls in file
validator.escape is the most popular function in validator (548 examples)