How to use the isFQDN function from validator

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

84
85
86
87
88
89
90
91
92
93
},
port: function(x) {
  check(x, "within range 0 - 65535", validator.isInt(x, 0, 65535));
},
fqdn: function(x) {
  check(x, "a domain name", validator.isFQDN(x));
},
url: function(x) {
  check(x, "a URL", validator.isURL(x));
},
fork icon2
star icon4
watch icon0

45
46
47
48
49
50
51
52
53
54
check('game')
  .isIn(allowedGameTypes)
  .withMessage('Game is not supported.'),
check('ip')
  .custom((value, { req }) => {
    if (validator.isIP(value) || validator.isFQDN(value)) {
      return true;
    }
    throw new Error('Invalid IP address or hostname.');
  })
fork icon0
star icon3
watch icon0

+ 2 other calls in file

227
228
229
230
231
232
233
234
235
236
case 'email':
  isValid = validator.isEmail(stringValue);
  break;

case 'fqdn':
  isValid = validator.isFQDN(stringValue);
  break;

case 'float':
  isValid = validator.isFloat(stringValue);
fork icon0
star icon2
watch icon1

+ 31 other calls in file

159
160
161
162
163
164
165
166
167
168
);

if (
  (ignoreCurrency && validator.isCurrency(word)) ||
  (ignoreEmail && validator.isEmail(word)) ||
  (ignoreFqdn && validator.isFQDN(word)) ||
  (ignoreUrl && validator.isURL(word)) ||
  (ignoreUnits && unitFilter.test(word))
) {
  parent.children[index] = {
fork icon0
star icon2
watch icon2

38
39
40
41
42
43
44
45
46
47
  }
  return true;
},
isFQDN: function(rule, value) {
  if (rule) {
    return validator.isFQDN(value);
  }
  return true;
},
isIP: function(rule, value) {
fork icon0
star icon2
watch icon2

+ 5 other calls in file

53
54
55
56
57
58
59
60
61
62
},
// isFQDN(str [, options]) - check if the string is a fully qualified domain name
// (e.g. domain.com). options is an object which defaults to
// { require_tld: true, allow_underscores: false, allow_trailing_dot: false }.
isFQDN: function (str, options) {
  return validator.isFQDN(str, typeof options === 'object' ? options : undefined);
},
// isFloat(str [, options]) - check if the string is a float.
// options is an object which can contain the keys min and/or max to validate
// the float is within boundaries (e.g. { min: 7.22, max: 9.55 }).
fork icon0
star icon1
watch icon3

+ 17 other calls in file

63
64
65
66
67
68
69
70
71

response = await prompts({
    type: 'text',
    name: 'value',
    message: 'Your domain name',
    validate: (e) => isFQDN(e) || `Must be a valid domain`,
});

domain = response.value;
fork icon0
star icon0
watch icon0