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,144 @@
1
+ import assertString from './util/assertString';
2
+
3
+ /**
4
+ * Reference:
5
+ * https://en.wikipedia.org/ -- Wikipedia
6
+ * https://docs.microsoft.com/en-us/microsoft-365/compliance/eu-passport-number -- EU Passport Number
7
+ * https://countrycode.org/ -- Country Codes
8
+ */
9
+ var passportRegexByCountryCode = {
10
+ AM: /^[A-Z]{2}\d{7}$/,
11
+ // ARMENIA
12
+ AR: /^[A-Z]{3}\d{6}$/,
13
+ // ARGENTINA
14
+ AT: /^[A-Z]\d{7}$/,
15
+ // AUSTRIA
16
+ AU: /^[A-Z]\d{7}$/,
17
+ // AUSTRALIA
18
+ AZ: /^[A-Z]{1}\d{8}$/,
19
+ // AZERBAIJAN
20
+ BE: /^[A-Z]{2}\d{6}$/,
21
+ // BELGIUM
22
+ BG: /^\d{9}$/,
23
+ // BULGARIA
24
+ BR: /^[A-Z]{2}\d{6}$/,
25
+ // BRAZIL
26
+ BY: /^[A-Z]{2}\d{7}$/,
27
+ // BELARUS
28
+ CA: /^[A-Z]{2}\d{6}$/,
29
+ // CANADA
30
+ CH: /^[A-Z]\d{7}$/,
31
+ // SWITZERLAND
32
+ CN: /^G\d{8}$|^E(?![IO])[A-Z0-9]\d{7}$/,
33
+ // CHINA [G=Ordinary, E=Electronic] followed by 8-digits, or E followed by any UPPERCASE letter (except I and O) followed by 7 digits
34
+ CY: /^[A-Z](\d{6}|\d{8})$/,
35
+ // CYPRUS
36
+ CZ: /^\d{8}$/,
37
+ // CZECH REPUBLIC
38
+ DE: /^[CFGHJKLMNPRTVWXYZ0-9]{9}$/,
39
+ // GERMANY
40
+ DK: /^\d{9}$/,
41
+ // DENMARK
42
+ DZ: /^\d{9}$/,
43
+ // ALGERIA
44
+ EE: /^([A-Z]\d{7}|[A-Z]{2}\d{7})$/,
45
+ // ESTONIA (K followed by 7-digits), e-passports have 2 UPPERCASE followed by 7 digits
46
+ ES: /^[A-Z0-9]{2}([A-Z0-9]?)\d{6}$/,
47
+ // SPAIN
48
+ FI: /^[A-Z]{2}\d{7}$/,
49
+ // FINLAND
50
+ FR: /^\d{2}[A-Z]{2}\d{5}$/,
51
+ // FRANCE
52
+ GB: /^\d{9}$/,
53
+ // UNITED KINGDOM
54
+ GR: /^[A-Z]{2}\d{7}$/,
55
+ // GREECE
56
+ HR: /^\d{9}$/,
57
+ // CROATIA
58
+ HU: /^[A-Z]{2}(\d{6}|\d{7})$/,
59
+ // HUNGARY
60
+ IE: /^[A-Z0-9]{2}\d{7}$/,
61
+ // IRELAND
62
+ IN: /^[A-Z]{1}-?\d{7}$/,
63
+ // INDIA
64
+ ID: /^[A-C]\d{7}$/,
65
+ // INDONESIA
66
+ IR: /^[A-Z]\d{8}$/,
67
+ // IRAN
68
+ IS: /^(A)\d{7}$/,
69
+ // ICELAND
70
+ IT: /^[A-Z0-9]{2}\d{7}$/,
71
+ // ITALY
72
+ JM: /^[Aa]\d{7}$/,
73
+ // JAMAICA
74
+ JP: /^[A-Z]{2}\d{7}$/,
75
+ // JAPAN
76
+ KR: /^[MS]\d{8}$/,
77
+ // SOUTH KOREA, REPUBLIC OF KOREA, [S=PS Passports, M=PM Passports]
78
+ KZ: /^[a-zA-Z]\d{7}$/,
79
+ // KAZAKHSTAN
80
+ LI: /^[a-zA-Z]\d{5}$/,
81
+ // LIECHTENSTEIN
82
+ LT: /^[A-Z0-9]{8}$/,
83
+ // LITHUANIA
84
+ LU: /^[A-Z0-9]{8}$/,
85
+ // LUXEMBURG
86
+ LV: /^[A-Z0-9]{2}\d{7}$/,
87
+ // LATVIA
88
+ LY: /^[A-Z0-9]{8}$/,
89
+ // LIBYA
90
+ MT: /^\d{7}$/,
91
+ // MALTA
92
+ MZ: /^([A-Z]{2}\d{7})|(\d{2}[A-Z]{2}\d{5})$/,
93
+ // MOZAMBIQUE
94
+ MY: /^[AHK]\d{8}$/,
95
+ // MALAYSIA
96
+ MX: /^\d{10,11}$/,
97
+ // MEXICO
98
+ NL: /^[A-Z]{2}[A-Z0-9]{6}\d$/,
99
+ // NETHERLANDS
100
+ NZ: /^([Ll]([Aa]|[Dd]|[Ff]|[Hh])|[Ee]([Aa]|[Pp])|[Nn])\d{6}$/,
101
+ // NEW ZEALAND
102
+ PH: /^([A-Z](\d{6}|\d{7}[A-Z]))|([A-Z]{2}(\d{6}|\d{7}))$/,
103
+ // PHILIPPINES
104
+ PK: /^[A-Z]{2}\d{7}$/,
105
+ // PAKISTAN
106
+ PL: /^[A-Z]{2}\d{7}$/,
107
+ // POLAND
108
+ PT: /^[A-Z]\d{6}$/,
109
+ // PORTUGAL
110
+ RO: /^\d{8,9}$/,
111
+ // ROMANIA
112
+ RU: /^\d{9}$/,
113
+ // RUSSIAN FEDERATION
114
+ SE: /^\d{8}$/,
115
+ // SWEDEN
116
+ SL: /^(P)[A-Z]\d{7}$/,
117
+ // SLOVENIA
118
+ SK: /^[0-9A-Z]\d{7}$/,
119
+ // SLOVAKIA
120
+ TH: /^[A-Z]{1,2}\d{6,7}$/,
121
+ // THAILAND
122
+ TR: /^[A-Z]\d{8}$/,
123
+ // TURKEY
124
+ UA: /^[A-Z]{2}\d{6}$/,
125
+ // UKRAINE
126
+ US: /^\d{9}$/,
127
+ // UNITED STATES
128
+ ZA: /^[TAMD]\d{8}$/ // SOUTH AFRICA
129
+ };
130
+
131
+ /**
132
+ * Check if str is a valid passport number
133
+ * relative to provided ISO Country Code.
134
+ *
135
+ * @param {string} str
136
+ * @param {string} countryCode
137
+ * @return {boolean}
138
+ */
139
+ export default function isPassportNumber(str, countryCode) {
140
+ assertString(str);
141
+ /** Remove All Whitespaces, Convert to UPPERCASE */
142
+ var normalizedStr = str.replace(/\s/g, '').toUpperCase();
143
+ return countryCode.toUpperCase() in passportRegexByCountryCode && passportRegexByCountryCode[countryCode].test(normalizedStr);
144
+ }
@@ -0,0 +1,8 @@
1
+ import isInt from './isInt';
2
+ export default function isPort(str) {
3
+ return isInt(str, {
4
+ allow_leading_zeroes: false,
5
+ min: 0,
6
+ max: 65535
7
+ });
8
+ }
@@ -0,0 +1,95 @@
1
+ import assertString from './util/assertString';
2
+
3
+ // common patterns
4
+ var threeDigit = /^\d{3}$/;
5
+ var fourDigit = /^\d{4}$/;
6
+ var fiveDigit = /^\d{5}$/;
7
+ var sixDigit = /^\d{6}$/;
8
+ var patterns = {
9
+ AD: /^AD\d{3}$/,
10
+ AT: fourDigit,
11
+ AU: fourDigit,
12
+ AZ: /^AZ\d{4}$/,
13
+ BA: /^([7-8]\d{4}$)/,
14
+ BE: fourDigit,
15
+ BG: fourDigit,
16
+ BR: /^\d{5}-\d{3}$/,
17
+ BY: /^2[1-4]\d{4}$/,
18
+ CA: /^[ABCEGHJKLMNPRSTVXY]\d[ABCEGHJ-NPRSTV-Z][\s\-]?\d[ABCEGHJ-NPRSTV-Z]\d$/i,
19
+ CH: fourDigit,
20
+ 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}$/,
21
+ CZ: /^\d{3}\s?\d{2}$/,
22
+ DE: fiveDigit,
23
+ DK: fourDigit,
24
+ DO: fiveDigit,
25
+ DZ: fiveDigit,
26
+ EE: fiveDigit,
27
+ ES: /^(5[0-2]{1}|[0-4]{1}\d{1})\d{3}$/,
28
+ FI: fiveDigit,
29
+ FR: /^\d{2}\s?\d{3}$/,
30
+ GB: /^(gir\s?0aa|[a-z]{1,2}\d[\da-z]?\s?(\d[a-z]{2})?)$/i,
31
+ GR: /^\d{3}\s?\d{2}$/,
32
+ HR: /^([1-5]\d{4}$)/,
33
+ HT: /^HT\d{4}$/,
34
+ HU: fourDigit,
35
+ ID: fiveDigit,
36
+ IE: /^(?!.*(?:o))[A-Za-z]\d[\dw]\s\w{4}$/i,
37
+ IL: /^(\d{5}|\d{7})$/,
38
+ IN: /^((?!10|29|35|54|55|65|66|86|87|88|89)[1-9][0-9]{5})$/,
39
+ IR: /^(?!(\d)\1{3})[13-9]{4}[1346-9][013-9]{5}$/,
40
+ IS: threeDigit,
41
+ IT: fiveDigit,
42
+ JP: /^\d{3}\-\d{4}$/,
43
+ KE: fiveDigit,
44
+ KR: /^(\d{5}|\d{6})$/,
45
+ LI: /^(948[5-9]|949[0-7])$/,
46
+ LT: /^LT\-\d{5}$/,
47
+ LU: fourDigit,
48
+ LV: /^LV\-\d{4}$/,
49
+ LK: fiveDigit,
50
+ MG: threeDigit,
51
+ MX: fiveDigit,
52
+ MT: /^[A-Za-z]{3}\s{0,1}\d{4}$/,
53
+ MY: fiveDigit,
54
+ NL: /^[1-9]\d{3}\s?(?!sa|sd|ss)[a-z]{2}$/i,
55
+ NO: fourDigit,
56
+ NP: /^(10|21|22|32|33|34|44|45|56|57)\d{3}$|^(977)$/i,
57
+ NZ: fourDigit,
58
+ PL: /^\d{2}\-\d{3}$/,
59
+ PR: /^00[679]\d{2}([ -]\d{4})?$/,
60
+ PT: /^\d{4}\-\d{3}?$/,
61
+ RO: sixDigit,
62
+ RU: sixDigit,
63
+ SA: fiveDigit,
64
+ SE: /^[1-9]\d{2}\s?\d{2}$/,
65
+ SG: sixDigit,
66
+ SI: fourDigit,
67
+ SK: /^\d{3}\s?\d{2}$/,
68
+ TH: fiveDigit,
69
+ TN: fourDigit,
70
+ TW: /^\d{3}(\d{2})?$/,
71
+ UA: fiveDigit,
72
+ US: /^\d{5}(-\d{4})?$/,
73
+ ZA: fourDigit,
74
+ ZM: fiveDigit
75
+ };
76
+ export var locales = Object.keys(patterns);
77
+ export default function isPostalCode(str, locale) {
78
+ assertString(str);
79
+ if (locale in patterns) {
80
+ return patterns[locale].test(str);
81
+ } else if (locale === 'any') {
82
+ for (var key in patterns) {
83
+ // https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md#ignoring-code-for-coverage-purposes
84
+ // istanbul ignore else
85
+ if (patterns.hasOwnProperty(key)) {
86
+ var pattern = patterns[key];
87
+ if (pattern.test(str)) {
88
+ return true;
89
+ }
90
+ }
91
+ }
92
+ return false;
93
+ }
94
+ throw new Error("Invalid locale '".concat(locale, "'"));
95
+ }
@@ -0,0 +1,21 @@
1
+ import assertString from './util/assertString';
2
+
3
+ /* Based on https://tools.ietf.org/html/rfc3339#section-5.6 */
4
+
5
+ var dateFullYear = /[0-9]{4}/;
6
+ var dateMonth = /(0[1-9]|1[0-2])/;
7
+ var dateMDay = /([12]\d|0[1-9]|3[01])/;
8
+ var timeHour = /([01][0-9]|2[0-3])/;
9
+ var timeMinute = /[0-5][0-9]/;
10
+ var timeSecond = /([0-5][0-9]|60)/;
11
+ var timeSecFrac = /(\.[0-9]+)?/;
12
+ var timeNumOffset = new RegExp("[-+]".concat(timeHour.source, ":").concat(timeMinute.source));
13
+ var timeOffset = new RegExp("([zZ]|".concat(timeNumOffset.source, ")"));
14
+ var partialTime = new RegExp("".concat(timeHour.source, ":").concat(timeMinute.source, ":").concat(timeSecond.source).concat(timeSecFrac.source));
15
+ var fullDate = new RegExp("".concat(dateFullYear.source, "-").concat(dateMonth.source, "-").concat(dateMDay.source));
16
+ var fullTime = new RegExp("".concat(partialTime.source).concat(timeOffset.source));
17
+ var rfc3339 = new RegExp("^".concat(fullDate.source, "[ tT]").concat(fullTime.source, "$"));
18
+ export default function isRFC3339(str) {
19
+ assertString(str);
20
+ return rfc3339.test(str);
21
+ }
@@ -0,0 +1,13 @@
1
+ import assertString from './util/assertString';
2
+ 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])\)$/;
3
+ 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|1(\.0)?|0(\.0)?)\)$/;
4
+ var rgbColorPercent = /^rgb\((([0-9]%|[1-9][0-9]%|100%),){2}([0-9]%|[1-9][0-9]%|100%)\)$/;
5
+ var rgbaColorPercent = /^rgba\((([0-9]%|[1-9][0-9]%|100%),){3}(0?\.\d|1(\.0)?|0(\.0)?)\)$/;
6
+ export default function isRgbColor(str) {
7
+ var includePercentValues = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
8
+ assertString(str);
9
+ if (!includePercentValues) {
10
+ return rgbColor.test(str) || rgbaColor.test(str);
11
+ }
12
+ return rgbColor.test(str) || rgbaColor.test(str) || rgbColorPercent.test(str) || rgbaColorPercent.test(str);
13
+ }
@@ -0,0 +1,14 @@
1
+ import assertString from './util/assertString';
2
+ import multilineRegexp from './util/multilineRegex';
3
+
4
+ /**
5
+ * Regular Expression to match
6
+ * semantic versioning (SemVer)
7
+ * built from multi-line, multi-parts regexp
8
+ * Reference: https://semver.org/
9
+ */
10
+ var semanticVersioningRegex = multilineRegexp(['^(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');
11
+ export default function isSemVer(str) {
12
+ assertString(str);
13
+ return semanticVersioningRegex.test(str);
14
+ }
@@ -0,0 +1,6 @@
1
+ import assertString from './util/assertString';
2
+ var charsetRegex = /^[^\s-_](?!.*?[-_]{2,})[a-z0-9-\\][^\s]*[^-_\s]$/;
3
+ export default function isSlug(str) {
4
+ assertString(str);
5
+ return charsetRegex.test(str);
6
+ }
@@ -0,0 +1,90 @@
1
+ import merge from './util/merge';
2
+ import assertString from './util/assertString';
3
+ var upperCaseRegex = /^[A-Z]$/;
4
+ var lowerCaseRegex = /^[a-z]$/;
5
+ var numberRegex = /^[0-9]$/;
6
+ var symbolRegex = /^[-#!$@£%^&*()_+|~=`{}\[\]:";'<>?,.\/\\ ]$/;
7
+ var defaultOptions = {
8
+ minLength: 8,
9
+ minLowercase: 1,
10
+ minUppercase: 1,
11
+ minNumbers: 1,
12
+ minSymbols: 1,
13
+ returnScore: false,
14
+ pointsPerUnique: 1,
15
+ pointsPerRepeat: 0.5,
16
+ pointsForContainingLower: 10,
17
+ pointsForContainingUpper: 10,
18
+ pointsForContainingNumber: 10,
19
+ pointsForContainingSymbol: 10
20
+ };
21
+
22
+ /* Counts number of occurrences of each char in a string
23
+ * could be moved to util/ ?
24
+ */
25
+ function countChars(str) {
26
+ var result = {};
27
+ Array.from(str).forEach(function (_char) {
28
+ var curVal = result[_char];
29
+ if (curVal) {
30
+ result[_char] += 1;
31
+ } else {
32
+ result[_char] = 1;
33
+ }
34
+ });
35
+ return result;
36
+ }
37
+
38
+ /* Return information about a password */
39
+ function analyzePassword(password) {
40
+ var charMap = countChars(password);
41
+ var analysis = {
42
+ length: password.length,
43
+ uniqueChars: Object.keys(charMap).length,
44
+ uppercaseCount: 0,
45
+ lowercaseCount: 0,
46
+ numberCount: 0,
47
+ symbolCount: 0
48
+ };
49
+ Object.keys(charMap).forEach(function (_char2) {
50
+ /* istanbul ignore else */
51
+ if (upperCaseRegex.test(_char2)) {
52
+ analysis.uppercaseCount += charMap[_char2];
53
+ } else if (lowerCaseRegex.test(_char2)) {
54
+ analysis.lowercaseCount += charMap[_char2];
55
+ } else if (numberRegex.test(_char2)) {
56
+ analysis.numberCount += charMap[_char2];
57
+ } else if (symbolRegex.test(_char2)) {
58
+ analysis.symbolCount += charMap[_char2];
59
+ }
60
+ });
61
+ return analysis;
62
+ }
63
+ function scorePassword(analysis, scoringOptions) {
64
+ var points = 0;
65
+ points += analysis.uniqueChars * scoringOptions.pointsPerUnique;
66
+ points += (analysis.length - analysis.uniqueChars) * scoringOptions.pointsPerRepeat;
67
+ if (analysis.lowercaseCount > 0) {
68
+ points += scoringOptions.pointsForContainingLower;
69
+ }
70
+ if (analysis.uppercaseCount > 0) {
71
+ points += scoringOptions.pointsForContainingUpper;
72
+ }
73
+ if (analysis.numberCount > 0) {
74
+ points += scoringOptions.pointsForContainingNumber;
75
+ }
76
+ if (analysis.symbolCount > 0) {
77
+ points += scoringOptions.pointsForContainingSymbol;
78
+ }
79
+ return points;
80
+ }
81
+ export default function isStrongPassword(str) {
82
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
83
+ assertString(str);
84
+ var analysis = analyzePassword(str);
85
+ options = merge(options || {}, defaultOptions);
86
+ if (options.returnScore) {
87
+ return scorePassword(analysis, options);
88
+ }
89
+ return analysis.length >= options.minLength && analysis.lowercaseCount >= options.minLowercase && analysis.uppercaseCount >= options.minUppercase && analysis.numberCount >= options.minNumbers && analysis.symbolCount >= options.minSymbols;
90
+ }
@@ -0,0 +1,6 @@
1
+ import assertString from './util/assertString';
2
+ var surrogatePair = /[\uD800-\uDBFF][\uDC00-\uDFFF]/;
3
+ export default function isSurrogatePair(str) {
4
+ assertString(str);
5
+ return surrogatePair.test(str);
6
+ }