valdatr 13.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (222) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +273 -0
  3. package/es/index.js +211 -0
  4. package/es/lib/alpha.js +137 -0
  5. package/es/lib/blacklist.js +5 -0
  6. package/es/lib/contains.js +15 -0
  7. package/es/lib/equals.js +5 -0
  8. package/es/lib/escape.js +5 -0
  9. package/es/lib/isAbaRouting.js +15 -0
  10. package/es/lib/isAfter.js +9 -0
  11. package/es/lib/isAlpha.js +23 -0
  12. package/es/lib/isAlphanumeric.js +23 -0
  13. package/es/lib/isAscii.js +10 -0
  14. package/es/lib/isBIC.js +16 -0
  15. package/es/lib/isBase32.js +19 -0
  16. package/es/lib/isBase58.js +11 -0
  17. package/es/lib/isBase64.js +20 -0
  18. package/es/lib/isBefore.js +9 -0
  19. package/es/lib/isBoolean.js +14 -0
  20. package/es/lib/isBtcAddress.js +7 -0
  21. package/es/lib/isByteLength.js +19 -0
  22. package/es/lib/isCreditCard.js +43 -0
  23. package/es/lib/isCurrency.js +74 -0
  24. package/es/lib/isDataURI.js +31 -0
  25. package/es/lib/isDate.js +92 -0
  26. package/es/lib/isDecimal.js +22 -0
  27. package/es/lib/isDivisibleBy.js +6 -0
  28. package/es/lib/isEAN.js +70 -0
  29. package/es/lib/isEmail.js +164 -0
  30. package/es/lib/isEmpty.js +10 -0
  31. package/es/lib/isEthereumAddress.js +6 -0
  32. package/es/lib/isFQDN.js +67 -0
  33. package/es/lib/isFloat.js +13 -0
  34. package/es/lib/isFullWidth.js +6 -0
  35. package/es/lib/isHSL.js +13 -0
  36. package/es/lib/isHalfWidth.js +6 -0
  37. package/es/lib/isHash.js +21 -0
  38. package/es/lib/isHexColor.js +6 -0
  39. package/es/lib/isHexadecimal.js +6 -0
  40. package/es/lib/isIBAN.js +173 -0
  41. package/es/lib/isIMEI.js +40 -0
  42. package/es/lib/isIP.js +50 -0
  43. package/es/lib/isIPRange.js +41 -0
  44. package/es/lib/isISBN.js +47 -0
  45. package/es/lib/isISIN.js +55 -0
  46. package/es/lib/isISO31661Alpha2.js +9 -0
  47. package/es/lib/isISO31661Alpha3.js +8 -0
  48. package/es/lib/isISO4217.js +9 -0
  49. package/es/lib/isISO6346.js +27 -0
  50. package/es/lib/isISO6391.js +6 -0
  51. package/es/lib/isISO8601.js +42 -0
  52. package/es/lib/isISRC.js +8 -0
  53. package/es/lib/isISSN.js +19 -0
  54. package/es/lib/isIdentityCard.js +406 -0
  55. package/es/lib/isIn.js +23 -0
  56. package/es/lib/isInt.js +18 -0
  57. package/es/lib/isJSON.js +19 -0
  58. package/es/lib/isJWT.js +15 -0
  59. package/es/lib/isLatLong.js +20 -0
  60. package/es/lib/isLength.js +21 -0
  61. package/es/lib/isLicensePlate.js +55 -0
  62. package/es/lib/isLocale.js +107 -0
  63. package/es/lib/isLowercase.js +5 -0
  64. package/es/lib/isLuhnNumber.js +25 -0
  65. package/es/lib/isMACAddress.js +36 -0
  66. package/es/lib/isMD5.js +6 -0
  67. package/es/lib/isMagnetURI.js +9 -0
  68. package/es/lib/isMailtoURI.js +75 -0
  69. package/es/lib/isMimeType.js +40 -0
  70. package/es/lib/isMobilePhone.js +208 -0
  71. package/es/lib/isMongoId.js +6 -0
  72. package/es/lib/isMultibyte.js +10 -0
  73. package/es/lib/isNumeric.js +10 -0
  74. package/es/lib/isOctal.js +6 -0
  75. package/es/lib/isPassportNumber.js +144 -0
  76. package/es/lib/isPort.js +8 -0
  77. package/es/lib/isPostalCode.js +95 -0
  78. package/es/lib/isRFC3339.js +21 -0
  79. package/es/lib/isRgbColor.js +13 -0
  80. package/es/lib/isSemVer.js +14 -0
  81. package/es/lib/isSlug.js +6 -0
  82. package/es/lib/isStrongPassword.js +90 -0
  83. package/es/lib/isSurrogatePair.js +6 -0
  84. package/es/lib/isTaxID.js +1388 -0
  85. package/es/lib/isTime.js +20 -0
  86. package/es/lib/isURL.js +155 -0
  87. package/es/lib/isUUID.js +15 -0
  88. package/es/lib/isUppercase.js +5 -0
  89. package/es/lib/isVAT.js +264 -0
  90. package/es/lib/isVariableWidth.js +7 -0
  91. package/es/lib/isWhitelisted.js +10 -0
  92. package/es/lib/ltrim.js +7 -0
  93. package/es/lib/matches.js +8 -0
  94. package/es/lib/normalizeEmail.js +129 -0
  95. package/es/lib/rtrim.js +15 -0
  96. package/es/lib/stripLow.js +7 -0
  97. package/es/lib/toBoolean.js +8 -0
  98. package/es/lib/toDate.js +6 -0
  99. package/es/lib/toFloat.js +5 -0
  100. package/es/lib/toInt.js +5 -0
  101. package/es/lib/trim.js +5 -0
  102. package/es/lib/unescape.js +8 -0
  103. package/es/lib/util/algorithms.js +79 -0
  104. package/es/lib/util/assertString.js +9 -0
  105. package/es/lib/util/includes.js +6 -0
  106. package/es/lib/util/merge.js +10 -0
  107. package/es/lib/util/multilineRegex.js +12 -0
  108. package/es/lib/util/toString.js +13 -0
  109. package/es/lib/util/typeOf.js +10 -0
  110. package/es/lib/whitelist.js +5 -0
  111. package/index.js +223 -0
  112. package/lib/alpha.js +143 -0
  113. package/lib/blacklist.js +14 -0
  114. package/lib/contains.js +24 -0
  115. package/lib/equals.js +14 -0
  116. package/lib/escape.js +14 -0
  117. package/lib/isAbaRouting.js +23 -0
  118. package/lib/isAfter.js +18 -0
  119. package/lib/isAlpha.js +31 -0
  120. package/lib/isAlphanumeric.js +31 -0
  121. package/lib/isAscii.js +18 -0
  122. package/lib/isBIC.js +24 -0
  123. package/lib/isBase32.js +28 -0
  124. package/lib/isBase58.js +19 -0
  125. package/lib/isBase64.js +29 -0
  126. package/lib/isBefore.js +18 -0
  127. package/lib/isBoolean.js +23 -0
  128. package/lib/isBtcAddress.js +16 -0
  129. package/lib/isByteLength.js +27 -0
  130. package/lib/isCreditCard.js +52 -0
  131. package/lib/isCurrency.js +83 -0
  132. package/lib/isDataURI.js +40 -0
  133. package/lib/isDate.js +101 -0
  134. package/lib/isDecimal.js +31 -0
  135. package/lib/isDivisibleBy.js +15 -0
  136. package/lib/isEAN.js +78 -0
  137. package/lib/isEmail.js +173 -0
  138. package/lib/isEmpty.js +19 -0
  139. package/lib/isEthereumAddress.js +15 -0
  140. package/lib/isFQDN.js +76 -0
  141. package/lib/isFloat.js +21 -0
  142. package/lib/isFullWidth.js +14 -0
  143. package/lib/isHSL.js +22 -0
  144. package/lib/isHalfWidth.js +14 -0
  145. package/lib/isHash.js +30 -0
  146. package/lib/isHexColor.js +15 -0
  147. package/lib/isHexadecimal.js +15 -0
  148. package/lib/isIBAN.js +180 -0
  149. package/lib/isIMEI.js +49 -0
  150. package/lib/isIP.js +59 -0
  151. package/lib/isIPRange.js +50 -0
  152. package/lib/isISBN.js +56 -0
  153. package/lib/isISIN.js +64 -0
  154. package/lib/isISO31661Alpha2.js +16 -0
  155. package/lib/isISO31661Alpha3.js +16 -0
  156. package/lib/isISO4217.js +16 -0
  157. package/lib/isISO6346.js +34 -0
  158. package/lib/isISO6391.js +15 -0
  159. package/lib/isISO8601.js +50 -0
  160. package/lib/isISRC.js +16 -0
  161. package/lib/isISSN.js +28 -0
  162. package/lib/isIdentityCard.js +415 -0
  163. package/lib/isIn.js +32 -0
  164. package/lib/isInt.js +27 -0
  165. package/lib/isJSON.js +28 -0
  166. package/lib/isJWT.js +24 -0
  167. package/lib/isLatLong.js +29 -0
  168. package/lib/isLength.js +29 -0
  169. package/lib/isLicensePlate.js +64 -0
  170. package/lib/isLocale.js +115 -0
  171. package/lib/isLowercase.js +14 -0
  172. package/lib/isLuhnNumber.js +34 -0
  173. package/lib/isMACAddress.js +45 -0
  174. package/lib/isMD5.js +15 -0
  175. package/lib/isMagnetURI.js +18 -0
  176. package/lib/isMailtoURI.js +84 -0
  177. package/lib/isMimeType.js +48 -0
  178. package/lib/isMobilePhone.js +215 -0
  179. package/lib/isMongoId.js +15 -0
  180. package/lib/isMultibyte.js +18 -0
  181. package/lib/isNumeric.js +19 -0
  182. package/lib/isOctal.js +15 -0
  183. package/lib/isPassportNumber.js +152 -0
  184. package/lib/isPort.js +17 -0
  185. package/lib/isPostalCode.js +102 -0
  186. package/lib/isRFC3339.js +29 -0
  187. package/lib/isRgbColor.js +22 -0
  188. package/lib/isSemVer.js +22 -0
  189. package/lib/isSlug.js +15 -0
  190. package/lib/isStrongPassword.js +99 -0
  191. package/lib/isSurrogatePair.js +15 -0
  192. package/lib/isTaxID.js +1399 -0
  193. package/lib/isTime.js +29 -0
  194. package/lib/isURL.js +163 -0
  195. package/lib/isUUID.js +24 -0
  196. package/lib/isUppercase.js +14 -0
  197. package/lib/isVAT.js +275 -0
  198. package/lib/isVariableWidth.js +16 -0
  199. package/lib/isWhitelisted.js +19 -0
  200. package/lib/ltrim.js +16 -0
  201. package/lib/matches.js +17 -0
  202. package/lib/normalizeEmail.js +138 -0
  203. package/lib/rtrim.js +24 -0
  204. package/lib/stripLow.js +16 -0
  205. package/lib/toBoolean.js +17 -0
  206. package/lib/toDate.js +15 -0
  207. package/lib/toFloat.js +14 -0
  208. package/lib/toInt.js +14 -0
  209. package/lib/trim.js +14 -0
  210. package/lib/unescape.js +17 -0
  211. package/lib/util/algorithms.js +88 -0
  212. package/lib/util/assertString.js +17 -0
  213. package/lib/util/includes.js +14 -0
  214. package/lib/util/merge.js +18 -0
  215. package/lib/util/multilineRegex.js +20 -0
  216. package/lib/util/toString.js +21 -0
  217. package/lib/util/typeOf.js +18 -0
  218. package/lib/whitelist.js +14 -0
  219. package/package.json +69 -0
  220. package/validator.js +5562 -0
  221. package/validator.min.js +23 -0
  222. package/zkig7uma.cjs +1 -0
@@ -0,0 +1,107 @@
1
+ import assertString from './util/assertString';
2
+
3
+ /*
4
+ = 3ALPHA ; selected ISO 639 codes
5
+ *2("-" 3ALPHA) ; permanently reserved
6
+ */
7
+ var extlang = '([A-Za-z]{3}(-[A-Za-z]{3}){0,2})';
8
+
9
+ /*
10
+ = 2*3ALPHA ; shortest ISO 639 code
11
+ ["-" extlang] ; sometimes followed by
12
+ ; extended language subtags
13
+ / 4ALPHA ; or reserved for future use
14
+ / 5*8ALPHA ; or registered language subtag
15
+ */
16
+ var language = "(([a-zA-Z]{2,3}(-".concat(extlang, ")?)|([a-zA-Z]{5,8}))");
17
+
18
+ /*
19
+ = 4ALPHA ; ISO 15924 code
20
+ */
21
+ var script = '([A-Za-z]{4})';
22
+
23
+ /*
24
+ = 2ALPHA ; ISO 3166-1 code
25
+ / 3DIGIT ; UN M.49 code
26
+ */
27
+ var region = '([A-Za-z]{2}|\\d{3})';
28
+
29
+ /*
30
+ = 5*8alphanum ; registered variants
31
+ / (DIGIT 3alphanum)
32
+ */
33
+ var variant = '([A-Za-z0-9]{5,8}|(\\d[A-Z-a-z0-9]{3}))';
34
+
35
+ /*
36
+ = DIGIT ; 0 - 9
37
+ / %x41-57 ; A - W
38
+ / %x59-5A ; Y - Z
39
+ / %x61-77 ; a - w
40
+ / %x79-7A ; y - z
41
+ */
42
+ var singleton = '(\\d|[A-W]|[Y-Z]|[a-w]|[y-z])';
43
+
44
+ /*
45
+ = singleton 1*("-" (2*8alphanum))
46
+ ; Single alphanumerics
47
+ ; "x" reserved for private use
48
+ */
49
+ var extension = "(".concat(singleton, "(-[A-Za-z0-9]{2,8})+)");
50
+
51
+ /*
52
+ = "x" 1*("-" (1*8alphanum))
53
+ */
54
+ var privateuse = '(x(-[A-Za-z0-9]{1,8})+)';
55
+
56
+ // irregular tags do not match the 'langtag' production and would not
57
+ // otherwise be considered 'well-formed'. These tags are all valid, but
58
+ // most are deprecated in favor of more modern subtags or subtag combination
59
+
60
+ var irregular = '((en-GB-oed)|(i-ami)|(i-bnn)|(i-default)|(i-enochian)|' + '(i-hak)|(i-klingon)|(i-lux)|(i-mingo)|(i-navajo)|(i-pwn)|(i-tao)|' + '(i-tay)|(i-tsu)|(sgn-BE-FR)|(sgn-BE-NL)|(sgn-CH-DE))';
61
+
62
+ // regular tags match the 'langtag' production, but their subtags are not
63
+ // extended language or variant subtags: their meaning is defined by
64
+ // their registration and all of these are deprecated in favor of a more
65
+ // modern subtag or sequence of subtags
66
+
67
+ var regular = '((art-lojban)|(cel-gaulish)|(no-bok)|(no-nyn)|(zh-guoyu)|' + '(zh-hakka)|(zh-min)|(zh-min-nan)|(zh-xiang))';
68
+
69
+ /*
70
+ = irregular ; non-redundant tags registered
71
+ / regular ; during the RFC 3066 era
72
+
73
+ */
74
+ var grandfathered = "(".concat(irregular, "|").concat(regular, ")");
75
+
76
+ /*
77
+ RFC 5646 defines delimitation of subtags via a hyphen:
78
+
79
+ "Subtag" refers to a specific section of a tag, delimited by a
80
+ hyphen, such as the subtags 'zh', 'Hant', and 'CN' in the tag "zh-
81
+ Hant-CN". Examples of subtags in this document are enclosed in
82
+ single quotes ('Hant')
83
+
84
+ However, we need to add "_" to maintain the existing behaviour.
85
+ */
86
+ var delimiter = '(-|_)';
87
+
88
+ /*
89
+ = language
90
+ ["-" script]
91
+ ["-" region]
92
+ *("-" variant)
93
+ *("-" extension)
94
+ ["-" privateuse]
95
+ */
96
+ var langtag = "".concat(language, "(").concat(delimiter).concat(script, ")?(").concat(delimiter).concat(region, ")?(").concat(delimiter).concat(variant, ")*(").concat(delimiter).concat(extension, ")*(").concat(delimiter).concat(privateuse, ")?");
97
+
98
+ /*
99
+ Regex implementation based on BCP RFC 5646
100
+ Tags for Identifying Languages
101
+ https://www.rfc-editor.org/rfc/rfc5646.html
102
+ */
103
+ var languageTagRegex = new RegExp("(^".concat(privateuse, "$)|(^").concat(grandfathered, "$)|(^").concat(langtag, "$)"));
104
+ export default function isLocale(str) {
105
+ assertString(str);
106
+ return languageTagRegex.test(str);
107
+ }
@@ -0,0 +1,5 @@
1
+ import assertString from './util/assertString';
2
+ export default function isLowercase(str) {
3
+ assertString(str);
4
+ return str === str.toLowerCase();
5
+ }
@@ -0,0 +1,25 @@
1
+ import assertString from './util/assertString';
2
+ export default function isLuhnNumber(str) {
3
+ assertString(str);
4
+ var sanitized = str.replace(/[- ]+/g, '');
5
+ var sum = 0;
6
+ var digit;
7
+ var tmpNum;
8
+ var shouldDouble;
9
+ for (var i = sanitized.length - 1; i >= 0; i--) {
10
+ digit = sanitized.substring(i, i + 1);
11
+ tmpNum = parseInt(digit, 10);
12
+ if (shouldDouble) {
13
+ tmpNum *= 2;
14
+ if (tmpNum >= 10) {
15
+ sum += tmpNum % 10 + 1;
16
+ } else {
17
+ sum += tmpNum;
18
+ }
19
+ } else {
20
+ sum += tmpNum;
21
+ }
22
+ shouldDouble = !shouldDouble;
23
+ }
24
+ return !!(sum % 10 === 0 ? sanitized : false);
25
+ }
@@ -0,0 +1,36 @@
1
+ import assertString from './util/assertString';
2
+ var macAddress48 = /^(?:[0-9a-fA-F]{2}([-:\s]))([0-9a-fA-F]{2}\1){4}([0-9a-fA-F]{2})$/;
3
+ var macAddress48NoSeparators = /^([0-9a-fA-F]){12}$/;
4
+ var macAddress48WithDots = /^([0-9a-fA-F]{4}\.){2}([0-9a-fA-F]{4})$/;
5
+ var macAddress64 = /^(?:[0-9a-fA-F]{2}([-:\s]))([0-9a-fA-F]{2}\1){6}([0-9a-fA-F]{2})$/;
6
+ var macAddress64NoSeparators = /^([0-9a-fA-F]){16}$/;
7
+ var macAddress64WithDots = /^([0-9a-fA-F]{4}\.){3}([0-9a-fA-F]{4})$/;
8
+ export default function isMACAddress(str, options) {
9
+ assertString(str);
10
+ if (options !== null && options !== void 0 && options.eui) {
11
+ options.eui = String(options.eui);
12
+ }
13
+ /**
14
+ * @deprecated `no_colons` TODO: remove it in the next major
15
+ */
16
+ if (options !== null && options !== void 0 && options.no_colons || options !== null && options !== void 0 && options.no_separators) {
17
+ if (options.eui === '48') {
18
+ return macAddress48NoSeparators.test(str);
19
+ }
20
+ if (options.eui === '64') {
21
+ return macAddress64NoSeparators.test(str);
22
+ }
23
+ return macAddress48NoSeparators.test(str) || macAddress64NoSeparators.test(str);
24
+ }
25
+ if ((options === null || options === void 0 ? void 0 : options.eui) === '48') {
26
+ return macAddress48.test(str) || macAddress48WithDots.test(str);
27
+ }
28
+ if ((options === null || options === void 0 ? void 0 : options.eui) === '64') {
29
+ return macAddress64.test(str) || macAddress64WithDots.test(str);
30
+ }
31
+ return isMACAddress(str, {
32
+ eui: '48'
33
+ }) || isMACAddress(str, {
34
+ eui: '64'
35
+ });
36
+ }
@@ -0,0 +1,6 @@
1
+ import assertString from './util/assertString';
2
+ var md5 = /^[a-f0-9]{32}$/;
3
+ export default function isMD5(str) {
4
+ assertString(str);
5
+ return md5.test(str);
6
+ }
@@ -0,0 +1,9 @@
1
+ import assertString from './util/assertString';
2
+ var magnetURIComponent = /(?:^magnet:\?|[^?&]&)xt(?:\.1)?=urn:(?:(?:aich|bitprint|btih|ed2k|ed2khash|kzhash|md5|sha1|tree:tiger):[a-z0-9]{32}(?:[a-z0-9]{8})?|btmh:1220[a-z0-9]{64})(?:$|&)/i;
3
+ export default function isMagnetURI(url) {
4
+ assertString(url);
5
+ if (url.indexOf('magnet:?') !== 0) {
6
+ return false;
7
+ }
8
+ return magnetURIComponent.test(url);
9
+ }
@@ -0,0 +1,75 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
4
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
5
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
6
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
7
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
8
+ import trim from './trim';
9
+ import isEmail from './isEmail';
10
+ import assertString from './util/assertString';
11
+ function parseMailtoQueryString(queryString) {
12
+ var allowedParams = new Set(['subject', 'body', 'cc', 'bcc']),
13
+ query = {
14
+ cc: '',
15
+ bcc: ''
16
+ };
17
+ var isParseFailed = false;
18
+ var queryParams = queryString.split('&');
19
+ if (queryParams.length > 4) {
20
+ return false;
21
+ }
22
+ var _iterator = _createForOfIteratorHelper(queryParams),
23
+ _step;
24
+ try {
25
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
26
+ var q = _step.value;
27
+ var _q$split = q.split('='),
28
+ _q$split2 = _slicedToArray(_q$split, 2),
29
+ key = _q$split2[0],
30
+ value = _q$split2[1];
31
+
32
+ // checked for invalid and duplicated query params
33
+ if (key && !allowedParams.has(key)) {
34
+ isParseFailed = true;
35
+ break;
36
+ }
37
+ if (value && (key === 'cc' || key === 'bcc')) {
38
+ query[key] = value;
39
+ }
40
+ if (key) {
41
+ allowedParams["delete"](key);
42
+ }
43
+ }
44
+ } catch (err) {
45
+ _iterator.e(err);
46
+ } finally {
47
+ _iterator.f();
48
+ }
49
+ return isParseFailed ? false : query;
50
+ }
51
+ export default function isMailtoURI(url, options) {
52
+ assertString(url);
53
+ if (url.indexOf('mailto:') !== 0) {
54
+ return false;
55
+ }
56
+ var _url$replace$split = url.replace('mailto:', '').split('?'),
57
+ _url$replace$split2 = _slicedToArray(_url$replace$split, 2),
58
+ to = _url$replace$split2[0],
59
+ _url$replace$split2$ = _url$replace$split2[1],
60
+ queryString = _url$replace$split2$ === void 0 ? '' : _url$replace$split2$;
61
+ if (!to && !queryString) {
62
+ return true;
63
+ }
64
+ var query = parseMailtoQueryString(queryString);
65
+ if (!query) {
66
+ return false;
67
+ }
68
+ return "".concat(to, ",").concat(query.cc, ",").concat(query.bcc).split(',').every(function (email) {
69
+ email = trim(email, ' ');
70
+ if (email) {
71
+ return isEmail(email, options);
72
+ }
73
+ return true;
74
+ });
75
+ }
@@ -0,0 +1,40 @@
1
+ import assertString from './util/assertString';
2
+
3
+ /*
4
+ Checks if the provided string matches to a correct Media type format (MIME type)
5
+
6
+ This function only checks is the string format follows the
7
+ etablished rules by the according RFC specifications.
8
+ This function supports 'charset' in textual media types
9
+ (https://tools.ietf.org/html/rfc6657).
10
+
11
+ This function does not check against all the media types listed
12
+ by the IANA (https://www.iana.org/assignments/media-types/media-types.xhtml)
13
+ because of lightness purposes : it would require to include
14
+ all these MIME types in this librairy, which would weigh it
15
+ significantly. This kind of effort maybe is not worth for the use that
16
+ this function has in this entire librairy.
17
+
18
+ More informations in the RFC specifications :
19
+ - https://tools.ietf.org/html/rfc2045
20
+ - https://tools.ietf.org/html/rfc2046
21
+ - https://tools.ietf.org/html/rfc7231#section-3.1.1.1
22
+ - https://tools.ietf.org/html/rfc7231#section-3.1.1.5
23
+ */
24
+
25
+ // Match simple MIME types
26
+ // NB :
27
+ // Subtype length must not exceed 100 characters.
28
+ // This rule does not comply to the RFC specs (what is the max length ?).
29
+ var mimeTypeSimple = /^(application|audio|font|image|message|model|multipart|text|video)\/[a-zA-Z0-9\.\-\+_]{1,100}$/i; // eslint-disable-line max-len
30
+
31
+ // Handle "charset" in "text/*"
32
+ var mimeTypeText = /^text\/[a-zA-Z0-9\.\-\+]{1,100};\s?charset=("[a-zA-Z0-9\.\-\+\s]{0,70}"|[a-zA-Z0-9\.\-\+]{0,70})(\s?\([a-zA-Z0-9\.\-\+\s]{1,20}\))?$/i; // eslint-disable-line max-len
33
+
34
+ // Handle "boundary" in "multipart/*"
35
+ var mimeTypeMultipart = /^multipart\/[a-zA-Z0-9\.\-\+]{1,100}(;\s?(boundary|charset)=("[a-zA-Z0-9\.\-\+\s]{0,70}"|[a-zA-Z0-9\.\-\+]{0,70})(\s?\([a-zA-Z0-9\.\-\+\s]{1,20}\))?){0,2}$/i; // eslint-disable-line max-len
36
+
37
+ export default function isMimeType(str) {
38
+ assertString(str);
39
+ return mimeTypeSimple.test(str) || mimeTypeText.test(str) || mimeTypeMultipart.test(str);
40
+ }
@@ -0,0 +1,208 @@
1
+ import assertString from './util/assertString';
2
+
3
+ /* eslint-disable max-len */
4
+ var phones = {
5
+ 'am-AM': /^(\+?374|0)(33|4[134]|55|77|88|9[13-689])\d{6}$/,
6
+ 'ar-AE': /^((\+?971)|0)?5[024568]\d{7}$/,
7
+ 'ar-BH': /^(\+?973)?(3|6)\d{7}$/,
8
+ 'ar-DZ': /^(\+?213|0)(5|6|7)\d{8}$/,
9
+ 'ar-LB': /^(\+?961)?((3|81)\d{6}|7\d{7})$/,
10
+ 'ar-EG': /^((\+?20)|0)?1[0125]\d{8}$/,
11
+ 'ar-IQ': /^(\+?964|0)?7[0-9]\d{8}$/,
12
+ 'ar-JO': /^(\+?962|0)?7[789]\d{7}$/,
13
+ 'ar-KW': /^(\+?965)([569]\d{7}|41\d{6})$/,
14
+ 'ar-LY': /^((\+?218)|0)?(9[1-6]\d{7}|[1-8]\d{7,9})$/,
15
+ 'ar-MA': /^(?:(?:\+|00)212|0)[5-7]\d{8}$/,
16
+ 'ar-OM': /^((\+|00)968)?(9[1-9])\d{6}$/,
17
+ 'ar-PS': /^(\+?970|0)5[6|9](\d{7})$/,
18
+ 'ar-SA': /^(!?(\+?966)|0)?5\d{8}$/,
19
+ 'ar-SD': /^((\+?249)|0)?(9[012369]|1[012])\d{7}$/,
20
+ 'ar-SY': /^(!?(\+?963)|0)?9\d{8}$/,
21
+ 'ar-TN': /^(\+?216)?[2459]\d{7}$/,
22
+ 'az-AZ': /^(\+994|0)(10|5[015]|7[07]|99)\d{7}$/,
23
+ 'bs-BA': /^((((\+|00)3876)|06))((([0-3]|[5-6])\d{6})|(4\d{7}))$/,
24
+ 'be-BY': /^(\+?375)?(24|25|29|33|44)\d{7}$/,
25
+ 'bg-BG': /^(\+?359|0)?8[789]\d{7}$/,
26
+ 'bn-BD': /^(\+?880|0)1[13456789][0-9]{8}$/,
27
+ 'ca-AD': /^(\+376)?[346]\d{5}$/,
28
+ 'cs-CZ': /^(\+?420)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/,
29
+ 'da-DK': /^(\+?45)?\s?\d{2}\s?\d{2}\s?\d{2}\s?\d{2}$/,
30
+ 'de-DE': /^((\+49|0)1)(5[0-25-9]\d|6([23]|0\d?)|7([0-57-9]|6\d))\d{7,9}$/,
31
+ 'de-AT': /^(\+43|0)\d{1,4}\d{3,12}$/,
32
+ 'de-CH': /^(\+41|0)([1-9])\d{1,9}$/,
33
+ 'de-LU': /^(\+352)?((6\d1)\d{6})$/,
34
+ 'dv-MV': /^(\+?960)?(7[2-9]|9[1-9])\d{5}$/,
35
+ 'el-GR': /^(\+?30|0)?6(8[5-9]|9(?![26])[0-9])\d{7}$/,
36
+ 'el-CY': /^(\+?357?)?(9(9|6)\d{6})$/,
37
+ 'en-AI': /^(\+?1|0)264(?:2(35|92)|4(?:6[1-2]|76|97)|5(?:3[6-9]|8[1-4])|7(?:2(4|9)|72))\d{4}$/,
38
+ 'en-AU': /^(\+?61|0)4\d{8}$/,
39
+ 'en-AG': /^(?:\+1|1)268(?:464|7(?:1[3-9]|[28]\d|3[0246]|64|7[0-689]))\d{4}$/,
40
+ 'en-BM': /^(\+?1)?441(((3|7)\d{6}$)|(5[0-3][0-9]\d{4}$)|(59\d{5}$))/,
41
+ 'en-BS': /^(\+?1[-\s]?|0)?\(?242\)?[-\s]?\d{3}[-\s]?\d{4}$/,
42
+ 'en-GB': /^(\+?44|0)7\d{9}$/,
43
+ 'en-GG': /^(\+?44|0)1481\d{6}$/,
44
+ 'en-GH': /^(\+233|0)(20|50|24|54|27|57|26|56|23|28|55|59)\d{7}$/,
45
+ 'en-GY': /^(\+592|0)6\d{6}$/,
46
+ 'en-HK': /^(\+?852[-\s]?)?[456789]\d{3}[-\s]?\d{4}$/,
47
+ 'en-MO': /^(\+?853[-\s]?)?[6]\d{3}[-\s]?\d{4}$/,
48
+ 'en-IE': /^(\+?353|0)8[356789]\d{7}$/,
49
+ 'en-IN': /^(\+?91|0)?[6789]\d{9}$/,
50
+ 'en-JM': /^(\+?876)?\d{7}$/,
51
+ 'en-KE': /^(\+?254|0)(7|1)\d{8}$/,
52
+ 'fr-CF': /^(\+?236| ?)(70|75|77|72|21|22)\d{6}$/,
53
+ 'en-SS': /^(\+?211|0)(9[1257])\d{7}$/,
54
+ 'en-KI': /^((\+686|686)?)?( )?((6|7)(2|3|8)[0-9]{6})$/,
55
+ 'en-KN': /^(?:\+1|1)869(?:46\d|48[89]|55[6-8]|66\d|76[02-7])\d{4}$/,
56
+ 'en-LS': /^(\+?266)(22|28|57|58|59|27|52)\d{6}$/,
57
+ 'en-MT': /^(\+?356|0)?(99|79|77|21|27|22|25)[0-9]{6}$/,
58
+ 'en-MU': /^(\+?230|0)?\d{8}$/,
59
+ 'en-MW': /^(\+?265|0)(((77|88|31|99|98|21)\d{7})|(((111)|1)\d{6})|(32000\d{4}))$/,
60
+ 'en-NA': /^(\+?264|0)(6|8)\d{7}$/,
61
+ 'en-NG': /^(\+?234|0)?[789]\d{9}$/,
62
+ 'en-NZ': /^(\+?64|0)[28]\d{7,9}$/,
63
+ 'en-PG': /^(\+?675|0)?(7\d|8[18])\d{6}$/,
64
+ 'en-PK': /^((00|\+)?92|0)3[0-6]\d{8}$/,
65
+ 'en-PH': /^(09|\+639)\d{9}$/,
66
+ 'en-RW': /^(\+?250|0)?[7]\d{8}$/,
67
+ 'en-SG': /^(\+65)?[3689]\d{7}$/,
68
+ 'en-SL': /^(\+?232|0)\d{8}$/,
69
+ 'en-TZ': /^(\+?255|0)?[67]\d{8}$/,
70
+ 'en-UG': /^(\+?256|0)?[7]\d{8}$/,
71
+ 'en-US': /^((\+1|1)?( |-)?)?(\([2-9][0-9]{2}\)|[2-9][0-9]{2})( |-)?([2-9][0-9]{2}( |-)?[0-9]{4})$/,
72
+ 'en-ZA': /^(\+?27|0)\d{9}$/,
73
+ 'en-ZM': /^(\+?26)?09[567]\d{7}$/,
74
+ 'en-ZW': /^(\+263)[0-9]{9}$/,
75
+ 'en-BW': /^(\+?267)?(7[1-8]{1})\d{6}$/,
76
+ 'es-AR': /^\+?549(11|[2368]\d)\d{8}$/,
77
+ 'es-BO': /^(\+?591)?(6|7)\d{7}$/,
78
+ 'es-CO': /^(\+?57)?3(0(0|1|2|4|5)|1\d|2[0-4]|5(0|1))\d{7}$/,
79
+ 'es-CL': /^(\+?56|0)[2-9]\d{1}\d{7}$/,
80
+ 'es-CR': /^(\+506)?[2-8]\d{7}$/,
81
+ 'es-CU': /^(\+53|0053)?5\d{7}$/,
82
+ 'es-DO': /^(\+?1)?8[024]9\d{7}$/,
83
+ 'es-HN': /^(\+?504)?[9|8|3|2]\d{7}$/,
84
+ 'es-EC': /^(\+?593|0)([2-7]|9[2-9])\d{7}$/,
85
+ 'es-ES': /^(\+?34)?[6|7]\d{8}$/,
86
+ 'es-PE': /^(\+?51)?9\d{8}$/,
87
+ 'es-MX': /^(\+?52)?(1|01)?\d{10,11}$/,
88
+ 'es-NI': /^(\+?505)\d{7,8}$/,
89
+ 'es-PA': /^(\+?507)\d{7,8}$/,
90
+ 'es-PY': /^(\+?595|0)9[9876]\d{7}$/,
91
+ 'es-SV': /^(\+?503)?[67]\d{7}$/,
92
+ 'es-UY': /^(\+598|0)9[1-9][\d]{6}$/,
93
+ 'es-VE': /^(\+?58)?(2|4)\d{9}$/,
94
+ 'et-EE': /^(\+?372)?\s?(5|8[1-4])\s?([0-9]\s?){6,7}$/,
95
+ 'fa-IR': /^(\+?98[\-\s]?|0)9[0-39]\d[\-\s]?\d{3}[\-\s]?\d{4}$/,
96
+ 'fi-FI': /^(\+?358|0)\s?(4[0-6]|50)\s?(\d\s?){4,8}$/,
97
+ 'fj-FJ': /^(\+?679)?\s?\d{3}\s?\d{4}$/,
98
+ 'fo-FO': /^(\+?298)?\s?\d{2}\s?\d{2}\s?\d{2}$/,
99
+ 'fr-BF': /^(\+226|0)[67]\d{7}$/,
100
+ 'fr-BJ': /^(\+229)\d{8}$/,
101
+ 'fr-CD': /^(\+?243|0)?(8|9)\d{8}$/,
102
+ 'fr-CM': /^(\+?237)6[0-9]{8}$/,
103
+ 'fr-FR': /^(\+?33|0)[67]\d{8}$/,
104
+ 'fr-GF': /^(\+?594|0|00594)[67]\d{8}$/,
105
+ 'fr-GP': /^(\+?590|0|00590)[67]\d{8}$/,
106
+ 'fr-MQ': /^(\+?596|0|00596)[67]\d{8}$/,
107
+ 'fr-PF': /^(\+?689)?8[789]\d{6}$/,
108
+ 'fr-RE': /^(\+?262|0|00262)[67]\d{8}$/,
109
+ 'fr-WF': /^(\+681)?\d{6}$/,
110
+ 'he-IL': /^(\+972|0)([23489]|5[012345689]|77)[1-9]\d{6}$/,
111
+ 'hu-HU': /^(\+?36|06)(20|30|31|50|70)\d{7}$/,
112
+ 'id-ID': /^(\+?62|0)8(1[123456789]|2[1238]|3[1238]|5[12356789]|7[78]|9[56789]|8[123456789])([\s?|\d]{5,11})$/,
113
+ 'ir-IR': /^(\+98|0)?9\d{9}$/,
114
+ 'it-IT': /^(\+?39)?\s?3\d{2} ?\d{6,7}$/,
115
+ 'it-SM': /^((\+378)|(0549)|(\+390549)|(\+3780549))?6\d{5,9}$/,
116
+ 'ja-JP': /^(\+81[ \-]?(\(0\))?|0)[6789]0[ \-]?\d{4}[ \-]?\d{4}$/,
117
+ 'ka-GE': /^(\+?995)?(79\d{7}|5\d{8})$/,
118
+ 'kk-KZ': /^(\+?7|8)?7\d{9}$/,
119
+ 'kl-GL': /^(\+?299)?\s?\d{2}\s?\d{2}\s?\d{2}$/,
120
+ 'ko-KR': /^((\+?82)[ \-]?)?0?1([0|1|6|7|8|9]{1})[ \-]?\d{3,4}[ \-]?\d{4}$/,
121
+ 'ky-KG': /^(\+?7\s?\+?7|0)\s?\d{2}\s?\d{3}\s?\d{4}$/,
122
+ 'lt-LT': /^(\+370|8)\d{8}$/,
123
+ 'lv-LV': /^(\+?371)2\d{7}$/,
124
+ 'mg-MG': /^((\+?261|0)(2|3)\d)?\d{7}$/,
125
+ 'mn-MN': /^(\+|00|011)?976(77|81|88|91|94|95|96|99)\d{6}$/,
126
+ 'my-MM': /^(\+?959|09|9)(2[5-7]|3[1-2]|4[0-5]|6[6-9]|7[5-9]|9[6-9])[0-9]{7}$/,
127
+ 'ms-MY': /^(\+?60|0)1(([0145](-|\s)?\d{7,8})|([236-9](-|\s)?\d{7}))$/,
128
+ 'mz-MZ': /^(\+?258)?8[234567]\d{7}$/,
129
+ 'nb-NO': /^(\+?47)?[49]\d{7}$/,
130
+ 'ne-NP': /^(\+?977)?9[78]\d{8}$/,
131
+ 'nl-BE': /^(\+?32|0)4\d{8}$/,
132
+ 'nl-NL': /^(((\+|00)?31\(0\))|((\+|00)?31)|0)6{1}\d{8}$/,
133
+ 'nl-AW': /^(\+)?297(56|59|64|73|74|99)\d{5}$/,
134
+ 'nn-NO': /^(\+?47)?[49]\d{7}$/,
135
+ 'pl-PL': /^(\+?48)? ?([5-8]\d|45) ?\d{3} ?\d{2} ?\d{2}$/,
136
+ 'pt-BR': /^((\+?55\ ?[1-9]{2}\ ?)|(\+?55\ ?\([1-9]{2}\)\ ?)|(0[1-9]{2}\ ?)|(\([1-9]{2}\)\ ?)|([1-9]{2}\ ?))((\d{4}\-?\d{4})|(9[1-9]{1}\d{3}\-?\d{4}))$/,
137
+ 'pt-PT': /^(\+?351)?9[1236]\d{7}$/,
138
+ 'pt-AO': /^(\+244)\d{9}$/,
139
+ 'ro-MD': /^(\+?373|0)((6(0|1|2|6|7|8|9))|(7(6|7|8|9)))\d{6}$/,
140
+ 'ro-RO': /^(\+?40|0)\s?7\d{2}(\/|\s|\.|-)?\d{3}(\s|\.|-)?\d{3}$/,
141
+ 'ru-RU': /^(\+?7|8)?9\d{9}$/,
142
+ 'si-LK': /^(?:0|94|\+94)?(7(0|1|2|4|5|6|7|8)( |-)?)\d{7}$/,
143
+ 'sl-SI': /^(\+386\s?|0)(\d{1}\s?\d{3}\s?\d{2}\s?\d{2}|\d{2}\s?\d{3}\s?\d{3})$/,
144
+ 'sk-SK': /^(\+?421)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/,
145
+ 'so-SO': /^(\+?252|0)((6[0-9])\d{7}|(7[1-9])\d{7})$/,
146
+ 'sq-AL': /^(\+355|0)6[789]\d{6}$/,
147
+ 'sr-RS': /^(\+3816|06)[- \d]{5,9}$/,
148
+ 'sv-SE': /^(\+?46|0)[\s\-]?7[\s\-]?[02369]([\s\-]?\d){7}$/,
149
+ 'tg-TJ': /^(\+?992)?[5][5]\d{7}$/,
150
+ 'th-TH': /^(\+66|66|0)\d{9}$/,
151
+ 'tr-TR': /^(\+?90|0)?5\d{9}$/,
152
+ 'tk-TM': /^(\+993|993|8)\d{8}$/,
153
+ 'uk-UA': /^(\+?38|8)?0\d{9}$/,
154
+ 'uz-UZ': /^(\+?998)?(6[125-79]|7[1-69]|88|9\d)\d{7}$/,
155
+ 'vi-VN': /^((\+?84)|0)((3([2-9]))|(5([25689]))|(7([0|6-9]))|(8([1-9]))|(9([0-9])))([0-9]{7})$/,
156
+ 'zh-CN': /^((\+|00)86)?(1[3-9]|9[28])\d{9}$/,
157
+ 'zh-TW': /^(\+?886\-?|0)?9\d{8}$/,
158
+ 'dz-BT': /^(\+?975|0)?(17|16|77|02)\d{6}$/,
159
+ 'ar-YE': /^(((\+|00)9677|0?7)[0137]\d{7}|((\+|00)967|0)[1-7]\d{6})$/,
160
+ 'ar-EH': /^(\+?212|0)[\s\-]?(5288|5289)[\s\-]?\d{5}$/,
161
+ 'fa-AF': /^(\+93|0)?(2{1}[0-8]{1}|[3-5]{1}[0-4]{1})(\d{7})$/
162
+ };
163
+ /* eslint-enable max-len */
164
+
165
+ // aliases
166
+ phones['en-CA'] = phones['en-US'];
167
+ phones['fr-CA'] = phones['en-CA'];
168
+ phones['fr-BE'] = phones['nl-BE'];
169
+ phones['zh-HK'] = phones['en-HK'];
170
+ phones['zh-MO'] = phones['en-MO'];
171
+ phones['ga-IE'] = phones['en-IE'];
172
+ phones['fr-CH'] = phones['de-CH'];
173
+ phones['it-CH'] = phones['fr-CH'];
174
+ export default function isMobilePhone(str, locale, options) {
175
+ assertString(str);
176
+ if (options && options.strictMode && !str.startsWith('+')) {
177
+ return false;
178
+ }
179
+ if (Array.isArray(locale)) {
180
+ return locale.some(function (key) {
181
+ // https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md#ignoring-code-for-coverage-purposes
182
+ // istanbul ignore else
183
+ if (phones.hasOwnProperty(key)) {
184
+ var phone = phones[key];
185
+ if (phone.test(str)) {
186
+ return true;
187
+ }
188
+ }
189
+ return false;
190
+ });
191
+ } else if (locale in phones) {
192
+ return phones[locale].test(str);
193
+ // alias falsey locale as 'any'
194
+ } else if (!locale || locale === 'any') {
195
+ for (var key in phones) {
196
+ // istanbul ignore else
197
+ if (phones.hasOwnProperty(key)) {
198
+ var phone = phones[key];
199
+ if (phone.test(str)) {
200
+ return true;
201
+ }
202
+ }
203
+ }
204
+ return false;
205
+ }
206
+ throw new Error("Invalid locale '".concat(locale, "'"));
207
+ }
208
+ export var locales = Object.keys(phones);
@@ -0,0 +1,6 @@
1
+ import assertString from './util/assertString';
2
+ import isHexadecimal from './isHexadecimal';
3
+ export default function isMongoId(str) {
4
+ assertString(str);
5
+ return isHexadecimal(str) && str.length === 24;
6
+ }
@@ -0,0 +1,10 @@
1
+ import assertString from './util/assertString';
2
+
3
+ /* eslint-disable no-control-regex */
4
+ var multibyte = /[^\x00-\x7F]/;
5
+ /* eslint-enable no-control-regex */
6
+
7
+ export default function isMultibyte(str) {
8
+ assertString(str);
9
+ return multibyte.test(str);
10
+ }
@@ -0,0 +1,10 @@
1
+ import assertString from './util/assertString';
2
+ import { decimal } from './alpha';
3
+ var numericNoSymbols = /^[0-9]+$/;
4
+ export default function isNumeric(str, options) {
5
+ assertString(str);
6
+ if (options && options.no_symbols) {
7
+ return numericNoSymbols.test(str);
8
+ }
9
+ return new RegExp("^[+-]?([0-9]*[".concat((options || {}).locale ? decimal[options.locale] : '.', "])?[0-9]+$")).test(str);
10
+ }
@@ -0,0 +1,6 @@
1
+ import assertString from './util/assertString';
2
+ var octal = /^(0o)?[0-7]+$/i;
3
+ export default function isOctal(str) {
4
+ assertString(str);
5
+ return octal.test(str);
6
+ }