How to use the toFloat function from validator
Find comprehensive JavaScript validator.toFloat code examples handpicked from public code repositorys.
GitHub: racker/node-swiz
1620 1621 1622 1623 1624 1625 1626 1627 1628 1629
*/ Chain.prototype.toFloat = function() { this._pushValidator({ name: 'toFloat', func: function(value, baton, callback) { callback(null, check.toFloat(value)); }, help: null }); return this;
11
96
0
3 4 5 6 7 8 9 10 11 12
const moment = require('moment-timezone'); const { ApiError } = require('./better-ctx-throw'); validator.extend('min', (str, min) => validator.toFloat(str) >= min); validator.extend('max', (str, max) => validator.toFloat(str) <= max); validator.extend('gt', (val, compare) => val > compare); validator.extend('gte', (val, compare) => val >= compare);
5
7
2
+ 11 other calls in file
10 11 12 13 14 15 16 17 18 19
switch (type) { case 'number': // noinspection JSUnresolvedFunction result = validator.toFloat(value); break; case 'date': // noinspection JSUnresolvedFunction,JSValidateTypes
1
13
0
GitHub: bevacqua/infer
160 161 162 163 164 165 166 167 168 169
validator.isFloat = function (str) { return str !== '' && float.test(str); }; validator.isDivisibleBy = function (str, num) { return validator.toFloat(str) % validator.toInt(num) === 0; }; validator.isNull = function (str) { return str.length === 0;
2
3
4
34 35 36 37 38 39 40 41 42 43
} if (sanitization.toInt) { sanitizefield = Validator.toInt(sanitizefield); } if (sanitization.toFloat) { sanitizefield = Validator.toFloat(sanitizefield); } if (sanitization.toDate) { sanitizefield = Validator.toDate(sanitizefield); }
0
3
0
GitHub: genx-tech/gx-data
16 17 18 19 20 21 22 23 24 25 26 27 28
exports.toInt = (value, radix) => _.isInteger(value) ? value : parseInt(value, radix); exports.toFloat = (value) => _.isFinite(value) ? value : validator.toFloat(value); exports.jsonToBase64 = (obj) => Buffer.from(JSON.stringify(obj)).toString('base64');
2
2
0
221 222 223 224 225 226 227 228 229 230
} if (sanitization.toDate) { req.body[field] = Validator.toDate(req.body[field]); } if (sanitization.toFloat) { req.body[field] = Validator.toFloat(req.body[field]); } if (sanitization.toInt) { req.body[field] = Validator.toInt(req.body[field]); }
0
0
0
+ 11 other calls in file
GitHub: SubinY/koa-seed
320 321 322 323 324 325 326 327 328 329
this.parsedValue = value; return validator1.isInt(String(value), ...this.options); } case 'isFloat': if (typeof value === 'string') { this.parsedValue = validator1.toFloat(value); return validator1.isFloat(value, ...this.options); } else { this.parsedValue = value; return validator1.isFloat(String(value), ...this.options);
0
0
0
+ 3 other calls in file
88 89 90 91 92 93 94 95 96 97
/** * 字符串转float * @param input 输入字符串 */ toFloat(input) { return validator1.toFloat(input); } /** * 字符串转boolean
0
0
0
405 406 407 408 409 410 411 412 413 414
}, 'int': { converter: (val) => _.isString(val) ? V.toInt(val) : parseInt(val) }, 'float': { converter: (val) => _.isString(val) ? V.toFloat(val) : parseFloat(val) }, 'trim': { converter: V.trim },
0
0
0
validator.escape is the most popular function in validator (548 examples)