validator-string 13.15.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +269 -0
  3. package/es/index.js +218 -0
  4. package/es/lib/alpha.js +151 -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 +10 -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 +15 -0
  16. package/es/lib/isBase58.js +8 -0
  17. package/es/lib/isBase64.js +23 -0
  18. package/es/lib/isBefore.js +10 -0
  19. package/es/lib/isBoolean.js +15 -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 +93 -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 +165 -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 +14 -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 +13 -0
  39. package/es/lib/isHexadecimal.js +6 -0
  40. package/es/lib/isIBAN.js +171 -0
  41. package/es/lib/isIMEI.js +40 -0
  42. package/es/lib/isIP.js +58 -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/isISO15924.js +9 -0
  47. package/es/lib/isISO31661Alpha2.js +21 -0
  48. package/es/lib/isISO31661Alpha3.js +20 -0
  49. package/es/lib/isISO31661Numeric.js +8 -0
  50. package/es/lib/isISO4217.js +9 -0
  51. package/es/lib/isISO6346.js +28 -0
  52. package/es/lib/isISO6391.js +6 -0
  53. package/es/lib/isISO8601.js +42 -0
  54. package/es/lib/isISRC.js +8 -0
  55. package/es/lib/isISSN.js +19 -0
  56. package/es/lib/isIdentityCard.js +407 -0
  57. package/es/lib/isIn.js +23 -0
  58. package/es/lib/isInt.js +19 -0
  59. package/es/lib/isJSON.js +26 -0
  60. package/es/lib/isJWT.js +15 -0
  61. package/es/lib/isLatLong.js +21 -0
  62. package/es/lib/isLength.js +27 -0
  63. package/es/lib/isLicensePlate.js +58 -0
  64. package/es/lib/isLocale.js +107 -0
  65. package/es/lib/isLowercase.js +5 -0
  66. package/es/lib/isLuhnNumber.js +25 -0
  67. package/es/lib/isMACAddress.js +36 -0
  68. package/es/lib/isMD5.js +6 -0
  69. package/es/lib/isMagnetURI.js +9 -0
  70. package/es/lib/isMailtoURI.js +75 -0
  71. package/es/lib/isMimeType.js +40 -0
  72. package/es/lib/isMobilePhone.js +212 -0
  73. package/es/lib/isMongoId.js +6 -0
  74. package/es/lib/isMultibyte.js +10 -0
  75. package/es/lib/isNumeric.js +10 -0
  76. package/es/lib/isOctal.js +6 -0
  77. package/es/lib/isPassportNumber.js +145 -0
  78. package/es/lib/isPort.js +8 -0
  79. package/es/lib/isPostalCode.js +100 -0
  80. package/es/lib/isRFC3339.js +21 -0
  81. package/es/lib/isRgbColor.js +34 -0
  82. package/es/lib/isSemVer.js +14 -0
  83. package/es/lib/isSlug.js +6 -0
  84. package/es/lib/isStrongPassword.js +90 -0
  85. package/es/lib/isSurrogatePair.js +6 -0
  86. package/es/lib/isTaxID.js +1407 -0
  87. package/es/lib/isTime.js +22 -0
  88. package/es/lib/isULID.js +5 -0
  89. package/es/lib/isURL.js +241 -0
  90. package/es/lib/isUUID.js +23 -0
  91. package/es/lib/isUppercase.js +5 -0
  92. package/es/lib/isVAT.js +264 -0
  93. package/es/lib/isVariableWidth.js +7 -0
  94. package/es/lib/isWhitelisted.js +10 -0
  95. package/es/lib/ltrim.js +7 -0
  96. package/es/lib/matches.js +8 -0
  97. package/es/lib/normalizeEmail.js +131 -0
  98. package/es/lib/rtrim.js +15 -0
  99. package/es/lib/stripLow.js +7 -0
  100. package/es/lib/toBoolean.js +8 -0
  101. package/es/lib/toDate.js +6 -0
  102. package/es/lib/toFloat.js +5 -0
  103. package/es/lib/toInt.js +5 -0
  104. package/es/lib/trim.js +5 -0
  105. package/es/lib/unescape.js +8 -0
  106. package/es/lib/util/algorithms.js +79 -0
  107. package/es/lib/util/assertString.js +4 -0
  108. package/es/lib/util/checkHost.js +12 -0
  109. package/es/lib/util/includesArray.js +6 -0
  110. package/es/lib/util/includesString.js +4 -0
  111. package/es/lib/util/merge.js +14 -0
  112. package/es/lib/util/multilineRegex.js +12 -0
  113. package/es/lib/util/nullUndefinedCheck.js +3 -0
  114. package/es/lib/util/toString.js +13 -0
  115. package/es/lib/util/typeOf.js +10 -0
  116. package/es/lib/whitelist.js +5 -0
  117. package/index.js +229 -0
  118. package/lib/alpha.js +157 -0
  119. package/lib/blacklist.js +14 -0
  120. package/lib/contains.js +24 -0
  121. package/lib/equals.js +14 -0
  122. package/lib/escape.js +14 -0
  123. package/lib/isAbaRouting.js +23 -0
  124. package/lib/isAfter.js +19 -0
  125. package/lib/isAlpha.js +31 -0
  126. package/lib/isAlphanumeric.js +31 -0
  127. package/lib/isAscii.js +18 -0
  128. package/lib/isBIC.js +24 -0
  129. package/lib/isBase32.js +24 -0
  130. package/lib/isBase58.js +16 -0
  131. package/lib/isBase64.js +32 -0
  132. package/lib/isBefore.js +19 -0
  133. package/lib/isBoolean.js +24 -0
  134. package/lib/isBtcAddress.js +16 -0
  135. package/lib/isByteLength.js +27 -0
  136. package/lib/isCreditCard.js +52 -0
  137. package/lib/isCurrency.js +83 -0
  138. package/lib/isDataURI.js +40 -0
  139. package/lib/isDate.js +102 -0
  140. package/lib/isDecimal.js +31 -0
  141. package/lib/isDivisibleBy.js +15 -0
  142. package/lib/isEAN.js +78 -0
  143. package/lib/isEmail.js +174 -0
  144. package/lib/isEmpty.js +19 -0
  145. package/lib/isEthereumAddress.js +15 -0
  146. package/lib/isFQDN.js +76 -0
  147. package/lib/isFloat.js +22 -0
  148. package/lib/isFullWidth.js +14 -0
  149. package/lib/isHSL.js +22 -0
  150. package/lib/isHalfWidth.js +14 -0
  151. package/lib/isHash.js +30 -0
  152. package/lib/isHexColor.js +22 -0
  153. package/lib/isHexadecimal.js +15 -0
  154. package/lib/isIBAN.js +178 -0
  155. package/lib/isIMEI.js +49 -0
  156. package/lib/isIP.js +67 -0
  157. package/lib/isIPRange.js +50 -0
  158. package/lib/isISBN.js +56 -0
  159. package/lib/isISIN.js +64 -0
  160. package/lib/isISO15924.js +16 -0
  161. package/lib/isISO31661Alpha2.js +28 -0
  162. package/lib/isISO31661Alpha3.js +28 -0
  163. package/lib/isISO31661Numeric.js +16 -0
  164. package/lib/isISO4217.js +16 -0
  165. package/lib/isISO6346.js +35 -0
  166. package/lib/isISO6391.js +15 -0
  167. package/lib/isISO8601.js +50 -0
  168. package/lib/isISRC.js +16 -0
  169. package/lib/isISSN.js +28 -0
  170. package/lib/isIdentityCard.js +416 -0
  171. package/lib/isIn.js +32 -0
  172. package/lib/isInt.js +28 -0
  173. package/lib/isJSON.js +35 -0
  174. package/lib/isJWT.js +24 -0
  175. package/lib/isLatLong.js +30 -0
  176. package/lib/isLength.js +35 -0
  177. package/lib/isLicensePlate.js +67 -0
  178. package/lib/isLocale.js +115 -0
  179. package/lib/isLowercase.js +14 -0
  180. package/lib/isLuhnNumber.js +34 -0
  181. package/lib/isMACAddress.js +45 -0
  182. package/lib/isMD5.js +15 -0
  183. package/lib/isMagnetURI.js +18 -0
  184. package/lib/isMailtoURI.js +84 -0
  185. package/lib/isMimeType.js +48 -0
  186. package/lib/isMobilePhone.js +219 -0
  187. package/lib/isMongoId.js +15 -0
  188. package/lib/isMultibyte.js +18 -0
  189. package/lib/isNumeric.js +19 -0
  190. package/lib/isOctal.js +15 -0
  191. package/lib/isPassportNumber.js +152 -0
  192. package/lib/isPort.js +17 -0
  193. package/lib/isPostalCode.js +107 -0
  194. package/lib/isRFC3339.js +29 -0
  195. package/lib/isRgbColor.js +42 -0
  196. package/lib/isSemVer.js +22 -0
  197. package/lib/isSlug.js +15 -0
  198. package/lib/isStrongPassword.js +99 -0
  199. package/lib/isSurrogatePair.js +15 -0
  200. package/lib/isTaxID.js +1417 -0
  201. package/lib/isTime.js +31 -0
  202. package/lib/isULID.js +14 -0
  203. package/lib/isURL.js +249 -0
  204. package/lib/isUUID.js +32 -0
  205. package/lib/isUppercase.js +14 -0
  206. package/lib/isVAT.js +274 -0
  207. package/lib/isVariableWidth.js +16 -0
  208. package/lib/isWhitelisted.js +19 -0
  209. package/lib/ltrim.js +16 -0
  210. package/lib/matches.js +17 -0
  211. package/lib/normalizeEmail.js +140 -0
  212. package/lib/rtrim.js +24 -0
  213. package/lib/stripLow.js +16 -0
  214. package/lib/toBoolean.js +17 -0
  215. package/lib/toDate.js +15 -0
  216. package/lib/toFloat.js +14 -0
  217. package/lib/toInt.js +14 -0
  218. package/lib/trim.js +14 -0
  219. package/lib/unescape.js +17 -0
  220. package/lib/util/algorithms.js +88 -0
  221. package/lib/util/assertString.js +12 -0
  222. package/lib/util/checkHost.js +20 -0
  223. package/lib/util/includesArray.js +14 -0
  224. package/lib/util/includesString.js +12 -0
  225. package/lib/util/merge.js +22 -0
  226. package/lib/util/multilineRegex.js +20 -0
  227. package/lib/util/nullUndefinedCheck.js +11 -0
  228. package/lib/util/toString.js +21 -0
  229. package/lib/util/typeOf.js +18 -0
  230. package/lib/whitelist.js +14 -0
  231. package/package.json +83 -0
  232. package/validator.js +5808 -0
  233. package/validator.min.js +23 -0
@@ -0,0 +1,219 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isMobilePhone;
7
+ exports.locales = void 0;
8
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ /* eslint-disable max-len */
11
+ var phones = {
12
+ 'am-AM': /^(\+?374|0)(33|4[134]|55|77|88|9[13-689])\d{6}$/,
13
+ 'ar-AE': /^((\+?971)|0)?5[024568]\d{7}$/,
14
+ 'ar-BH': /^(\+?973)?(3|6)\d{7}$/,
15
+ 'ar-DZ': /^(\+?213|0)(5|6|7)\d{8}$/,
16
+ 'ar-LB': /^(\+?961)?((3|81)\d{6}|7\d{7})$/,
17
+ 'ar-EG': /^((\+?20)|0)?1[0125]\d{8}$/,
18
+ 'ar-IQ': /^(\+?964|0)?7[0-9]\d{8}$/,
19
+ 'ar-JO': /^(\+?962|0)?7[789]\d{7}$/,
20
+ 'ar-KW': /^(\+?965)([569]\d{7}|41\d{6})$/,
21
+ 'ar-LY': /^((\+?218)|0)?(9[1-6]\d{7}|[1-8]\d{7,9})$/,
22
+ 'ar-MA': /^(?:(?:\+|00)212|0)[5-7]\d{8}$/,
23
+ 'ar-OM': /^((\+|00)968)?([79][1-9])\d{6}$/,
24
+ 'ar-PS': /^(\+?970|0)5[6|9](\d{7})$/,
25
+ 'ar-SA': /^(!?(\+?966)|0)?5\d{8}$/,
26
+ 'ar-SD': /^((\+?249)|0)?(9[012369]|1[012])\d{7}$/,
27
+ 'ar-SY': /^(!?(\+?963)|0)?9\d{8}$/,
28
+ 'ar-TN': /^(\+?216)?[2459]\d{7}$/,
29
+ 'az-AZ': /^(\+994|0)(10|5[015]|7[07]|99)\d{7}$/,
30
+ 'ar-QA': /^(\+?974|0)?([3567]\d{7})$/,
31
+ 'bs-BA': /^((((\+|00)3876)|06))((([0-3]|[5-6])\d{6})|(4\d{7}))$/,
32
+ 'be-BY': /^(\+?375)?(24|25|29|33|44)\d{7}$/,
33
+ 'bg-BG': /^(\+?359|0)?8[789]\d{7}$/,
34
+ 'bn-BD': /^(\+?880|0)1[13456789][0-9]{8}$/,
35
+ 'ca-AD': /^(\+376)?[346]\d{5}$/,
36
+ 'cs-CZ': /^(\+?420)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/,
37
+ 'da-DK': /^(\+?45)?\s?\d{2}\s?\d{2}\s?\d{2}\s?\d{2}$/,
38
+ 'de-DE': /^((\+49|0)1)(5[0-25-9]\d|6([23]|0\d?)|7([0-57-9]|6\d))\d{7,9}$/,
39
+ 'de-AT': /^(\+43|0)\d{1,4}\d{3,12}$/,
40
+ 'de-CH': /^(\+41|0)([1-9])\d{1,9}$/,
41
+ 'de-LU': /^(\+352)?((6\d1)\d{6})$/,
42
+ 'dv-MV': /^(\+?960)?(7[2-9]|9[1-9])\d{5}$/,
43
+ 'el-GR': /^(\+?30|0)?6(8[5-9]|9(?![26])[0-9])\d{7}$/,
44
+ 'el-CY': /^(\+?357?)?(9(9|7|6|5|4)\d{6})$/,
45
+ '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}$/,
46
+ 'en-AU': /^(\+?61|0)4\d{8}$/,
47
+ 'en-AG': /^(?:\+1|1)268(?:464|7(?:1[3-9]|[28]\d|3[0246]|64|7[0-689]))\d{4}$/,
48
+ 'en-BM': /^(\+?1)?441(((3|7)\d{6}$)|(5[0-3][0-9]\d{4}$)|(59\d{5}$))/,
49
+ 'en-BS': /^(\+?1[-\s]?|0)?\(?242\)?[-\s]?\d{3}[-\s]?\d{4}$/,
50
+ 'en-GB': /^(\+?44|0)7[1-9]\d{8}$/,
51
+ 'en-GG': /^(\+?44|0)1481\d{6}$/,
52
+ 'en-GH': /^(\+233|0)(20|50|24|54|27|57|26|56|23|53|28|55|59)\d{7}$/,
53
+ 'en-GY': /^(\+592|0)6\d{6}$/,
54
+ 'en-HK': /^(\+?852[-\s]?)?[456789]\d{3}[-\s]?\d{4}$/,
55
+ 'en-MO': /^(\+?853[-\s]?)?[6]\d{3}[-\s]?\d{4}$/,
56
+ 'en-IE': /^(\+?353|0)8[356789]\d{7}$/,
57
+ 'en-IN': /^(\+?91|0)?[6789]\d{9}$/,
58
+ 'en-JM': /^(\+?876)?\d{7}$/,
59
+ 'en-KE': /^(\+?254|0)(7|1)\d{8}$/,
60
+ 'fr-CF': /^(\+?236| ?)(70|75|77|72|21|22)\d{6}$/,
61
+ 'en-SS': /^(\+?211|0)(9[1257])\d{7}$/,
62
+ 'en-KI': /^((\+686|686)?)?( )?((6|7)(2|3|8)[0-9]{6})$/,
63
+ 'en-KN': /^(?:\+1|1)869(?:46\d|48[89]|55[6-8]|66\d|76[02-7])\d{4}$/,
64
+ 'en-LS': /^(\+?266)(22|28|57|58|59|27|52)\d{6}$/,
65
+ 'en-MT': /^(\+?356|0)?(99|79|77|21|27|22|25)[0-9]{6}$/,
66
+ 'en-MU': /^(\+?230|0)?\d{8}$/,
67
+ 'en-MW': /^(\+?265|0)(((77|88|31|99|98|21)\d{7})|(((111)|1)\d{6})|(32000\d{4}))$/,
68
+ 'en-NA': /^(\+?264|0)(6|8)\d{7}$/,
69
+ 'en-NG': /^(\+?234|0)?[789]\d{9}$/,
70
+ 'en-NZ': /^(\+?64|0)[28]\d{7,9}$/,
71
+ 'en-PG': /^(\+?675|0)?(7\d|8[18])\d{6}$/,
72
+ 'en-PK': /^((00|\+)?92|0)3[0-6]\d{8}$/,
73
+ 'en-PH': /^(09|\+639)\d{9}$/,
74
+ 'en-RW': /^(\+?250|0)?[7]\d{8}$/,
75
+ 'en-SG': /^(\+65)?[3689]\d{7}$/,
76
+ 'en-SL': /^(\+?232|0)\d{8}$/,
77
+ 'en-TZ': /^(\+?255|0)?[67]\d{8}$/,
78
+ 'en-UG': /^(\+?256|0)?[7]\d{8}$/,
79
+ 'en-US': /^((\+1|1)?( |-)?)?(\([2-9][0-9]{2}\)|[2-9][0-9]{2})( |-)?([2-9][0-9]{2}( |-)?[0-9]{4})$/,
80
+ 'en-ZA': /^(\+?27|0)\d{9}$/,
81
+ 'en-ZM': /^(\+?26)?0[79][567]\d{7}$/,
82
+ 'en-ZW': /^(\+263)[0-9]{9}$/,
83
+ 'en-BW': /^(\+?267)?(7[1-8]{1})\d{6}$/,
84
+ 'es-AR': /^\+?549(11|[2368]\d)\d{8}$/,
85
+ 'es-BO': /^(\+?591)?(6|7)\d{7}$/,
86
+ 'es-CO': /^(\+?57)?3(0(0|1|2|4|5)|1\d|2[0-4]|5(0|1))\d{7}$/,
87
+ 'es-CL': /^(\+?56|0)[2-9]\d{1}\d{7}$/,
88
+ 'es-CR': /^(\+506)?[2-8]\d{7}$/,
89
+ 'es-CU': /^(\+53|0053)?5\d{7}$/,
90
+ 'es-DO': /^(\+?1)?8[024]9\d{7}$/,
91
+ 'es-HN': /^(\+?504)?[9|8|3|2]\d{7}$/,
92
+ 'es-EC': /^(\+?593|0)([2-7]|9[2-9])\d{7}$/,
93
+ 'es-ES': /^(\+?34)?[6|7]\d{8}$/,
94
+ 'es-GT': /^(\+?502)?[2|6|7]\d{7}$/,
95
+ 'es-PE': /^(\+?51)?9\d{8}$/,
96
+ 'es-MX': /^(\+?52)?(1|01)?\d{10,11}$/,
97
+ 'es-NI': /^(\+?505)\d{7,8}$/,
98
+ 'es-PA': /^(\+?507)\d{7,8}$/,
99
+ 'es-PY': /^(\+?595|0)9[9876]\d{7}$/,
100
+ 'es-SV': /^(\+?503)?[67]\d{7}$/,
101
+ 'es-UY': /^(\+598|0)9[1-9][\d]{6}$/,
102
+ 'es-VE': /^(\+?58)?(2|4)\d{9}$/,
103
+ 'et-EE': /^(\+?372)?\s?(5|8[1-4])\s?([0-9]\s?){6,7}$/,
104
+ 'fa-IR': /^(\+?98[\-\s]?|0)9[0-39]\d[\-\s]?\d{3}[\-\s]?\d{4}$/,
105
+ 'fi-FI': /^(\+?358|0)\s?(4[0-6]|50)\s?(\d\s?){4,8}$/,
106
+ 'fj-FJ': /^(\+?679)?\s?\d{3}\s?\d{4}$/,
107
+ 'fo-FO': /^(\+?298)?\s?\d{2}\s?\d{2}\s?\d{2}$/,
108
+ 'fr-BF': /^(\+226|0)[67]\d{7}$/,
109
+ 'fr-BJ': /^(\+229)\d{8}$/,
110
+ 'fr-CD': /^(\+?243|0)?(8|9)\d{8}$/,
111
+ 'fr-CM': /^(\+?237)6[0-9]{8}$/,
112
+ 'fr-DJ': /^(?:\+253)?77[6-8]\d{5}$/,
113
+ 'fr-FR': /^(\+?33|0)[67]\d{8}$/,
114
+ 'fr-GF': /^(\+?594|0|00594)[67]\d{8}$/,
115
+ 'fr-GP': /^(\+?590|0|00590)[67]\d{8}$/,
116
+ 'fr-MQ': /^(\+?596|0|00596)[67]\d{8}$/,
117
+ 'fr-PF': /^(\+?689)?8[789]\d{6}$/,
118
+ 'fr-RE': /^(\+?262|0|00262)[67]\d{8}$/,
119
+ 'fr-WF': /^(\+681)?\d{6}$/,
120
+ 'he-IL': /^(\+972|0)([23489]|5[012345689]|77)[1-9]\d{6}$/,
121
+ 'hu-HU': /^(\+?36|06)(20|30|31|50|70)\d{7}$/,
122
+ 'id-ID': /^(\+?62|0)8(1[123456789]|2[1238]|3[1238]|5[12356789]|7[78]|9[56789]|8[123456789])([\s?|\d]{5,11})$/,
123
+ 'ir-IR': /^(\+98|0)?9\d{9}$/,
124
+ 'it-IT': /^(\+?39)?\s?3\d{2} ?\d{6,7}$/,
125
+ 'it-SM': /^((\+378)|(0549)|(\+390549)|(\+3780549))?6\d{5,9}$/,
126
+ 'ja-JP': /^(\+81[ \-]?(\(0\))?|0)[6789]0[ \-]?\d{4}[ \-]?\d{4}$/,
127
+ 'ka-GE': /^(\+?995)?(79\d{7}|5\d{8})$/,
128
+ 'kk-KZ': /^(\+?7|8)?7\d{9}$/,
129
+ 'kl-GL': /^(\+?299)?\s?\d{2}\s?\d{2}\s?\d{2}$/,
130
+ 'ko-KR': /^((\+?82)[ \-]?)?0?1([0|1|6|7|8|9]{1})[ \-]?\d{3,4}[ \-]?\d{4}$/,
131
+ 'ky-KG': /^(\+996\s?)?(22[0-9]|50[0-9]|55[0-9]|70[0-9]|75[0-9]|77[0-9]|880|990|995|996|997|998)\s?\d{3}\s?\d{3}$/,
132
+ 'lt-LT': /^(\+370|8)\d{8}$/,
133
+ 'lv-LV': /^(\+?371)2\d{7}$/,
134
+ 'mg-MG': /^((\+?261|0)(2|3)\d)?\d{7}$/,
135
+ 'mn-MN': /^(\+|00|011)?976(77|81|88|91|94|95|96|99)\d{6}$/,
136
+ '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}$/,
137
+ 'ms-MY': /^(\+?60|0)1(([0145](-|\s)?\d{7,8})|([236-9](-|\s)?\d{7}))$/,
138
+ 'mz-MZ': /^(\+?258)?8[234567]\d{7}$/,
139
+ 'nb-NO': /^(\+?47)?[49]\d{7}$/,
140
+ 'ne-NP': /^(\+?977)?9[78]\d{8}$/,
141
+ 'nl-BE': /^(\+?32|0)4\d{8}$/,
142
+ 'nl-NL': /^(((\+|00)?31\(0\))|((\+|00)?31)|0)6{1}\d{8}$/,
143
+ 'nl-AW': /^(\+)?297(56|59|64|73|74|99)\d{5}$/,
144
+ 'nn-NO': /^(\+?47)?[49]\d{7}$/,
145
+ 'pl-PL': /^(\+?48)? ?([5-8]\d|45) ?\d{3} ?\d{2} ?\d{2}$/,
146
+ '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}))$/,
147
+ 'pt-PT': /^(\+?351)?9[1236]\d{7}$/,
148
+ 'pt-AO': /^(\+?244)?9\d{8}$/,
149
+ 'ro-MD': /^(\+?373|0)((6(0|1|2|6|7|8|9))|(7(6|7|8|9)))\d{6}$/,
150
+ 'ro-RO': /^(\+?40|0)\s?7\d{2}(\/|\s|\.|-)?\d{3}(\s|\.|-)?\d{3}$/,
151
+ 'ru-RU': /^(\+?7|8)?9\d{9}$/,
152
+ 'si-LK': /^(?:0|94|\+94)?(7(0|1|2|4|5|6|7|8)( |-)?)\d{7}$/,
153
+ 'sl-SI': /^(\+386\s?|0)(\d{1}\s?\d{3}\s?\d{2}\s?\d{2}|\d{2}\s?\d{3}\s?\d{3})$/,
154
+ 'sk-SK': /^(\+?421)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/,
155
+ 'so-SO': /^(\+?252|0)((6[0-9])\d{7}|(7[1-9])\d{7})$/,
156
+ 'sq-AL': /^(\+355|0)6[2-9]\d{7}$/,
157
+ 'sr-RS': /^(\+3816|06)[- \d]{5,9}$/,
158
+ 'sv-SE': /^(\+?46|0)[\s\-]?7[\s\-]?[02369]([\s\-]?\d){7}$/,
159
+ 'tg-TJ': /^(\+?992)?[5][5]\d{7}$/,
160
+ 'th-TH': /^(\+66|66|0)\d{9}$/,
161
+ 'tr-TR': /^(\+?90|0)?5\d{9}$/,
162
+ 'tk-TM': /^(\+993|993|8)\d{8}$/,
163
+ 'uk-UA': /^(\+?38)?0(50|6[36-8]|7[357]|9[1-9])\d{7}$/,
164
+ 'uz-UZ': /^(\+?998)?(6[125-79]|7[1-69]|88|9\d)\d{7}$/,
165
+ 'vi-VN': /^((\+?84)|0)((3([2-9]))|(5([25689]))|(7([0|6-9]))|(8([1-9]))|(9([0-9])))([0-9]{7})$/,
166
+ 'zh-CN': /^((\+|00)86)?(1[3-9]|9[28])\d{9}$/,
167
+ 'zh-TW': /^(\+?886\-?|0)?9\d{8}$/,
168
+ 'dz-BT': /^(\+?975|0)?(17|16|77|02)\d{6}$/,
169
+ 'ar-YE': /^(((\+|00)9677|0?7)[0137]\d{7}|((\+|00)967|0)[1-7]\d{6})$/,
170
+ 'ar-EH': /^(\+?212|0)[\s\-]?(5288|5289)[\s\-]?\d{5}$/,
171
+ 'fa-AF': /^(\+93|0)?(2{1}[0-8]{1}|[3-5]{1}[0-4]{1})(\d{7})$/,
172
+ 'mk-MK': /^(\+?389|0)?((?:2[2-9]\d{6}|(?:3[1-4]|4[2-8])\d{6}|500\d{5}|5[2-9]\d{6}|7[0-9][2-9]\d{5}|8[1-9]\d{6}|800\d{5}|8009\d{4}))$/
173
+ };
174
+ /* eslint-enable max-len */
175
+
176
+ // aliases
177
+ phones['en-CA'] = phones['en-US'];
178
+ phones['fr-CA'] = phones['en-CA'];
179
+ phones['fr-BE'] = phones['nl-BE'];
180
+ phones['zh-HK'] = phones['en-HK'];
181
+ phones['zh-MO'] = phones['en-MO'];
182
+ phones['ga-IE'] = phones['en-IE'];
183
+ phones['fr-CH'] = phones['de-CH'];
184
+ phones['it-CH'] = phones['fr-CH'];
185
+ function isMobilePhone(str, locale, options) {
186
+ (0, _assertString.default)(str);
187
+ if (options && options.strictMode && !str.startsWith('+')) {
188
+ return false;
189
+ }
190
+ if (Array.isArray(locale)) {
191
+ return locale.some(function (key) {
192
+ // https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md#ignoring-code-for-coverage-purposes
193
+ // istanbul ignore else
194
+ if (phones.hasOwnProperty(key)) {
195
+ var phone = phones[key];
196
+ if (phone.test(str)) {
197
+ return true;
198
+ }
199
+ }
200
+ return false;
201
+ });
202
+ } else if (locale in phones) {
203
+ return phones[locale].test(str);
204
+ // alias falsey locale as 'any'
205
+ } else if (!locale || locale === 'any') {
206
+ for (var key in phones) {
207
+ // istanbul ignore else
208
+ if (phones.hasOwnProperty(key)) {
209
+ var phone = phones[key];
210
+ if (phone.test(str)) {
211
+ return true;
212
+ }
213
+ }
214
+ }
215
+ return false;
216
+ }
217
+ throw new Error("Invalid locale '".concat(locale, "'"));
218
+ }
219
+ var locales = exports.locales = Object.keys(phones);
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isMongoId;
7
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
8
+ var _isHexadecimal = _interopRequireDefault(require("./isHexadecimal"));
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ function isMongoId(str) {
11
+ (0, _assertString.default)(str);
12
+ return (0, _isHexadecimal.default)(str) && str.length === 24;
13
+ }
14
+ module.exports = exports.default;
15
+ module.exports.default = exports.default;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isMultibyte;
7
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ /* eslint-disable no-control-regex */
10
+ var multibyte = /[^\x00-\x7F]/;
11
+ /* eslint-enable no-control-regex */
12
+
13
+ function isMultibyte(str) {
14
+ (0, _assertString.default)(str);
15
+ return multibyte.test(str);
16
+ }
17
+ module.exports = exports.default;
18
+ module.exports.default = exports.default;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isNumeric;
7
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
8
+ var _alpha = require("./alpha");
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ var numericNoSymbols = /^[0-9]+$/;
11
+ function isNumeric(str, options) {
12
+ (0, _assertString.default)(str);
13
+ if (options && options.no_symbols) {
14
+ return numericNoSymbols.test(str);
15
+ }
16
+ return new RegExp("^[+-]?([0-9]*[".concat((options || {}).locale ? _alpha.decimal[options.locale] : '.', "])?[0-9]+$")).test(str);
17
+ }
18
+ module.exports = exports.default;
19
+ module.exports.default = exports.default;
package/lib/isOctal.js ADDED
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isOctal;
7
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ var octal = /^(0o)?[0-7]+$/i;
10
+ function isOctal(str) {
11
+ (0, _assertString.default)(str);
12
+ return octal.test(str);
13
+ }
14
+ module.exports = exports.default;
15
+ module.exports.default = exports.default;
@@ -0,0 +1,152 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isPassportNumber;
7
+ exports.locales = void 0;
8
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ /**
11
+ * Reference:
12
+ * https://en.wikipedia.org/ -- Wikipedia
13
+ * https://docs.microsoft.com/en-us/microsoft-365/compliance/eu-passport-number -- EU Passport Number
14
+ * https://countrycode.org/ -- Country Codes
15
+ */
16
+ var passportRegexByCountryCode = {
17
+ AM: /^[A-Z]{2}\d{7}$/,
18
+ // ARMENIA
19
+ AR: /^[A-Z]{3}\d{6}$/,
20
+ // ARGENTINA
21
+ AT: /^[A-Z]\d{7}$/,
22
+ // AUSTRIA
23
+ AU: /^[A-Z]\d{7}$/,
24
+ // AUSTRALIA
25
+ AZ: /^[A-Z]{1}\d{8}$/,
26
+ // AZERBAIJAN
27
+ BE: /^[A-Z]{2}\d{6}$/,
28
+ // BELGIUM
29
+ BG: /^\d{9}$/,
30
+ // BULGARIA
31
+ BR: /^[A-Z]{2}\d{6}$/,
32
+ // BRAZIL
33
+ BY: /^[A-Z]{2}\d{7}$/,
34
+ // BELARUS
35
+ CA: /^[A-Z]{2}\d{6}$|^[A-Z]\d{6}[A-Z]{2}$/,
36
+ // CANADA
37
+ CH: /^[A-Z]\d{7}$/,
38
+ // SWITZERLAND
39
+ CN: /^G\d{8}$|^E(?![IO])[A-Z0-9]\d{7}$/,
40
+ // CHINA [G=Ordinary, E=Electronic] followed by 8-digits, or E followed by any UPPERCASE letter (except I and O) followed by 7 digits
41
+ CY: /^[A-Z](\d{6}|\d{8})$/,
42
+ // CYPRUS
43
+ CZ: /^\d{8}$/,
44
+ // CZECH REPUBLIC
45
+ DE: /^[CFGHJKLMNPRTVWXYZ0-9]{9}$/,
46
+ // GERMANY
47
+ DK: /^\d{9}$/,
48
+ // DENMARK
49
+ DZ: /^\d{9}$/,
50
+ // ALGERIA
51
+ EE: /^([A-Z]\d{7}|[A-Z]{2}\d{7})$/,
52
+ // ESTONIA (K followed by 7-digits), e-passports have 2 UPPERCASE followed by 7 digits
53
+ ES: /^[A-Z0-9]{2}([A-Z0-9]?)\d{6}$/,
54
+ // SPAIN
55
+ FI: /^[A-Z]{2}\d{7}$/,
56
+ // FINLAND
57
+ FR: /^\d{2}[A-Z]{2}\d{5}$/,
58
+ // FRANCE
59
+ GB: /^\d{9}$/,
60
+ // UNITED KINGDOM
61
+ GR: /^[A-Z]{2}\d{7}$/,
62
+ // GREECE
63
+ HR: /^\d{9}$/,
64
+ // CROATIA
65
+ HU: /^[A-Z]{2}(\d{6}|\d{7})$/,
66
+ // HUNGARY
67
+ IE: /^[A-Z0-9]{2}\d{7}$/,
68
+ // IRELAND
69
+ IN: /^[A-Z]{1}-?\d{7}$/,
70
+ // INDIA
71
+ ID: /^[A-C]\d{7}$/,
72
+ // INDONESIA
73
+ IR: /^[A-Z]\d{8}$/,
74
+ // IRAN
75
+ IS: /^(A)\d{7}$/,
76
+ // ICELAND
77
+ IT: /^[A-Z0-9]{2}\d{7}$/,
78
+ // ITALY
79
+ JM: /^[Aa]\d{7}$/,
80
+ // JAMAICA
81
+ JP: /^[A-Z]{2}\d{7}$/,
82
+ // JAPAN
83
+ KR: /^[MS]\d{8}$/,
84
+ // SOUTH KOREA, REPUBLIC OF KOREA, [S=PS Passports, M=PM Passports]
85
+ KZ: /^[a-zA-Z]\d{7}$/,
86
+ // KAZAKHSTAN
87
+ LI: /^[a-zA-Z]\d{5}$/,
88
+ // LIECHTENSTEIN
89
+ LT: /^[A-Z0-9]{8}$/,
90
+ // LITHUANIA
91
+ LU: /^[A-Z0-9]{8}$/,
92
+ // LUXEMBURG
93
+ LV: /^[A-Z0-9]{2}\d{7}$/,
94
+ // LATVIA
95
+ LY: /^[A-Z0-9]{8}$/,
96
+ // LIBYA
97
+ MT: /^\d{7}$/,
98
+ // MALTA
99
+ MZ: /^([A-Z]{2}\d{7})|(\d{2}[A-Z]{2}\d{5})$/,
100
+ // MOZAMBIQUE
101
+ MY: /^[AHK]\d{8}$/,
102
+ // MALAYSIA
103
+ MX: /^[A-Z]\d{8}$/,
104
+ // MEXICO
105
+ NL: /^[A-Z]{2}[A-Z0-9]{6}\d$/,
106
+ // NETHERLANDS
107
+ NZ: /^([Ll]([Aa]|[Dd]|[Ff]|[Hh])|[Ee]([Aa]|[Pp])|[Nn])\d{6}$/,
108
+ // NEW ZEALAND
109
+ PH: /^([A-Z](\d{6}|\d{7}[A-Z]))|([A-Z]{2}(\d{6}|\d{7}))$/,
110
+ // PHILIPPINES
111
+ PK: /^[A-Z]{2}\d{7}$/,
112
+ // PAKISTAN
113
+ PL: /^[A-Z]{2}\d{7}$/,
114
+ // POLAND
115
+ PT: /^[A-Z]\d{6}$/,
116
+ // PORTUGAL
117
+ RO: /^\d{8,9}$/,
118
+ // ROMANIA
119
+ RU: /^\d{9}$/,
120
+ // RUSSIAN FEDERATION
121
+ SE: /^\d{8}$/,
122
+ // SWEDEN
123
+ SL: /^(P)[A-Z]\d{7}$/,
124
+ // SLOVENIA
125
+ SK: /^[0-9A-Z]\d{7}$/,
126
+ // SLOVAKIA
127
+ TH: /^[A-Z]{1,2}\d{6,7}$/,
128
+ // THAILAND
129
+ TR: /^[A-Z]\d{8}$/,
130
+ // TURKEY
131
+ UA: /^[A-Z]{2}\d{6}$/,
132
+ // UKRAINE
133
+ US: /^\d{9}$|^[A-Z]\d{8}$/,
134
+ // UNITED STATES
135
+ ZA: /^[TAMD]\d{8}$/ // SOUTH AFRICA
136
+ };
137
+ var locales = exports.locales = Object.keys(passportRegexByCountryCode);
138
+
139
+ /**
140
+ * Check if str is a valid passport number
141
+ * relative to provided ISO Country Code.
142
+ *
143
+ * @param {string} str
144
+ * @param {string} countryCode
145
+ * @return {boolean}
146
+ */
147
+ function isPassportNumber(str, countryCode) {
148
+ (0, _assertString.default)(str);
149
+ /** Remove All Whitespaces, Convert to UPPERCASE */
150
+ var normalizedStr = str.replace(/\s/g, '').toUpperCase();
151
+ return countryCode.toUpperCase() in passportRegexByCountryCode && passportRegexByCountryCode[countryCode].test(normalizedStr);
152
+ }
package/lib/isPort.js ADDED
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isPort;
7
+ var _isInt = _interopRequireDefault(require("./isInt"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ function isPort(str) {
10
+ return (0, _isInt.default)(str, {
11
+ allow_leading_zeroes: false,
12
+ min: 0,
13
+ max: 65535
14
+ });
15
+ }
16
+ module.exports = exports.default;
17
+ module.exports.default = exports.default;
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isPostalCode;
7
+ exports.locales = void 0;
8
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ // common patterns
11
+ var threeDigit = /^\d{3}$/;
12
+ var fourDigit = /^\d{4}$/;
13
+ var fiveDigit = /^\d{5}$/;
14
+ var sixDigit = /^\d{6}$/;
15
+ var patterns = {
16
+ AD: /^AD\d{3}$/,
17
+ AT: fourDigit,
18
+ AU: fourDigit,
19
+ AZ: /^AZ\d{4}$/,
20
+ BA: /^([7-8]\d{4}$)/,
21
+ BD: /^([1-8][0-9]{3}|9[0-4][0-9]{2})$/,
22
+ BE: fourDigit,
23
+ BG: fourDigit,
24
+ BR: /^\d{5}-?\d{3}$/,
25
+ BY: /^2[1-4]\d{4}$/,
26
+ CA: /^[ABCEGHJKLMNPRSTVXY]\d[ABCEGHJ-NPRSTV-Z][\s\-]?\d[ABCEGHJ-NPRSTV-Z]\d$/i,
27
+ CH: fourDigit,
28
+ CN: /^(0[1-7]|1[012356]|2[0-7]|3[0-6]|4[0-7]|5[1-7]|6[1-7]|7[1-5]|8[1345]|9[09])\d{4}$/,
29
+ CO: /^(05|08|11|13|15|17|18|19|20|23|25|27|41|44|47|50|52|54|63|66|68|70|73|76|81|85|86|88|91|94|95|97|99)(\d{4})$/,
30
+ CZ: /^\d{3}\s?\d{2}$/,
31
+ DE: fiveDigit,
32
+ DK: fourDigit,
33
+ DO: fiveDigit,
34
+ DZ: fiveDigit,
35
+ EE: fiveDigit,
36
+ ES: /^(5[0-2]{1}|[0-4]{1}\d{1})\d{3}$/,
37
+ FI: fiveDigit,
38
+ FR: /^(?:(?:0[1-9]|[1-8]\d|9[0-5])\d{3}|97[1-46]\d{2})$/,
39
+ GB: /^(gir\s?0aa|[a-z]{1,2}\d[\da-z]?\s?(\d[a-z]{2})?)$/i,
40
+ GR: /^\d{3}\s?\d{2}$/,
41
+ HR: /^([1-5]\d{4}$)/,
42
+ HT: /^HT\d{4}$/,
43
+ HU: fourDigit,
44
+ ID: fiveDigit,
45
+ IE: /^(?!.*(?:o))[A-Za-z]\d[\dw]\s\w{4}$/i,
46
+ IL: /^(\d{5}|\d{7})$/,
47
+ IN: /^((?!10|29|35|54|55|65|66|86|87|88|89)[1-9][0-9]{5})$/,
48
+ IR: /^(?!(\d)\1{3})[13-9]{4}[1346-9][013-9]{5}$/,
49
+ IS: threeDigit,
50
+ IT: fiveDigit,
51
+ JP: /^\d{3}\-\d{4}$/,
52
+ KE: fiveDigit,
53
+ KR: /^(\d{5}|\d{6})$/,
54
+ LI: /^(948[5-9]|949[0-7])$/,
55
+ LT: /^LT\-\d{5}$/,
56
+ LU: fourDigit,
57
+ LV: /^LV\-\d{4}$/,
58
+ LK: fiveDigit,
59
+ MC: /^980\d{2}$/,
60
+ MG: threeDigit,
61
+ MX: fiveDigit,
62
+ MT: /^[A-Za-z]{3}\s{0,1}\d{4}$/,
63
+ MY: fiveDigit,
64
+ NL: /^[1-9]\d{3}\s?(?!sa|sd|ss)[a-z]{2}$/i,
65
+ NO: fourDigit,
66
+ NP: /^(10|21|22|32|33|34|44|45|56|57)\d{3}$|^(977)$/i,
67
+ NZ: fourDigit,
68
+ // https://www.pakpost.gov.pk/postcodes.php
69
+ PK: fiveDigit,
70
+ PL: /^\d{2}\-\d{3}$/,
71
+ PR: /^00[679]\d{2}([ -]\d{4})?$/,
72
+ PT: /^\d{4}\-\d{3}?$/,
73
+ RO: sixDigit,
74
+ RU: sixDigit,
75
+ SA: fiveDigit,
76
+ SE: /^[1-9]\d{2}\s?\d{2}$/,
77
+ SG: sixDigit,
78
+ SI: fourDigit,
79
+ SK: /^\d{3}\s?\d{2}$/,
80
+ TH: fiveDigit,
81
+ TN: fourDigit,
82
+ TW: /^\d{3}(\d{2,3})?$/,
83
+ UA: fiveDigit,
84
+ US: /^\d{5}(-\d{4})?$/,
85
+ ZA: fourDigit,
86
+ ZM: fiveDigit
87
+ };
88
+ var locales = exports.locales = Object.keys(patterns);
89
+ function isPostalCode(str, locale) {
90
+ (0, _assertString.default)(str);
91
+ if (locale in patterns) {
92
+ return patterns[locale].test(str);
93
+ } else if (locale === 'any') {
94
+ for (var key in patterns) {
95
+ // https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md#ignoring-code-for-coverage-purposes
96
+ // istanbul ignore else
97
+ if (patterns.hasOwnProperty(key)) {
98
+ var pattern = patterns[key];
99
+ if (pattern.test(str)) {
100
+ return true;
101
+ }
102
+ }
103
+ }
104
+ return false;
105
+ }
106
+ throw new Error("Invalid locale '".concat(locale, "'"));
107
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isRFC3339;
7
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ /* Based on https://tools.ietf.org/html/rfc3339#section-5.6 */
10
+
11
+ var dateFullYear = /[0-9]{4}/;
12
+ var dateMonth = /(0[1-9]|1[0-2])/;
13
+ var dateMDay = /([12]\d|0[1-9]|3[01])/;
14
+ var timeHour = /([01][0-9]|2[0-3])/;
15
+ var timeMinute = /[0-5][0-9]/;
16
+ var timeSecond = /([0-5][0-9]|60)/;
17
+ var timeSecFrac = /(\.[0-9]+)?/;
18
+ var timeNumOffset = new RegExp("[-+]".concat(timeHour.source, ":").concat(timeMinute.source));
19
+ var timeOffset = new RegExp("([zZ]|".concat(timeNumOffset.source, ")"));
20
+ var partialTime = new RegExp("".concat(timeHour.source, ":").concat(timeMinute.source, ":").concat(timeSecond.source).concat(timeSecFrac.source));
21
+ var fullDate = new RegExp("".concat(dateFullYear.source, "-").concat(dateMonth.source, "-").concat(dateMDay.source));
22
+ var fullTime = new RegExp("".concat(partialTime.source).concat(timeOffset.source));
23
+ var rfc3339 = new RegExp("^".concat(fullDate.source, "[ tT]").concat(fullTime.source, "$"));
24
+ function isRFC3339(str) {
25
+ (0, _assertString.default)(str);
26
+ return rfc3339.test(str);
27
+ }
28
+ module.exports = exports.default;
29
+ module.exports.default = exports.default;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isRgbColor;
7
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } /* eslint-disable prefer-rest-params */
10
+ var rgbColor = /^rgb\((([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]),){2}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\)$/;
11
+ var rgbaColor = /^rgba\((([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]),){3}(0?\.\d\d?|1(\.0)?|0(\.0)?)\)$/;
12
+ var rgbColorPercent = /^rgb\((([0-9]%|[1-9][0-9]%|100%),){2}([0-9]%|[1-9][0-9]%|100%)\)$/;
13
+ var rgbaColorPercent = /^rgba\((([0-9]%|[1-9][0-9]%|100%),){3}(0?\.\d\d?|1(\.0)?|0(\.0)?)\)$/;
14
+ var startsWithRgb = /^rgba?/;
15
+ function isRgbColor(str, options) {
16
+ (0, _assertString.default)(str);
17
+ // default options to true for percent and false for spaces
18
+ var allowSpaces = false;
19
+ var includePercentValues = true;
20
+ if (_typeof(options) !== 'object') {
21
+ if (arguments.length >= 2) {
22
+ includePercentValues = arguments[1];
23
+ }
24
+ } else {
25
+ allowSpaces = options.allowSpaces !== undefined ? options.allowSpaces : allowSpaces;
26
+ includePercentValues = options.includePercentValues !== undefined ? options.includePercentValues : includePercentValues;
27
+ }
28
+ if (allowSpaces) {
29
+ // make sure it starts with continuous rgba? without spaces before stripping
30
+ if (!startsWithRgb.test(str)) {
31
+ return false;
32
+ }
33
+ // strip all whitespace
34
+ str = str.replace(/\s/g, '');
35
+ }
36
+ if (!includePercentValues) {
37
+ return rgbColor.test(str) || rgbaColor.test(str);
38
+ }
39
+ return rgbColor.test(str) || rgbaColor.test(str) || rgbColorPercent.test(str) || rgbaColorPercent.test(str);
40
+ }
41
+ module.exports = exports.default;
42
+ module.exports.default = exports.default;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isSemVer;
7
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
8
+ var _multilineRegex = _interopRequireDefault(require("./util/multilineRegex"));
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ /**
11
+ * Regular Expression to match
12
+ * semantic versioning (SemVer)
13
+ * built from multi-line, multi-parts regexp
14
+ * Reference: https://semver.org/
15
+ */
16
+ var semanticVersioningRegex = (0, _multilineRegex.default)(['^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)', '(?:-((?:0|[1-9]\\d*|\\d*[a-z-][0-9a-z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-z-][0-9a-z-]*))*))', '?(?:\\+([0-9a-z-]+(?:\\.[0-9a-z-]+)*))?$'], 'i');
17
+ function isSemVer(str) {
18
+ (0, _assertString.default)(str);
19
+ return semanticVersioningRegex.test(str);
20
+ }
21
+ module.exports = exports.default;
22
+ module.exports.default = exports.default;