How to use the isHexadecimal function from validator

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

81
82
83
84
85
86
87
88
89
90
91
92
93
94
95


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


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


const validHexa = url => validator.isHexadecimal(url) || validator.isHexColor(url);


const validHexadecimal = url => validator.isHexadecimal(url);


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

311
312
313
314
315
316
317
318
319
320
validator.isBase64 = function (str) {
    return base64.test(str);
};

validator.isMongoId = function (str) {
    return validator.isHexadecimal(str) && str.length === 24;
};

validator.ltrim = function (str, chars) {
    var pattern = chars ? new RegExp('^[' + chars + ']+', 'g') : /^\s+/g;
fork icon2
star icon3
watch icon4

74
75
76
77
78
79
80
81
82
83
  }
  return true;
},
isHexadecimal: function(rule, value) {
  if (rule) {
    return validator.isHexadecimal(value);
  }
  return true;
},
isHexColor: function(rule, value) {
fork icon0
star icon2
watch icon2

+ 5 other calls in file

417
418
419
420
421
422
423
424
425
426
app.post('/getPlayers/delete/:uid', authenticate, function (req, res, next) {
  var uid = req.params.uid;
  function fail () {
    sendErr(res, {error: 'Invalid ID or the job is not complete'});
  }
  if (uid.length === 10 && validator.isHexadecimal(uid)) {
    var path = './players/' + uid;
    if (completed[uid]) {
      completed[uid] = false;
      inProgress[uid] = null;
fork icon0
star icon0
watch icon0

50
51
52
53
54
55
56
57
58
}


// Validate hexadecimal number


exports.validateHexNumber = (hexNumber) => {
    return validator.isHexadecimal(hexNumber);
}
fork icon0
star icon0
watch icon0