How to use the isNumeric function from validator

Find comprehensive JavaScript validator.isNumeric code examples handpicked from public code repositorys.

243
244
245
246
247
248
249
250
251
252
case 'phone':
  isValid = validator.isMobilePhone(stringValue, this.locale || 'en-US');
  break;

case 'number':
  isValid = validator.isNumeric(stringValue);
  break;
}

return isValid;
fork icon0
star icon2
watch icon1

+ 31 other calls in file

56
57
58
59
60
61
62
63
64
65
  }
  return true;
},
isNumeric: function(rule, value) {
  if (rule) {
    return validator.isNumeric(value);
  }
  return true;
},
isAlphanumeric: function(rule, value) {
fork icon0
star icon2
watch icon2

+ 5 other calls in file

200
201
202
203
204
205
206
207
208
209

validations.isNumeric = function isNumeric(paramName, customMessage) {
  return checkParam(
    paramName,
    customMessage || message(paramName, 'should be a number'),
    validator.isNumeric
  );
}

validations.isURL = function isURL(paramName, options, customMessage) {
fork icon9
star icon0
watch icon1

77
78
79
80
81
82
83
84
85
86
87
88
89
90
91


const validFloat = url => validator.isFloat(url);


const validInt = url => validator.isInt(url);


const validNumber = url => validator.isNumeric(url);


const validOctal = url => validator.isOctal(url);


const validHexa = url => validator.isHexadecimal(url) || validator.isHexColor(url);
fork icon5
star icon63
watch icon0

11
12
13
14
15
16
17
18
19
20
exports.isNullOrUndefined = function (value) {
  return !value
}

exports.isNumeric = function (value) {
  return validator.isNumeric(value) || validator.isDecimal(value)
}

exports.isCurrency = function (value) {
  return validator.isCurrency(value)
fork icon2
star icon5
watch icon35

15
16
17
18
19
20
21
22
23
24
25
  return fields.every(includesSortingSuffix);
};


const constraints = [
  {  field: 'c',  validator: (string) => isJSON(string) },
  {  field: 'l',  validator: (string) => isNumeric(string) && (string >= 1) },
  {  field: 'p',  validator: (string) => isNumeric(string) && (string >= 1) },
  {  field: 's',  validator: (string) => isInAgreementWithConvention(string) },
].map(constraint => ({ ...constraint, ...PAGINATION_ERROR_QUERY_PARAMETER_INVALID }));

fork icon0
star icon1
watch icon0

+ 5 other calls in file

51
52
53
54
55
56
57
58
59
60
    bellStyle = req.body.bellStyle;

if (req.body.readyTimeout && validator.isInt(`${req.body.readyTimeout}`, {min: 1, max: 300000}))
    readyTimeout = req.body.readyTimeout;

if (req.body.fontSize && validator.isNumeric(`${req.body.fontSize}`))
    fontSize = req.body.fontSize;

if (req.body.fontFamily)
    fontFamily = req.body.fontFamily;
fork icon0
star icon0
watch icon0

+ 5 other calls in file

367
368
369
370
371
372
373
374
375
376
  duplicate_references = duplicate_references.map((o) => o._id);
}

const form_data = {
  ...(advance_search[seq_key] &&
    validator.isNumeric(advance_search[seq_key]) && {
      [seq_key]: parseInt(advance_search[seq_key], 10),
    }),

  ...(advance_search.period_covered &&
fork icon0
star icon0
watch icon0

275
276
277
278
279
280
281
282
283
284
  method: 'isNumeric',
  message: 'string contains only numbers (may contain +, -, or . symbol)'
},
// check if the string contains only numbers, no other symbols  (e.g. +, -, or .).
'numericonly': {
  method: (val) => V.isNumeric(val, {no_symbols: true}),
  message: 'string contains only numbers (0-9)'
},
'number': {
  method: 'isNumeric',
fork icon0
star icon0
watch icon0