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,415 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isIdentityCard;
7
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
8
+ var _isInt = _interopRequireDefault(require("./isInt"));
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ var validators = {
11
+ PL: function PL(str) {
12
+ (0, _assertString.default)(str);
13
+ var weightOfDigits = {
14
+ 1: 1,
15
+ 2: 3,
16
+ 3: 7,
17
+ 4: 9,
18
+ 5: 1,
19
+ 6: 3,
20
+ 7: 7,
21
+ 8: 9,
22
+ 9: 1,
23
+ 10: 3,
24
+ 11: 0
25
+ };
26
+ if (str != null && str.length === 11 && (0, _isInt.default)(str, {
27
+ allow_leading_zeroes: true
28
+ })) {
29
+ var digits = str.split('').slice(0, -1);
30
+ var sum = digits.reduce(function (acc, digit, index) {
31
+ return acc + Number(digit) * weightOfDigits[index + 1];
32
+ }, 0);
33
+ var modulo = sum % 10;
34
+ var lastDigit = Number(str.charAt(str.length - 1));
35
+ if (modulo === 0 && lastDigit === 0 || lastDigit === 10 - modulo) {
36
+ return true;
37
+ }
38
+ }
39
+ return false;
40
+ },
41
+ ES: function ES(str) {
42
+ (0, _assertString.default)(str);
43
+ var DNI = /^[0-9X-Z][0-9]{7}[TRWAGMYFPDXBNJZSQVHLCKE]$/;
44
+ var charsValue = {
45
+ X: 0,
46
+ Y: 1,
47
+ Z: 2
48
+ };
49
+ var controlDigits = ['T', 'R', 'W', 'A', 'G', 'M', 'Y', 'F', 'P', 'D', 'X', 'B', 'N', 'J', 'Z', 'S', 'Q', 'V', 'H', 'L', 'C', 'K', 'E'];
50
+
51
+ // sanitize user input
52
+ var sanitized = str.trim().toUpperCase();
53
+
54
+ // validate the data structure
55
+ if (!DNI.test(sanitized)) {
56
+ return false;
57
+ }
58
+
59
+ // validate the control digit
60
+ var number = sanitized.slice(0, -1).replace(/[X,Y,Z]/g, function (char) {
61
+ return charsValue[char];
62
+ });
63
+ return sanitized.endsWith(controlDigits[number % 23]);
64
+ },
65
+ FI: function FI(str) {
66
+ // https://dvv.fi/en/personal-identity-code#:~:text=control%20character%20for%20a-,personal,-identity%20code%20calculated
67
+ (0, _assertString.default)(str);
68
+ if (str.length !== 11) {
69
+ return false;
70
+ }
71
+ if (!str.match(/^\d{6}[\-A\+]\d{3}[0-9ABCDEFHJKLMNPRSTUVWXY]{1}$/)) {
72
+ return false;
73
+ }
74
+ var checkDigits = '0123456789ABCDEFHJKLMNPRSTUVWXY';
75
+ var idAsNumber = parseInt(str.slice(0, 6), 10) * 1000 + parseInt(str.slice(7, 10), 10);
76
+ var remainder = idAsNumber % 31;
77
+ var checkDigit = checkDigits[remainder];
78
+ return checkDigit === str.slice(10, 11);
79
+ },
80
+ IN: function IN(str) {
81
+ var DNI = /^[1-9]\d{3}\s?\d{4}\s?\d{4}$/;
82
+
83
+ // multiplication table
84
+ var d = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 0, 6, 7, 8, 9, 5], [2, 3, 4, 0, 1, 7, 8, 9, 5, 6], [3, 4, 0, 1, 2, 8, 9, 5, 6, 7], [4, 0, 1, 2, 3, 9, 5, 6, 7, 8], [5, 9, 8, 7, 6, 0, 4, 3, 2, 1], [6, 5, 9, 8, 7, 1, 0, 4, 3, 2], [7, 6, 5, 9, 8, 2, 1, 0, 4, 3], [8, 7, 6, 5, 9, 3, 2, 1, 0, 4], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]];
85
+
86
+ // permutation table
87
+ var p = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 5, 7, 6, 2, 8, 3, 0, 9, 4], [5, 8, 0, 3, 7, 9, 6, 1, 4, 2], [8, 9, 1, 6, 0, 4, 3, 5, 2, 7], [9, 4, 5, 3, 1, 2, 6, 8, 7, 0], [4, 2, 8, 6, 5, 7, 3, 9, 0, 1], [2, 7, 9, 3, 8, 0, 6, 4, 1, 5], [7, 0, 4, 6, 9, 1, 3, 2, 5, 8]];
88
+
89
+ // sanitize user input
90
+ var sanitized = str.trim();
91
+
92
+ // validate the data structure
93
+ if (!DNI.test(sanitized)) {
94
+ return false;
95
+ }
96
+ var c = 0;
97
+ var invertedArray = sanitized.replace(/\s/g, '').split('').map(Number).reverse();
98
+ invertedArray.forEach(function (val, i) {
99
+ c = d[c][p[i % 8][val]];
100
+ });
101
+ return c === 0;
102
+ },
103
+ IR: function IR(str) {
104
+ if (!str.match(/^\d{10}$/)) return false;
105
+ str = "0000".concat(str).slice(str.length - 6);
106
+ if (parseInt(str.slice(3, 9), 10) === 0) return false;
107
+ var lastNumber = parseInt(str.slice(9, 10), 10);
108
+ var sum = 0;
109
+ for (var i = 0; i < 9; i++) {
110
+ sum += parseInt(str.slice(i, i + 1), 10) * (10 - i);
111
+ }
112
+ sum %= 11;
113
+ return sum < 2 && lastNumber === sum || sum >= 2 && lastNumber === 11 - sum;
114
+ },
115
+ IT: function IT(str) {
116
+ if (str.length !== 9) return false;
117
+ if (str === 'CA00000AA') return false; // https://it.wikipedia.org/wiki/Carta_d%27identit%C3%A0_elettronica_italiana
118
+ return str.search(/C[A-Z]\d{5}[A-Z]{2}/i) > -1;
119
+ },
120
+ NO: function NO(str) {
121
+ var sanitized = str.trim();
122
+ if (isNaN(Number(sanitized))) return false;
123
+ if (sanitized.length !== 11) return false;
124
+ if (sanitized === '00000000000') return false;
125
+
126
+ // https://no.wikipedia.org/wiki/F%C3%B8dselsnummer
127
+ var f = sanitized.split('').map(Number);
128
+ var k1 = (11 - (3 * f[0] + 7 * f[1] + 6 * f[2] + 1 * f[3] + 8 * f[4] + 9 * f[5] + 4 * f[6] + 5 * f[7] + 2 * f[8]) % 11) % 11;
129
+ var k2 = (11 - (5 * f[0] + 4 * f[1] + 3 * f[2] + 2 * f[3] + 7 * f[4] + 6 * f[5] + 5 * f[6] + 4 * f[7] + 3 * f[8] + 2 * k1) % 11) % 11;
130
+ if (k1 !== f[9] || k2 !== f[10]) return false;
131
+ return true;
132
+ },
133
+ TH: function TH(str) {
134
+ if (!str.match(/^[1-8]\d{12}$/)) return false;
135
+
136
+ // validate check digit
137
+ var sum = 0;
138
+ for (var i = 0; i < 12; i++) {
139
+ sum += parseInt(str[i], 10) * (13 - i);
140
+ }
141
+ return str[12] === ((11 - sum % 11) % 10).toString();
142
+ },
143
+ LK: function LK(str) {
144
+ var old_nic = /^[1-9]\d{8}[vx]$/i;
145
+ var new_nic = /^[1-9]\d{11}$/i;
146
+ if (str.length === 10 && old_nic.test(str)) return true;else if (str.length === 12 && new_nic.test(str)) return true;
147
+ return false;
148
+ },
149
+ 'he-IL': function heIL(str) {
150
+ var DNI = /^\d{9}$/;
151
+
152
+ // sanitize user input
153
+ var sanitized = str.trim();
154
+
155
+ // validate the data structure
156
+ if (!DNI.test(sanitized)) {
157
+ return false;
158
+ }
159
+ var id = sanitized;
160
+ var sum = 0,
161
+ incNum;
162
+ for (var i = 0; i < id.length; i++) {
163
+ incNum = Number(id[i]) * (i % 2 + 1); // Multiply number by 1 or 2
164
+ sum += incNum > 9 ? incNum - 9 : incNum; // Sum the digits up and add to total
165
+ }
166
+ return sum % 10 === 0;
167
+ },
168
+ 'ar-LY': function arLY(str) {
169
+ // Libya National Identity Number NIN is 12 digits, the first digit is either 1 or 2
170
+ var NIN = /^(1|2)\d{11}$/;
171
+
172
+ // sanitize user input
173
+ var sanitized = str.trim();
174
+
175
+ // validate the data structure
176
+ if (!NIN.test(sanitized)) {
177
+ return false;
178
+ }
179
+ return true;
180
+ },
181
+ 'ar-TN': function arTN(str) {
182
+ var DNI = /^\d{8}$/;
183
+
184
+ // sanitize user input
185
+ var sanitized = str.trim();
186
+
187
+ // validate the data structure
188
+ if (!DNI.test(sanitized)) {
189
+ return false;
190
+ }
191
+ return true;
192
+ },
193
+ 'zh-CN': function zhCN(str) {
194
+ var provincesAndCities = ['11',
195
+ // 北京
196
+ '12',
197
+ // 天津
198
+ '13',
199
+ // 河北
200
+ '14',
201
+ // 山西
202
+ '15',
203
+ // 内蒙古
204
+ '21',
205
+ // 辽宁
206
+ '22',
207
+ // 吉林
208
+ '23',
209
+ // 黑龙江
210
+ '31',
211
+ // 上海
212
+ '32',
213
+ // 江苏
214
+ '33',
215
+ // 浙江
216
+ '34',
217
+ // 安徽
218
+ '35',
219
+ // 福建
220
+ '36',
221
+ // 江西
222
+ '37',
223
+ // 山东
224
+ '41',
225
+ // 河南
226
+ '42',
227
+ // 湖北
228
+ '43',
229
+ // 湖南
230
+ '44',
231
+ // 广东
232
+ '45',
233
+ // 广西
234
+ '46',
235
+ // 海南
236
+ '50',
237
+ // 重庆
238
+ '51',
239
+ // 四川
240
+ '52',
241
+ // 贵州
242
+ '53',
243
+ // 云南
244
+ '54',
245
+ // 西藏
246
+ '61',
247
+ // 陕西
248
+ '62',
249
+ // 甘肃
250
+ '63',
251
+ // 青海
252
+ '64',
253
+ // 宁夏
254
+ '65',
255
+ // 新疆
256
+ '71',
257
+ // 台湾
258
+ '81',
259
+ // 香港
260
+ '82',
261
+ // 澳门
262
+ '91' // 国外
263
+ ];
264
+ var powers = ['7', '9', '10', '5', '8', '4', '2', '1', '6', '3', '7', '9', '10', '5', '8', '4', '2'];
265
+ var parityBit = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'];
266
+ var checkAddressCode = function checkAddressCode(addressCode) {
267
+ return provincesAndCities.includes(addressCode);
268
+ };
269
+ var checkBirthDayCode = function checkBirthDayCode(birDayCode) {
270
+ var yyyy = parseInt(birDayCode.substring(0, 4), 10);
271
+ var mm = parseInt(birDayCode.substring(4, 6), 10);
272
+ var dd = parseInt(birDayCode.substring(6), 10);
273
+ var xdata = new Date(yyyy, mm - 1, dd);
274
+ if (xdata > new Date()) {
275
+ return false;
276
+ // eslint-disable-next-line max-len
277
+ } else if (xdata.getFullYear() === yyyy && xdata.getMonth() === mm - 1 && xdata.getDate() === dd) {
278
+ return true;
279
+ }
280
+ return false;
281
+ };
282
+ var getParityBit = function getParityBit(idCardNo) {
283
+ var id17 = idCardNo.substring(0, 17);
284
+ var power = 0;
285
+ for (var i = 0; i < 17; i++) {
286
+ power += parseInt(id17.charAt(i), 10) * parseInt(powers[i], 10);
287
+ }
288
+ var mod = power % 11;
289
+ return parityBit[mod];
290
+ };
291
+ var checkParityBit = function checkParityBit(idCardNo) {
292
+ return getParityBit(idCardNo) === idCardNo.charAt(17).toUpperCase();
293
+ };
294
+ var check15IdCardNo = function check15IdCardNo(idCardNo) {
295
+ var check = /^[1-9]\d{7}((0[1-9])|(1[0-2]))((0[1-9])|([1-2][0-9])|(3[0-1]))\d{3}$/.test(idCardNo);
296
+ if (!check) return false;
297
+ var addressCode = idCardNo.substring(0, 2);
298
+ check = checkAddressCode(addressCode);
299
+ if (!check) return false;
300
+ var birDayCode = "19".concat(idCardNo.substring(6, 12));
301
+ check = checkBirthDayCode(birDayCode);
302
+ if (!check) return false;
303
+ return true;
304
+ };
305
+ var check18IdCardNo = function check18IdCardNo(idCardNo) {
306
+ var check = /^[1-9]\d{5}[1-9]\d{3}((0[1-9])|(1[0-2]))((0[1-9])|([1-2][0-9])|(3[0-1]))\d{3}(\d|x|X)$/.test(idCardNo);
307
+ if (!check) return false;
308
+ var addressCode = idCardNo.substring(0, 2);
309
+ check = checkAddressCode(addressCode);
310
+ if (!check) return false;
311
+ var birDayCode = idCardNo.substring(6, 14);
312
+ check = checkBirthDayCode(birDayCode);
313
+ if (!check) return false;
314
+ return checkParityBit(idCardNo);
315
+ };
316
+ var checkIdCardNo = function checkIdCardNo(idCardNo) {
317
+ var check = /^\d{15}|(\d{17}(\d|x|X))$/.test(idCardNo);
318
+ if (!check) return false;
319
+ if (idCardNo.length === 15) {
320
+ return check15IdCardNo(idCardNo);
321
+ }
322
+ return check18IdCardNo(idCardNo);
323
+ };
324
+ return checkIdCardNo(str);
325
+ },
326
+ 'zh-HK': function zhHK(str) {
327
+ // sanitize user input
328
+ str = str.trim();
329
+
330
+ // HKID number starts with 1 or 2 letters, followed by 6 digits,
331
+ // then a checksum contained in square / round brackets or nothing
332
+ var regexHKID = /^[A-Z]{1,2}[0-9]{6}((\([0-9A]\))|(\[[0-9A]\])|([0-9A]))$/;
333
+ var regexIsDigit = /^[0-9]$/;
334
+
335
+ // convert the user input to all uppercase and apply regex
336
+ str = str.toUpperCase();
337
+ if (!regexHKID.test(str)) return false;
338
+ str = str.replace(/\[|\]|\(|\)/g, '');
339
+ if (str.length === 8) str = "3".concat(str);
340
+ var checkSumVal = 0;
341
+ for (var i = 0; i <= 7; i++) {
342
+ var convertedChar = void 0;
343
+ if (!regexIsDigit.test(str[i])) convertedChar = (str[i].charCodeAt(0) - 55) % 11;else convertedChar = str[i];
344
+ checkSumVal += convertedChar * (9 - i);
345
+ }
346
+ checkSumVal %= 11;
347
+ var checkSumConverted;
348
+ if (checkSumVal === 0) checkSumConverted = '0';else if (checkSumVal === 1) checkSumConverted = 'A';else checkSumConverted = String(11 - checkSumVal);
349
+ if (checkSumConverted === str[str.length - 1]) return true;
350
+ return false;
351
+ },
352
+ 'zh-TW': function zhTW(str) {
353
+ var ALPHABET_CODES = {
354
+ A: 10,
355
+ B: 11,
356
+ C: 12,
357
+ D: 13,
358
+ E: 14,
359
+ F: 15,
360
+ G: 16,
361
+ H: 17,
362
+ I: 34,
363
+ J: 18,
364
+ K: 19,
365
+ L: 20,
366
+ M: 21,
367
+ N: 22,
368
+ O: 35,
369
+ P: 23,
370
+ Q: 24,
371
+ R: 25,
372
+ S: 26,
373
+ T: 27,
374
+ U: 28,
375
+ V: 29,
376
+ W: 32,
377
+ X: 30,
378
+ Y: 31,
379
+ Z: 33
380
+ };
381
+ var sanitized = str.trim().toUpperCase();
382
+ if (!/^[A-Z][0-9]{9}$/.test(sanitized)) return false;
383
+ return Array.from(sanitized).reduce(function (sum, number, index) {
384
+ if (index === 0) {
385
+ var code = ALPHABET_CODES[number];
386
+ return code % 10 * 9 + Math.floor(code / 10);
387
+ }
388
+ if (index === 9) {
389
+ return (10 - sum % 10 - Number(number)) % 10 === 0;
390
+ }
391
+ return sum + Number(number) * (9 - index);
392
+ }, 0);
393
+ }
394
+ };
395
+ function isIdentityCard(str, locale) {
396
+ (0, _assertString.default)(str);
397
+ if (locale in validators) {
398
+ return validators[locale](str);
399
+ } else if (locale === 'any') {
400
+ for (var key in validators) {
401
+ // https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md#ignoring-code-for-coverage-purposes
402
+ // istanbul ignore else
403
+ if (validators.hasOwnProperty(key)) {
404
+ var validator = validators[key];
405
+ if (validator(str)) {
406
+ return true;
407
+ }
408
+ }
409
+ }
410
+ return false;
411
+ }
412
+ throw new Error("Invalid locale '".concat(locale, "'"));
413
+ }
414
+ module.exports = exports.default;
415
+ module.exports.default = exports.default;
package/lib/isIn.js ADDED
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isIn;
7
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
8
+ var _toString = _interopRequireDefault(require("./util/toString"));
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ 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); }
11
+ function isIn(str, options) {
12
+ (0, _assertString.default)(str);
13
+ var i;
14
+ if (Object.prototype.toString.call(options) === '[object Array]') {
15
+ var array = [];
16
+ for (i in options) {
17
+ // https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md#ignoring-code-for-coverage-purposes
18
+ // istanbul ignore else
19
+ if ({}.hasOwnProperty.call(options, i)) {
20
+ array[i] = (0, _toString.default)(options[i]);
21
+ }
22
+ }
23
+ return array.indexOf(str) >= 0;
24
+ } else if (_typeof(options) === 'object') {
25
+ return options.hasOwnProperty(str);
26
+ } else if (options && typeof options.indexOf === 'function') {
27
+ return options.indexOf(str) >= 0;
28
+ }
29
+ return false;
30
+ }
31
+ module.exports = exports.default;
32
+ module.exports.default = exports.default;
package/lib/isInt.js ADDED
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isInt;
7
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ var int = /^(?:[-+]?(?:0|[1-9][0-9]*))$/;
10
+ var intLeadingZeroes = /^[-+]?[0-9]+$/;
11
+ function isInt(str, options) {
12
+ (0, _assertString.default)(str);
13
+ options = options || {};
14
+
15
+ // Get the regex to use for testing, based on whether
16
+ // leading zeroes are allowed or not.
17
+ var regex = options.allow_leading_zeroes === false ? int : intLeadingZeroes;
18
+
19
+ // Check min/max/lt/gt
20
+ var minCheckPassed = !options.hasOwnProperty('min') || str >= options.min;
21
+ var maxCheckPassed = !options.hasOwnProperty('max') || str <= options.max;
22
+ var ltCheckPassed = !options.hasOwnProperty('lt') || str < options.lt;
23
+ var gtCheckPassed = !options.hasOwnProperty('gt') || str > options.gt;
24
+ return regex.test(str) && minCheckPassed && maxCheckPassed && ltCheckPassed && gtCheckPassed;
25
+ }
26
+ module.exports = exports.default;
27
+ module.exports.default = exports.default;
package/lib/isJSON.js ADDED
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isJSON;
7
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
8
+ var _merge = _interopRequireDefault(require("./util/merge"));
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ 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); }
11
+ var default_json_options = {
12
+ allow_primitives: false
13
+ };
14
+ function isJSON(str, options) {
15
+ (0, _assertString.default)(str);
16
+ try {
17
+ options = (0, _merge.default)(options, default_json_options);
18
+ var primitives = [];
19
+ if (options.allow_primitives) {
20
+ primitives = [null, false, true];
21
+ }
22
+ var obj = JSON.parse(str);
23
+ return primitives.includes(obj) || !!obj && _typeof(obj) === 'object';
24
+ } catch (e) {/* ignore */}
25
+ return false;
26
+ }
27
+ module.exports = exports.default;
28
+ module.exports.default = exports.default;
package/lib/isJWT.js ADDED
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isJWT;
7
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
8
+ var _isBase = _interopRequireDefault(require("./isBase64"));
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ function isJWT(str) {
11
+ (0, _assertString.default)(str);
12
+ var dotSplit = str.split('.');
13
+ var len = dotSplit.length;
14
+ if (len !== 3) {
15
+ return false;
16
+ }
17
+ return dotSplit.reduce(function (acc, currElem) {
18
+ return acc && (0, _isBase.default)(currElem, {
19
+ urlSafe: true
20
+ });
21
+ }, true);
22
+ }
23
+ module.exports = exports.default;
24
+ module.exports.default = exports.default;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isLatLong;
7
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
8
+ var _merge = _interopRequireDefault(require("./util/merge"));
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ var lat = /^\(?[+-]?(90(\.0+)?|[1-8]?\d(\.\d+)?)$/;
11
+ var long = /^\s?[+-]?(180(\.0+)?|1[0-7]\d(\.\d+)?|\d{1,2}(\.\d+)?)\)?$/;
12
+ var latDMS = /^(([1-8]?\d)\D+([1-5]?\d|60)\D+([1-5]?\d|60)(\.\d+)?|90\D+0\D+0)\D+[NSns]?$/i;
13
+ var longDMS = /^\s*([1-7]?\d{1,2}\D+([1-5]?\d|60)\D+([1-5]?\d|60)(\.\d+)?|180\D+0\D+0)\D+[EWew]?$/i;
14
+ var defaultLatLongOptions = {
15
+ checkDMS: false
16
+ };
17
+ function isLatLong(str, options) {
18
+ (0, _assertString.default)(str);
19
+ options = (0, _merge.default)(options, defaultLatLongOptions);
20
+ if (!str.includes(',')) return false;
21
+ var pair = str.split(',');
22
+ if (pair[0].startsWith('(') && !pair[1].endsWith(')') || pair[1].endsWith(')') && !pair[0].startsWith('(')) return false;
23
+ if (options.checkDMS) {
24
+ return latDMS.test(pair[0]) && longDMS.test(pair[1]);
25
+ }
26
+ return lat.test(pair[0]) && long.test(pair[1]);
27
+ }
28
+ module.exports = exports.default;
29
+ module.exports.default = exports.default;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isLength;
7
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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); }
10
+ /* eslint-disable prefer-rest-params */
11
+ function isLength(str, options) {
12
+ (0, _assertString.default)(str);
13
+ var min;
14
+ var max;
15
+ if (_typeof(options) === 'object') {
16
+ min = options.min || 0;
17
+ max = options.max;
18
+ } else {
19
+ // backwards compatibility: isLength(str, min [, max])
20
+ min = arguments[1] || 0;
21
+ max = arguments[2];
22
+ }
23
+ var presentationSequences = str.match(/(\uFE0F|\uFE0E)/g) || [];
24
+ var surrogatePairs = str.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g) || [];
25
+ var len = str.length - presentationSequences.length - surrogatePairs.length;
26
+ return len >= min && (typeof max === 'undefined' || len <= max);
27
+ }
28
+ module.exports = exports.default;
29
+ module.exports.default = exports.default;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isLicensePlate;
7
+ var _assertString = _interopRequireDefault(require("./util/assertString"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ var validators = {
10
+ 'cs-CZ': function csCZ(str) {
11
+ return /^(([ABCDEFHIJKLMNPRSTUVXYZ]|[0-9])-?){5,8}$/.test(str);
12
+ },
13
+ 'de-DE': function deDE(str) {
14
+ return /^((A|AA|AB|AC|AE|AH|AK|AM|AN|AÖ|AP|AS|AT|AU|AW|AZ|B|BA|BB|BC|BE|BF|BH|BI|BK|BL|BM|BN|BO|BÖ|BS|BT|BZ|C|CA|CB|CE|CO|CR|CW|D|DA|DD|DE|DH|DI|DL|DM|DN|DO|DU|DW|DZ|E|EA|EB|ED|EE|EF|EG|EH|EI|EL|EM|EN|ER|ES|EU|EW|F|FB|FD|FF|FG|FI|FL|FN|FO|FR|FS|FT|FÜ|FW|FZ|G|GA|GC|GD|GE|GF|GG|GI|GK|GL|GM|GN|GÖ|GP|GR|GS|GT|GÜ|GV|GW|GZ|H|HA|HB|HC|HD|HE|HF|HG|HH|HI|HK|HL|HM|HN|HO|HP|HR|HS|HU|HV|HX|HY|HZ|IK|IL|IN|IZ|J|JE|JL|K|KA|KB|KC|KE|KF|KG|KH|KI|KK|KL|KM|KN|KO|KR|KS|KT|KU|KW|KY|L|LA|LB|LC|LD|LF|LG|LH|LI|LL|LM|LN|LÖ|LP|LR|LU|M|MA|MB|MC|MD|ME|MG|MH|MI|MK|ML|MM|MN|MO|MQ|MR|MS|MÜ|MW|MY|MZ|N|NB|ND|NE|NF|NH|NI|NK|NM|NÖ|NP|NR|NT|NU|NW|NY|NZ|OA|OB|OC|OD|OE|OF|OG|OH|OK|OL|OP|OS|OZ|P|PA|PB|PE|PF|PI|PL|PM|PN|PR|PS|PW|PZ|R|RA|RC|RD|RE|RG|RH|RI|RL|RM|RN|RO|RP|RS|RT|RU|RV|RW|RZ|S|SB|SC|SE|SG|SI|SK|SL|SM|SN|SO|SP|SR|ST|SU|SW|SY|SZ|TE|TF|TG|TO|TP|TR|TS|TT|TÜ|ÜB|UE|UH|UL|UM|UN|V|VB|VG|VK|VR|VS|W|WA|WB|WE|WF|WI|WK|WL|WM|WN|WO|WR|WS|WT|WÜ|WW|WZ|Z|ZE|ZI|ZP|ZR|ZW|ZZ)[- ]?[A-Z]{1,2}[- ]?\d{1,4}|(ABG|ABI|AIB|AIC|ALF|ALZ|ANA|ANG|ANK|APD|ARN|ART|ASL|ASZ|AUR|AZE|BAD|BAR|BBG|BCH|BED|BER|BGD|BGL|BID|BIN|BIR|BIT|BIW|BKS|BLB|BLK|BNA|BOG|BOH|BOR|BOT|BRA|BRB|BRG|BRK|BRL|BRV|BSB|BSK|BTF|BÜD|BUL|BÜR|BÜS|BÜZ|CAS|CHA|CLP|CLZ|COC|COE|CUX|DAH|DAN|DAU|DBR|DEG|DEL|DGF|DIL|DIN|DIZ|DKB|DLG|DON|DUD|DÜW|EBE|EBN|EBS|ECK|EIC|EIL|EIN|EIS|EMD|EMS|ERB|ERH|ERK|ERZ|ESB|ESW|FDB|FDS|FEU|FFB|FKB|FLÖ|FOR|FRG|FRI|FRW|FTL|FÜS|GAN|GAP|GDB|GEL|GEO|GER|GHA|GHC|GLA|GMN|GNT|GOA|GOH|GRA|GRH|GRI|GRM|GRZ|GTH|GUB|GUN|GVM|HAB|HAL|HAM|HAS|HBN|HBS|HCH|HDH|HDL|HEB|HEF|HEI|HER|HET|HGN|HGW|HHM|HIG|HIP|HMÜ|HOG|HOH|HOL|HOM|HOR|HÖS|HOT|HRO|HSK|HST|HVL|HWI|IGB|ILL|JÜL|KEH|KEL|KEM|KIB|KLE|KLZ|KÖN|KÖT|KÖZ|KRU|KÜN|KUS|KYF|LAN|LAU|LBS|LBZ|LDK|LDS|LEO|LER|LEV|LIB|LIF|LIP|LÖB|LOS|LRO|LSZ|LÜN|LUP|LWL|MAB|MAI|MAK|MAL|MED|MEG|MEI|MEK|MEL|MER|MET|MGH|MGN|MHL|MIL|MKK|MOD|MOL|MON|MOS|MSE|MSH|MSP|MST|MTK|MTL|MÜB|MÜR|MYK|MZG|NAB|NAI|NAU|NDH|NEA|NEB|NEC|NEN|NES|NEW|NMB|NMS|NOH|NOL|NOM|NOR|NVP|NWM|OAL|OBB|OBG|OCH|OHA|ÖHR|OHV|OHZ|OPR|OSL|OVI|OVL|OVP|PAF|PAN|PAR|PCH|PEG|PIR|PLÖ|PRÜ|QFT|QLB|RDG|REG|REH|REI|RID|RIE|ROD|ROF|ROK|ROL|ROS|ROT|ROW|RSL|RÜD|RÜG|SAB|SAD|SAN|SAW|SBG|SBK|SCZ|SDH|SDL|SDT|SEB|SEE|SEF|SEL|SFB|SFT|SGH|SHA|SHG|SHK|SHL|SIG|SIM|SLE|SLF|SLK|SLN|SLS|SLÜ|SLZ|SMÜ|SOB|SOG|SOK|SÖM|SON|SPB|SPN|SRB|SRO|STA|STB|STD|STE|STL|SUL|SÜW|SWA|SZB|TBB|TDO|TET|TIR|TÖL|TUT|UEM|UER|UFF|USI|VAI|VEC|VER|VIB|VIE|VIT|VOH|WAF|WAK|WAN|WAR|WAT|WBS|WDA|WEL|WEN|WER|WES|WHV|WIL|WIS|WIT|WIZ|WLG|WMS|WND|WOB|WOH|WOL|WOR|WOS|WRN|WSF|WST|WSW|WTL|WTM|WUG|WÜM|WUN|WUR|WZL|ZEL|ZIG)[- ]?(([A-Z][- ]?\d{1,4})|([A-Z]{2}[- ]?\d{1,3})))[- ]?(E|H)?$/.test(str);
15
+ },
16
+ 'de-LI': function deLI(str) {
17
+ return /^FL[- ]?\d{1,5}[UZ]?$/.test(str);
18
+ },
19
+ 'en-IN': function enIN(str) {
20
+ return /^[A-Z]{2}[ -]?[0-9]{1,2}(?:[ -]?[A-Z])(?:[ -]?[A-Z]*)?[ -]?[0-9]{4}$/.test(str);
21
+ },
22
+ 'es-AR': function esAR(str) {
23
+ return /^(([A-Z]{2} ?[0-9]{3} ?[A-Z]{2})|([A-Z]{3} ?[0-9]{3}))$/.test(str);
24
+ },
25
+ 'fi-FI': function fiFI(str) {
26
+ return /^(?=.{4,7})(([A-Z]{1,3}|[0-9]{1,3})[\s-]?([A-Z]{1,3}|[0-9]{1,5}))$/.test(str);
27
+ },
28
+ 'hu-HU': function huHU(str) {
29
+ return /^((((?!AAA)(([A-NPRSTVZWXY]{1})([A-PR-Z]{1})([A-HJ-NPR-Z]))|(A[ABC]I)|A[ABC]O|A[A-W]Q|BPI|BPO|UCO|UDO|XAO)-(?!000)\d{3})|(M\d{6})|((CK|DT|CD|HC|H[ABEFIKLMNPRSTVX]|MA|OT|R[A-Z]) \d{2}-\d{2})|(CD \d{3}-\d{3})|(C-(C|X) \d{4})|(X-(A|B|C) \d{4})|(([EPVZ]-\d{5}))|(S A[A-Z]{2} \d{2})|(SP \d{2}-\d{2}))$/.test(str);
30
+ },
31
+ 'pt-BR': function ptBR(str) {
32
+ return /^[A-Z]{3}[ -]?[0-9][A-Z][0-9]{2}|[A-Z]{3}[ -]?[0-9]{4}$/.test(str);
33
+ },
34
+ 'pt-PT': function ptPT(str) {
35
+ return /^([A-Z]{2}|[0-9]{2})[ -·]?([A-Z]{2}|[0-9]{2})[ -·]?([A-Z]{2}|[0-9]{2})$/.test(str);
36
+ },
37
+ 'sq-AL': function sqAL(str) {
38
+ return /^[A-Z]{2}[- ]?((\d{3}[- ]?(([A-Z]{2})|T))|(R[- ]?\d{3}))$/.test(str);
39
+ },
40
+ 'sv-SE': function svSE(str) {
41
+ return /^[A-HJ-PR-UW-Z]{3} ?[\d]{2}[A-HJ-PR-UW-Z1-9]$|(^[A-ZÅÄÖ ]{2,7}$)/.test(str.trim());
42
+ },
43
+ 'en-PK': function enPK(str) {
44
+ return /(^[A-Z]{2}((\s|-){0,1})[0-9]{3,4}((\s|-)[0-9]{2}){0,1}$)|(^[A-Z]{3}((\s|-){0,1})[0-9]{3,4}((\s|-)[0-9]{2}){0,1}$)|(^[A-Z]{4}((\s|-){0,1})[0-9]{3,4}((\s|-)[0-9]{2}){0,1}$)|(^[A-Z]((\s|-){0,1})[0-9]{4}((\s|-)[0-9]{2}){0,1}$)/.test(str.trim());
45
+ }
46
+ };
47
+ function isLicensePlate(str, locale) {
48
+ (0, _assertString.default)(str);
49
+ if (locale in validators) {
50
+ return validators[locale](str);
51
+ } else if (locale === 'any') {
52
+ for (var key in validators) {
53
+ /* eslint guard-for-in: 0 */
54
+ var validator = validators[key];
55
+ if (validator(str)) {
56
+ return true;
57
+ }
58
+ }
59
+ return false;
60
+ }
61
+ throw new Error("Invalid locale '".concat(locale, "'"));
62
+ }
63
+ module.exports = exports.default;
64
+ module.exports.default = exports.default;