UNPKG

497 kBJavaScriptView Raw
1(function (global, factory) {
2 typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3 typeof define === 'function' && define.amd ? define(['exports'], factory) :
4 (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ClassValidator = {}));
5})(this, (function (exports) { 'use strict';
6
7 /**
8 * Container to be used by this library for inversion control. If container was not implicitly set then by default
9 * container simply creates a new instance of the given class.
10 */
11 var defaultContainer = new (/** @class */ (function () {
12 function class_1() {
13 this.instances = [];
14 }
15 class_1.prototype.get = function (someClass) {
16 var instance = this.instances.find(function (instance) { return instance.type === someClass; });
17 if (!instance) {
18 instance = { type: someClass, object: new someClass() };
19 this.instances.push(instance);
20 }
21 return instance.object;
22 };
23 return class_1;
24 }()))();
25 var userContainer;
26 var userContainerOptions;
27 /**
28 * Sets container to be used by this library.
29 */
30 function useContainer(iocContainer, options) {
31 userContainer = iocContainer;
32 userContainerOptions = options;
33 }
34 /**
35 * Gets the IOC container used by this library.
36 */
37 function getFromContainer(someClass) {
38 if (userContainer) {
39 try {
40 var instance = userContainer.get(someClass);
41 if (instance)
42 return instance;
43 if (!userContainerOptions || !userContainerOptions.fallback)
44 return instance;
45 }
46 catch (error) {
47 if (!userContainerOptions || !userContainerOptions.fallbackOnErrors)
48 throw error;
49 }
50 }
51 return defaultContainer.get(someClass);
52 }
53
54 /**
55 * This metadata contains validation rules.
56 */
57 var ValidationMetadata = /** @class */ (function () {
58 // -------------------------------------------------------------------------
59 // Constructor
60 // -------------------------------------------------------------------------
61 function ValidationMetadata(args) {
62 /**
63 * Validation groups used for this validation.
64 */
65 this.groups = [];
66 /**
67 * Specifies if validated value is an array and each of its item must be validated.
68 */
69 this.each = false;
70 /*
71 * A transient set of data passed through to the validation result for response mapping
72 */
73 this.context = undefined;
74 this.type = args.type;
75 this.target = args.target;
76 this.propertyName = args.propertyName;
77 this.constraints = args.constraints;
78 this.constraintCls = args.constraintCls;
79 this.validationTypeOptions = args.validationTypeOptions;
80 if (args.validationOptions) {
81 this.message = args.validationOptions.message;
82 this.groups = args.validationOptions.groups;
83 this.always = args.validationOptions.always;
84 this.each = args.validationOptions.each;
85 this.context = args.validationOptions.context;
86 }
87 }
88 return ValidationMetadata;
89 }());
90
91 /**
92 * Used to transform validation schemas to validation metadatas.
93 */
94 var ValidationSchemaToMetadataTransformer = /** @class */ (function () {
95 function ValidationSchemaToMetadataTransformer() {
96 }
97 ValidationSchemaToMetadataTransformer.prototype.transform = function (schema) {
98 var metadatas = [];
99 Object.keys(schema.properties).forEach(function (property) {
100 schema.properties[property].forEach(function (validation) {
101 var validationOptions = {
102 message: validation.message,
103 groups: validation.groups,
104 always: validation.always,
105 each: validation.each,
106 };
107 var args = {
108 type: validation.type,
109 target: schema.name,
110 propertyName: property,
111 constraints: validation.constraints,
112 validationTypeOptions: validation.options,
113 validationOptions: validationOptions,
114 };
115 metadatas.push(new ValidationMetadata(args));
116 });
117 });
118 return metadatas;
119 };
120 return ValidationSchemaToMetadataTransformer;
121 }());
122
123 /**
124 * Convert Map, Set to Array
125 */
126 function convertToArray(val) {
127 if (val instanceof Map) {
128 return Array.from(val.values());
129 }
130 return Array.isArray(val) ? val : Array.from(val);
131 }
132
133 /**
134 * This function returns the global object across Node and browsers.
135 *
136 * Note: `globalThis` is the standardized approach however it has been added to
137 * Node.js in version 12. We need to include this snippet until Node 12 EOL.
138 */
139 function getGlobal() {
140 if (typeof globalThis !== 'undefined') {
141 return globalThis;
142 }
143 if (typeof global !== 'undefined') {
144 return global;
145 }
146 // eslint-disable-next-line @typescript-eslint/ban-ts-comment
147 // @ts-ignore: Cannot find name 'window'.
148 if (typeof window !== 'undefined') {
149 // eslint-disable-next-line @typescript-eslint/ban-ts-comment
150 // @ts-ignore: Cannot find name 'window'.
151 return window;
152 }
153 // eslint-disable-next-line @typescript-eslint/ban-ts-comment
154 // @ts-ignore: Cannot find name 'self'.
155 if (typeof self !== 'undefined') {
156 // eslint-disable-next-line @typescript-eslint/ban-ts-comment
157 // @ts-ignore: Cannot find name 'self'.
158 return self;
159 }
160 }
161
162 // https://github.com/TylorS/typed-is-promise/blob/abf1514e1b6961adfc75765476b0debb96b2c3ae/src/index.ts
163 function isPromise(p) {
164 return p !== null && typeof p === 'object' && typeof p.then === 'function';
165 }
166
167 /**
168 * Storage all metadatas.
169 */
170 var MetadataStorage = /** @class */ (function () {
171 function MetadataStorage() {
172 // -------------------------------------------------------------------------
173 // Private properties
174 // -------------------------------------------------------------------------
175 this.validationMetadatas = [];
176 this.constraintMetadatas = [];
177 }
178 Object.defineProperty(MetadataStorage.prototype, "hasValidationMetaData", {
179 get: function () {
180 return !!this.validationMetadatas.length;
181 },
182 enumerable: false,
183 configurable: true
184 });
185 // -------------------------------------------------------------------------
186 // Public Methods
187 // -------------------------------------------------------------------------
188 /**
189 * Adds a new validation metadata.
190 */
191 MetadataStorage.prototype.addValidationSchema = function (schema) {
192 var _this = this;
193 var validationMetadatas = new ValidationSchemaToMetadataTransformer().transform(schema);
194 validationMetadatas.forEach(function (validationMetadata) { return _this.addValidationMetadata(validationMetadata); });
195 };
196 /**
197 * Adds a new validation metadata.
198 */
199 MetadataStorage.prototype.addValidationMetadata = function (metadata) {
200 this.validationMetadatas.push(metadata);
201 };
202 /**
203 * Adds a new constraint metadata.
204 */
205 MetadataStorage.prototype.addConstraintMetadata = function (metadata) {
206 this.constraintMetadatas.push(metadata);
207 };
208 /**
209 * Groups metadata by their property names.
210 */
211 MetadataStorage.prototype.groupByPropertyName = function (metadata) {
212 var grouped = {};
213 metadata.forEach(function (metadata) {
214 if (!grouped[metadata.propertyName])
215 grouped[metadata.propertyName] = [];
216 grouped[metadata.propertyName].push(metadata);
217 });
218 return grouped;
219 };
220 /**
221 * Gets all validation metadatas for the given object with the given groups.
222 */
223 MetadataStorage.prototype.getTargetValidationMetadatas = function (targetConstructor, targetSchema, always, strictGroups, groups) {
224 var includeMetadataBecauseOfAlwaysOption = function (metadata) {
225 // `metadata.always` overrides global default.
226 if (typeof metadata.always !== 'undefined')
227 return metadata.always;
228 // `metadata.groups` overrides global default.
229 if (metadata.groups && metadata.groups.length)
230 return false;
231 // Use global default.
232 return always;
233 };
234 var excludeMetadataBecauseOfStrictGroupsOption = function (metadata) {
235 if (strictGroups) {
236 // Validation is not using groups.
237 if (!groups || !groups.length) {
238 // `metadata.groups` has at least one group.
239 if (metadata.groups && metadata.groups.length)
240 return true;
241 }
242 }
243 return false;
244 };
245 // get directly related to a target metadatas
246 var originalMetadatas = this.validationMetadatas.filter(function (metadata) {
247 if (metadata.target !== targetConstructor && metadata.target !== targetSchema)
248 return false;
249 if (includeMetadataBecauseOfAlwaysOption(metadata))
250 return true;
251 if (excludeMetadataBecauseOfStrictGroupsOption(metadata))
252 return false;
253 if (groups && groups.length > 0)
254 return metadata.groups && !!metadata.groups.find(function (group) { return groups.indexOf(group) !== -1; });
255 return true;
256 });
257 // get metadatas for inherited classes
258 var inheritedMetadatas = this.validationMetadatas.filter(function (metadata) {
259 // if target is a string it's means we validate against a schema, and there is no inheritance support for schemas
260 if (typeof metadata.target === 'string')
261 return false;
262 if (metadata.target === targetConstructor)
263 return false;
264 if (metadata.target instanceof Function && !(targetConstructor.prototype instanceof metadata.target))
265 return false;
266 if (includeMetadataBecauseOfAlwaysOption(metadata))
267 return true;
268 if (excludeMetadataBecauseOfStrictGroupsOption(metadata))
269 return false;
270 if (groups && groups.length > 0)
271 return metadata.groups && !!metadata.groups.find(function (group) { return groups.indexOf(group) !== -1; });
272 return true;
273 });
274 // filter out duplicate metadatas, prefer original metadatas instead of inherited metadatas
275 var uniqueInheritedMetadatas = inheritedMetadatas.filter(function (inheritedMetadata) {
276 return !originalMetadatas.find(function (originalMetadata) {
277 return (originalMetadata.propertyName === inheritedMetadata.propertyName &&
278 originalMetadata.type === inheritedMetadata.type);
279 });
280 });
281 return originalMetadatas.concat(uniqueInheritedMetadatas);
282 };
283 /**
284 * Gets all validator constraints for the given object.
285 */
286 MetadataStorage.prototype.getTargetValidatorConstraints = function (target) {
287 return this.constraintMetadatas.filter(function (metadata) { return metadata.target === target; });
288 };
289 return MetadataStorage;
290 }());
291 /**
292 * Gets metadata storage.
293 * Metadata storage follows the best practices and stores metadata in a global variable.
294 */
295 function getMetadataStorage() {
296 var global = getGlobal();
297 if (!global.classValidatorMetadataStorage) {
298 global.classValidatorMetadataStorage = new MetadataStorage();
299 }
300 return global.classValidatorMetadataStorage;
301 }
302
303 /**
304 * Validation error description.
305 */
306 var ValidationError = /** @class */ (function () {
307 function ValidationError() {
308 }
309 /**
310 *
311 * @param shouldDecorate decorate the message with ANSI formatter escape codes for better readability
312 * @param hasParent true when the error is a child of an another one
313 * @param parentPath path as string to the parent of this property
314 */
315 ValidationError.prototype.toString = function (shouldDecorate, hasParent, parentPath) {
316 var _this = this;
317 if (shouldDecorate === void 0) { shouldDecorate = false; }
318 if (hasParent === void 0) { hasParent = false; }
319 if (parentPath === void 0) { parentPath = ""; }
320 var boldStart = shouldDecorate ? "\u001B[1m" : "";
321 var boldEnd = shouldDecorate ? "\u001B[22m" : "";
322 var propConstraintFailed = function (propertyName) {
323 return " - property ".concat(boldStart).concat(parentPath).concat(propertyName).concat(boldEnd, " has failed the following constraints: ").concat(boldStart).concat(Object.keys(_this.constraints).join(", ")).concat(boldEnd, " \n");
324 };
325 if (!hasParent) {
326 return ("An instance of ".concat(boldStart).concat(this.target ? this.target.constructor.name : 'an object').concat(boldEnd, " has failed the validation:\n") +
327 (this.constraints ? propConstraintFailed(this.property) : "") +
328 (this.children
329 ? this.children.map(function (childError) { return childError.toString(shouldDecorate, true, _this.property); }).join("")
330 : ""));
331 }
332 else {
333 // we format numbers as array indexes for better readability.
334 var formattedProperty_1 = Number.isInteger(+this.property)
335 ? "[".concat(this.property, "]")
336 : "".concat(parentPath ? "." : "").concat(this.property);
337 if (this.constraints) {
338 return propConstraintFailed(formattedProperty_1);
339 }
340 else {
341 return this.children
342 ? this.children
343 .map(function (childError) { return childError.toString(shouldDecorate, true, "".concat(parentPath).concat(formattedProperty_1)); })
344 .join("")
345 : "";
346 }
347 }
348 };
349 return ValidationError;
350 }());
351
352 /**
353 * Validation types.
354 */
355 var ValidationTypes = /** @class */ (function () {
356 function ValidationTypes() {
357 }
358 /**
359 * Checks if validation type is valid.
360 */
361 ValidationTypes.isValid = function (type) {
362 var _this = this;
363 return (type !== 'isValid' &&
364 type !== 'getMessage' &&
365 Object.keys(this)
366 .map(function (key) { return _this[key]; })
367 .indexOf(type) !== -1);
368 };
369 /* system */
370 ValidationTypes.CUSTOM_VALIDATION = 'customValidation'; // done
371 ValidationTypes.NESTED_VALIDATION = 'nestedValidation'; // done
372 ValidationTypes.PROMISE_VALIDATION = 'promiseValidation'; // done
373 ValidationTypes.CONDITIONAL_VALIDATION = 'conditionalValidation'; // done
374 ValidationTypes.WHITELIST = 'whitelistValidation'; // done
375 ValidationTypes.IS_DEFINED = 'isDefined'; // done
376 return ValidationTypes;
377 }());
378
379 var CLASS_VALIDATOR_MESSAGES = 'CLASS_VALIDATOR_MESSAGES';
380 function getClassValidatorMessagesStorage() {
381 var global = getGlobal();
382 if (!global[CLASS_VALIDATOR_MESSAGES]) {
383 global[CLASS_VALIDATOR_MESSAGES] = {};
384 }
385 return global[CLASS_VALIDATOR_MESSAGES];
386 }
387 function setClassValidatorMessages(messages) {
388 var storageMessages = getClassValidatorMessagesStorage();
389 Object.keys(storageMessages).forEach(function (key) { return delete storageMessages[key]; });
390 Object.assign(storageMessages, messages);
391 }
392 function getClassValidatorMessages() {
393 return getClassValidatorMessagesStorage();
394 }
395 function getClassValidatorMessage(key) {
396 var messages = getClassValidatorMessagesStorage();
397 return messages[key];
398 }
399
400 var CLASS_VALIDATOR_MESSAGE_MARKER = '__I18N__';
401 function getText(s) {
402 return getClassValidatorMessage(s) ? [CLASS_VALIDATOR_MESSAGE_MARKER, s, CLASS_VALIDATOR_MESSAGE_MARKER].join('') : s;
403 }
404
405 var CLASS_VALIDATOR_PROPERTY_TITLES = 'CLASS_VALIDATOR_PROPERTY_TITLES';
406 var CLASS_VALIDATOR_TITLES = 'CLASS_VALIDATOR_TITLES';
407 var CLASS_VALIDATOR_ROOT_TITLE = 'CLASS_VALIDATOR_ROOT_TITLE';
408 // PROPERTY
409 function getClassValidatorPropertyTitlesStorage() {
410 var global = getGlobal();
411 if (!global[CLASS_VALIDATOR_PROPERTY_TITLES]) {
412 global[CLASS_VALIDATOR_PROPERTY_TITLES] = [];
413 }
414 return global[CLASS_VALIDATOR_PROPERTY_TITLES];
415 }
416 function setClassValidatorPropertyTitle(object, propertyName, title) {
417 var storagePropertyTitle = getClassValidatorPropertyTitlesStorage();
418 var obj = storagePropertyTitle.find(function (o) { return o.target === object.constructor; });
419 if (!obj) {
420 obj = { target: object.constructor, titles: new Map() };
421 storagePropertyTitle.push(obj);
422 }
423 obj.titles.set(propertyName, title);
424 }
425 function getClassValidatorPropertyTitles(object) {
426 var storagePropertyTitle = getClassValidatorPropertyTitlesStorage();
427 var obj = storagePropertyTitle.find(function (o) { return o.target === object.constructor; });
428 if (!obj) {
429 return new Map();
430 }
431 return obj.titles;
432 }
433 function getClassValidatorPropertyTitle(object, propertyName) {
434 var titles = getClassValidatorPropertyTitles(object);
435 return titles.get(propertyName);
436 }
437 // CLASS
438 function getClassValidatorTitlesStorage() {
439 var global = getGlobal();
440 if (!global[CLASS_VALIDATOR_TITLES]) {
441 global[CLASS_VALIDATOR_TITLES] = [];
442 }
443 return global[CLASS_VALIDATOR_TITLES];
444 }
445 function setClassValidatorTitle(object, propertyName, title) {
446 var storageTitle = getClassValidatorTitlesStorage();
447 var obj = storageTitle.find(function (o) { return o.target === object; });
448 if (!obj) {
449 obj = { target: object, titles: new Map() };
450 storageTitle.push(obj);
451 }
452 obj.titles.set(propertyName || CLASS_VALIDATOR_ROOT_TITLE, title);
453 }
454 function getClassValidatorTitles(object) {
455 var storageTitle = getClassValidatorTitlesStorage();
456 var obj = storageTitle.find(function (o) { return o.target === object.constructor; });
457 if (!obj) {
458 return new Map();
459 }
460 return obj.titles;
461 }
462 function getClassValidatorTitle(object, propertyName) {
463 var titles = getClassValidatorTitles(object);
464 return titles.get(propertyName || CLASS_VALIDATOR_ROOT_TITLE);
465 }
466
467 function ClassPropertyTitle(title) {
468 return function (object, propertyName) {
469 setClassValidatorPropertyTitle(object, propertyName, title);
470 };
471 }
472 function ClassTitle(title, key) {
473 return function (object) {
474 setClassValidatorTitle(object, key, title);
475 };
476 }
477
478 /**
479 * Convert the constraint to a string to be shown in an error
480 */
481 function constraintToString(constraint) {
482 if (Array.isArray(constraint)) {
483 return constraint.join(', ');
484 }
485 return "".concat(constraint);
486 }
487 var ValidationUtils = /** @class */ (function () {
488 function ValidationUtils() {
489 }
490 ValidationUtils.replaceMessageSpecialTokens = function (message, validationArguments, titles) {
491 var checkTitle = Object.keys(titles).length > 0;
492 var messageString = '';
493 if (message instanceof Function) {
494 messageString = message(validationArguments);
495 }
496 else if (typeof message === 'string') {
497 messageString = message;
498 }
499 if (messageString && Array.isArray(validationArguments.constraints)) {
500 validationArguments.constraints.forEach(function (constraint, index) {
501 messageString = messageString.replace(new RegExp("\\$constraint".concat(index + 1), 'g'), (checkTitle &&
502 titles[getClassValidatorTitle(validationArguments.object, constraintToString(constraint)) ||
503 constraintToString(constraint)]) ||
504 constraintToString(constraint));
505 });
506 }
507 if (messageString &&
508 validationArguments.value !== undefined &&
509 validationArguments.value !== null &&
510 typeof validationArguments.value === 'string')
511 messageString = messageString.replace(/\$value/g, (checkTitle &&
512 titles[getClassValidatorTitle(validationArguments.object, validationArguments.value) || validationArguments.value]) ||
513 validationArguments.value);
514 if (messageString) {
515 messageString = messageString.replace(/\$property/g, (checkTitle &&
516 titles[getClassValidatorPropertyTitle(validationArguments.object, validationArguments.property) ||
517 validationArguments.property]) ||
518 validationArguments.property);
519 }
520 if (messageString) {
521 messageString = messageString.replace(/\$target/g, (checkTitle &&
522 titles[getClassValidatorTitle(validationArguments.object, '') || validationArguments.targetName]) ||
523 validationArguments.targetName);
524 }
525 return messageString;
526 };
527 return ValidationUtils;
528 }());
529
530 /**
531 * Executes validation over given object.
532 */
533 var ValidationExecutor = /** @class */ (function () {
534 // -------------------------------------------------------------------------
535 // Constructor
536 // -------------------------------------------------------------------------
537 function ValidationExecutor(validator, validatorOptions) {
538 this.validator = validator;
539 this.validatorOptions = validatorOptions;
540 // -------------------------------------------------------------------------
541 // Properties
542 // -------------------------------------------------------------------------
543 this.awaitingPromises = [];
544 this.ignoreAsyncValidations = false;
545 // -------------------------------------------------------------------------
546 // Private Properties
547 // -------------------------------------------------------------------------
548 this.metadataStorage = getMetadataStorage();
549 }
550 // -------------------------------------------------------------------------
551 // Public Methods
552 // -------------------------------------------------------------------------
553 ValidationExecutor.prototype.execute = function (object, targetSchema, validationErrors) {
554 var _this = this;
555 var _a;
556 /**
557 * If there is no metadata registered it means possibly the dependencies are not flatterned and
558 * more than one instance is used.
559 *
560 * TODO: This needs proper handling, forcing to use the same container or some other proper solution.
561 */
562 if (!this.metadataStorage.hasValidationMetaData && ((_a = this.validatorOptions) === null || _a === void 0 ? void 0 : _a.enableDebugMessages) === true) {
563 console.warn("No metadata found. There is more than once class-validator version installed probably. You need to flatten your dependencies.");
564 }
565 var groups = this.validatorOptions ? this.validatorOptions.groups : undefined;
566 var strictGroups = (this.validatorOptions && this.validatorOptions.strictGroups) || false;
567 var always = (this.validatorOptions && this.validatorOptions.always) || false;
568 var targetMetadatas = this.metadataStorage.getTargetValidationMetadatas(object.constructor, targetSchema, always, strictGroups, groups);
569 var groupedMetadatas = this.metadataStorage.groupByPropertyName(targetMetadatas);
570 if (this.validatorOptions && this.validatorOptions.forbidUnknownValues && !targetMetadatas.length) {
571 var validationError = new ValidationError();
572 if (!this.validatorOptions ||
573 !this.validatorOptions.validationError ||
574 this.validatorOptions.validationError.target === undefined ||
575 this.validatorOptions.validationError.target === true)
576 validationError.target = object;
577 validationError.value = undefined;
578 validationError.property = undefined;
579 validationError.children = [];
580 validationError.constraints = { unknownValue: 'an unknown value was passed to the validate function' };
581 validationErrors.push(validationError);
582 return;
583 }
584 if (this.validatorOptions && this.validatorOptions.whitelist)
585 this.whitelist(object, groupedMetadatas, validationErrors);
586 // General validation
587 Object.keys(groupedMetadatas).forEach(function (propertyName) {
588 var value = object[propertyName];
589 var definedMetadatas = groupedMetadatas[propertyName].filter(function (metadata) { return metadata.type === ValidationTypes.IS_DEFINED; });
590 var metadatas = groupedMetadatas[propertyName].filter(function (metadata) { return metadata.type !== ValidationTypes.IS_DEFINED && metadata.type !== ValidationTypes.WHITELIST; });
591 if (value instanceof Promise &&
592 metadatas.find(function (metadata) { return metadata.type === ValidationTypes.PROMISE_VALIDATION; })) {
593 _this.awaitingPromises.push(value.then(function (resolvedValue) {
594 _this.performValidations(object, resolvedValue, propertyName, definedMetadatas, metadatas, validationErrors);
595 }));
596 }
597 else {
598 _this.performValidations(object, value, propertyName, definedMetadatas, metadatas, validationErrors);
599 }
600 });
601 };
602 ValidationExecutor.prototype.whitelist = function (object, groupedMetadatas, validationErrors) {
603 var _this = this;
604 var notAllowedProperties = [];
605 Object.keys(object).forEach(function (propertyName) {
606 // does this property have no metadata?
607 if (!groupedMetadatas[propertyName] || groupedMetadatas[propertyName].length === 0)
608 notAllowedProperties.push(propertyName);
609 });
610 if (notAllowedProperties.length > 0) {
611 if (this.validatorOptions && this.validatorOptions.forbidNonWhitelisted) {
612 // throw errors
613 notAllowedProperties.forEach(function (property) {
614 var _a;
615 var validationError = _this.generateValidationError(object, object[property], property);
616 validationError.constraints = (_a = {}, _a[ValidationTypes.WHITELIST] = "property ".concat(property, " should not exist"), _a);
617 validationError.children = undefined;
618 validationErrors.push(validationError);
619 });
620 }
621 else {
622 // strip non allowed properties
623 notAllowedProperties.forEach(function (property) { return delete object[property]; });
624 }
625 }
626 };
627 ValidationExecutor.prototype.stripEmptyErrors = function (errors) {
628 var _this = this;
629 return errors.filter(function (error) {
630 if (error.children) {
631 error.children = _this.stripEmptyErrors(error.children);
632 }
633 if (Object.keys(error.constraints).length === 0) {
634 if (error.children.length === 0) {
635 return false;
636 }
637 else {
638 delete error.constraints;
639 }
640 }
641 return true;
642 });
643 };
644 // -------------------------------------------------------------------------
645 // Private Methods
646 // -------------------------------------------------------------------------
647 ValidationExecutor.prototype.performValidations = function (object, value, propertyName, definedMetadatas, metadatas, validationErrors) {
648 var customValidationMetadatas = metadatas.filter(function (metadata) { return metadata.type === ValidationTypes.CUSTOM_VALIDATION; });
649 var nestedValidationMetadatas = metadatas.filter(function (metadata) { return metadata.type === ValidationTypes.NESTED_VALIDATION; });
650 var conditionalValidationMetadatas = metadatas.filter(function (metadata) { return metadata.type === ValidationTypes.CONDITIONAL_VALIDATION; });
651 var validationError = this.generateValidationError(object, value, propertyName);
652 validationErrors.push(validationError);
653 var canValidate = this.conditionalValidations(object, value, conditionalValidationMetadatas);
654 if (!canValidate) {
655 return;
656 }
657 // handle IS_DEFINED validation type the special way - it should work no matter skipUndefinedProperties/skipMissingProperties is set or not
658 this.customValidations(object, value, definedMetadatas, validationError);
659 this.mapContexts(object, value, definedMetadatas, validationError);
660 if (value === undefined && this.validatorOptions && this.validatorOptions.skipUndefinedProperties === true) {
661 return;
662 }
663 if (value === null && this.validatorOptions && this.validatorOptions.skipNullProperties === true) {
664 return;
665 }
666 if ((value === null || value === undefined) &&
667 this.validatorOptions &&
668 this.validatorOptions.skipMissingProperties === true) {
669 return;
670 }
671 this.customValidations(object, value, customValidationMetadatas, validationError);
672 this.nestedValidations(value, nestedValidationMetadatas, validationError.children);
673 this.mapContexts(object, value, metadatas, validationError);
674 this.mapContexts(object, value, customValidationMetadatas, validationError);
675 };
676 ValidationExecutor.prototype.generateValidationError = function (object, value, propertyName) {
677 var validationError = new ValidationError();
678 if (!this.validatorOptions ||
679 !this.validatorOptions.validationError ||
680 this.validatorOptions.validationError.target === undefined ||
681 this.validatorOptions.validationError.target === true)
682 validationError.target = object;
683 if (!this.validatorOptions ||
684 !this.validatorOptions.validationError ||
685 this.validatorOptions.validationError.value === undefined ||
686 this.validatorOptions.validationError.value === true)
687 validationError.value = value;
688 validationError.property = propertyName;
689 validationError.children = [];
690 validationError.constraints = {};
691 return validationError;
692 };
693 ValidationExecutor.prototype.conditionalValidations = function (object, value, metadatas) {
694 return metadatas
695 .map(function (metadata) { return metadata.constraints[0](object, value); })
696 .reduce(function (resultA, resultB) { return resultA && resultB; }, true);
697 };
698 ValidationExecutor.prototype.customValidations = function (object, value, metadatas, error) {
699 var _this = this;
700 metadatas.forEach(function (metadata) {
701 _this.metadataStorage.getTargetValidatorConstraints(metadata.constraintCls).forEach(function (customConstraintMetadata) {
702 if (customConstraintMetadata.async && _this.ignoreAsyncValidations)
703 return;
704 if (_this.validatorOptions &&
705 _this.validatorOptions.stopAtFirstError &&
706 Object.keys(error.constraints || {}).length > 0)
707 return;
708 var validationArguments = {
709 targetName: object.constructor ? object.constructor.name : undefined,
710 property: metadata.propertyName,
711 object: object,
712 value: value,
713 constraints: metadata.constraints,
714 };
715 if (!metadata.each || !(Array.isArray(value) || value instanceof Set || value instanceof Map)) {
716 var validatedValue = customConstraintMetadata.instance.validate(value, validationArguments);
717 if (isPromise(validatedValue)) {
718 var promise = validatedValue.then(function (isValid) {
719 if (!isValid) {
720 var _a = _this.createValidationError(object, value, metadata, customConstraintMetadata), type = _a[0], message = _a[1];
721 error.constraints[type] = message;
722 if (metadata.context) {
723 if (!error.contexts) {
724 error.contexts = {};
725 }
726 error.contexts[type] = Object.assign(error.contexts[type] || {}, metadata.context);
727 }
728 }
729 });
730 _this.awaitingPromises.push(promise);
731 }
732 else {
733 if (!validatedValue) {
734 var _a = _this.createValidationError(object, value, metadata, customConstraintMetadata), type = _a[0], message = _a[1];
735 error.constraints[type] = message;
736 }
737 }
738 return;
739 }
740 // convert set and map into array
741 var arrayValue = convertToArray(value);
742 // Validation needs to be applied to each array item
743 var validatedSubValues = arrayValue.map(function (subValue) {
744 return customConstraintMetadata.instance.validate(subValue, validationArguments);
745 });
746 var validationIsAsync = validatedSubValues.some(function (validatedSubValue) {
747 return isPromise(validatedSubValue);
748 });
749 if (validationIsAsync) {
750 // Wrap plain values (if any) in promises, so that all are async
751 var asyncValidatedSubValues = validatedSubValues.map(function (validatedSubValue) {
752 return isPromise(validatedSubValue) ? validatedSubValue : Promise.resolve(validatedSubValue);
753 });
754 var asyncValidationIsFinishedPromise = Promise.all(asyncValidatedSubValues).then(function (flatValidatedValues) {
755 var validationResult = flatValidatedValues.every(function (isValid) { return isValid; });
756 if (!validationResult) {
757 var _a = _this.createValidationError(object, value, metadata, customConstraintMetadata), type = _a[0], message = _a[1];
758 error.constraints[type] = message;
759 if (metadata.context) {
760 if (!error.contexts) {
761 error.contexts = {};
762 }
763 error.contexts[type] = Object.assign(error.contexts[type] || {}, metadata.context);
764 }
765 }
766 });
767 _this.awaitingPromises.push(asyncValidationIsFinishedPromise);
768 return;
769 }
770 var validationResult = validatedSubValues.every(function (isValid) { return isValid; });
771 if (!validationResult) {
772 var _b = _this.createValidationError(object, value, metadata, customConstraintMetadata), type = _b[0], message = _b[1];
773 error.constraints[type] = message;
774 }
775 });
776 });
777 };
778 ValidationExecutor.prototype.nestedValidations = function (value, metadatas, errors) {
779 var _this = this;
780 if (value === void 0) {
781 return;
782 }
783 metadatas.forEach(function (metadata) {
784 var _a;
785 if (metadata.type !== ValidationTypes.NESTED_VALIDATION && metadata.type !== ValidationTypes.PROMISE_VALIDATION) {
786 return;
787 }
788 if (Array.isArray(value) || value instanceof Set || value instanceof Map) {
789 // Treats Set as an array - as index of Set value is value itself and it is common case to have Object as value
790 var arrayLikeValue = value instanceof Set ? Array.from(value) : value;
791 arrayLikeValue.forEach(function (subValue, index) {
792 _this.performValidations(value, subValue, index.toString(), [], metadatas, errors);
793 });
794 }
795 else if (value instanceof Object) {
796 var targetSchema = typeof metadata.target === 'string' ? metadata.target : metadata.target.name;
797 _this.execute(value, targetSchema, errors);
798 }
799 else {
800 var error = new ValidationError();
801 error.value = value;
802 error.property = metadata.propertyName;
803 error.target = metadata.target;
804 var _b = _this.createValidationError(metadata.target, value, metadata), type = _b[0], message = _b[1];
805 error.constraints = (_a = {},
806 _a[type] = message,
807 _a);
808 errors.push(error);
809 }
810 });
811 };
812 ValidationExecutor.prototype.mapContexts = function (object, value, metadatas, error) {
813 var _this = this;
814 return metadatas.forEach(function (metadata) {
815 if (metadata.context) {
816 var customConstraint = void 0;
817 if (metadata.type === ValidationTypes.CUSTOM_VALIDATION) {
818 var customConstraints = _this.metadataStorage.getTargetValidatorConstraints(metadata.constraintCls);
819 customConstraint = customConstraints[0];
820 }
821 var type = _this.getConstraintType(metadata, customConstraint);
822 if (error.constraints[type]) {
823 if (!error.contexts) {
824 error.contexts = {};
825 }
826 error.contexts[type] = Object.assign(error.contexts[type] || {}, metadata.context);
827 }
828 }
829 });
830 };
831 ValidationExecutor.prototype.createValidationError = function (object, value, metadata, customValidatorMetadata) {
832 var targetName = object.constructor ? object.constructor.name : undefined;
833 var type = this.getConstraintType(metadata, customValidatorMetadata);
834 var validationArguments = {
835 targetName: targetName,
836 property: metadata.propertyName,
837 object: object,
838 value: value,
839 constraints: metadata.constraints,
840 };
841 var titles = (this.validatorOptions && this.validatorOptions.titles) || {};
842 var message = metadata.message || '';
843 if (!metadata.message &&
844 (!this.validatorOptions || (this.validatorOptions && !this.validatorOptions.dismissDefaultMessages))) {
845 if (customValidatorMetadata && customValidatorMetadata.instance.defaultMessage instanceof Function) {
846 message = customValidatorMetadata.instance.defaultMessage(validationArguments);
847 }
848 }
849 if (typeof message === 'string') {
850 var messages_1 = (this.validatorOptions && this.validatorOptions.messages) || getClassValidatorMessages();
851 Object.keys(messages_1).forEach(function (messageKey) {
852 var key = getText(messageKey);
853 var value = messages_1[messageKey] || messageKey;
854 message = message.split(key).join(value);
855 });
856 }
857 var messageString = ValidationUtils.replaceMessageSpecialTokens(message, validationArguments, titles);
858 return [type, messageString];
859 };
860 ValidationExecutor.prototype.getConstraintType = function (metadata, customValidatorMetadata) {
861 var type = customValidatorMetadata && customValidatorMetadata.name ? customValidatorMetadata.name : metadata.type;
862 return type;
863 };
864 return ValidationExecutor;
865 }());
866
867 var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
868 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
869 return new (P || (P = Promise))(function (resolve, reject) {
870 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
871 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
872 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
873 step((generator = generator.apply(thisArg, _arguments || [])).next());
874 });
875 };
876 var __generator = (undefined && undefined.__generator) || function (thisArg, body) {
877 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
878 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
879 function verb(n) { return function (v) { return step([n, v]); }; }
880 function step(op) {
881 if (f) throw new TypeError("Generator is already executing.");
882 while (_) try {
883 if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
884 if (y = 0, t) op = [op[0] & 2, t.value];
885 switch (op[0]) {
886 case 0: case 1: t = op; break;
887 case 4: _.label++; return { value: op[1], done: false };
888 case 5: _.label++; y = op[1]; op = [0]; continue;
889 case 7: op = _.ops.pop(); _.trys.pop(); continue;
890 default:
891 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
892 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
893 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
894 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
895 if (t[2]) _.ops.pop();
896 _.trys.pop(); continue;
897 }
898 op = body.call(thisArg, _);
899 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
900 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
901 }
902 };
903 /**
904 * Validator performs validation of the given object based on its metadata.
905 */
906 var Validator = /** @class */ (function () {
907 function Validator() {
908 }
909 /**
910 * Performs validation of the given object based on decorators or validation schema.
911 */
912 Validator.prototype.validate = function (objectOrSchemaName, objectOrValidationOptions, maybeValidatorOptions) {
913 return this.coreValidate(objectOrSchemaName, objectOrValidationOptions, maybeValidatorOptions);
914 };
915 /**
916 * Performs validation of the given object based on decorators or validation schema and reject on error.
917 */
918 Validator.prototype.validateOrReject = function (objectOrSchemaName, objectOrValidationOptions, maybeValidatorOptions) {
919 return __awaiter(this, void 0, void 0, function () {
920 var errors;
921 return __generator(this, function (_a) {
922 switch (_a.label) {
923 case 0: return [4 /*yield*/, this.coreValidate(objectOrSchemaName, objectOrValidationOptions, maybeValidatorOptions)];
924 case 1:
925 errors = _a.sent();
926 if (errors.length)
927 return [2 /*return*/, Promise.reject(errors)];
928 return [2 /*return*/];
929 }
930 });
931 });
932 };
933 /**
934 * Performs validation of the given object based on decorators or validation schema.
935 */
936 Validator.prototype.validateSync = function (objectOrSchemaName, objectOrValidationOptions, maybeValidatorOptions) {
937 var object = typeof objectOrSchemaName === 'string' ? objectOrValidationOptions : objectOrSchemaName;
938 var options = typeof objectOrSchemaName === 'string' ? maybeValidatorOptions : objectOrValidationOptions;
939 var schema = typeof objectOrSchemaName === 'string' ? objectOrSchemaName : undefined;
940 var executor = new ValidationExecutor(this, options);
941 executor.ignoreAsyncValidations = true;
942 var validationErrors = [];
943 executor.execute(object, schema, validationErrors);
944 return executor.stripEmptyErrors(validationErrors);
945 };
946 // -------------------------------------------------------------------------
947 // Private Properties
948 // -------------------------------------------------------------------------
949 /**
950 * Performs validation of the given object based on decorators or validation schema.
951 * Common method for `validateOrReject` and `validate` methods.
952 */
953 Validator.prototype.coreValidate = function (objectOrSchemaName, objectOrValidationOptions, maybeValidatorOptions) {
954 var object = typeof objectOrSchemaName === 'string' ? objectOrValidationOptions : objectOrSchemaName;
955 var options = typeof objectOrSchemaName === 'string' ? maybeValidatorOptions : objectOrValidationOptions;
956 var schema = typeof objectOrSchemaName === 'string' ? objectOrSchemaName : undefined;
957 var executor = new ValidationExecutor(this, options);
958 var validationErrors = [];
959 executor.execute(object, schema, validationErrors);
960 return Promise.all(executor.awaitingPromises).then(function () {
961 return executor.stripEmptyErrors(validationErrors);
962 });
963 };
964 return Validator;
965 }());
966
967 /**
968 * If object has both allowed and not allowed properties a validation error will be thrown.
969 */
970 function Allow(validationOptions) {
971 return function (object, propertyName) {
972 var args = {
973 type: ValidationTypes.WHITELIST,
974 target: object.constructor,
975 propertyName: propertyName,
976 validationOptions: validationOptions,
977 };
978 getMetadataStorage().addValidationMetadata(new ValidationMetadata(args));
979 };
980 }
981
982 /**
983 * This metadata interface contains information for custom validators.
984 */
985 var ConstraintMetadata = /** @class */ (function () {
986 // -------------------------------------------------------------------------
987 // Constructor
988 // -------------------------------------------------------------------------
989 function ConstraintMetadata(target, name, async) {
990 if (async === void 0) { async = false; }
991 this.target = target;
992 this.name = name;
993 this.async = async;
994 }
995 Object.defineProperty(ConstraintMetadata.prototype, "instance", {
996 // -------------------------------------------------------------------------
997 // Accessors
998 // -------------------------------------------------------------------------
999 /**
1000 * Instance of the target custom validation class which performs validation.
1001 */
1002 get: function () {
1003 return getFromContainer(this.target);
1004 },
1005 enumerable: false,
1006 configurable: true
1007 });
1008 return ConstraintMetadata;
1009 }());
1010
1011 /**
1012 * Registers a custom validation decorator.
1013 */
1014 function registerDecorator(options) {
1015 var constraintCls;
1016 if (options.validator instanceof Function) {
1017 constraintCls = options.validator;
1018 var constraintClasses = getFromContainer(MetadataStorage).getTargetValidatorConstraints(options.validator);
1019 if (constraintClasses.length > 1) {
1020 throw "More than one implementation of ValidatorConstraintInterface found for validator on: ".concat(options.target.name, ":").concat(options.propertyName);
1021 }
1022 }
1023 else {
1024 var validator_1 = options.validator;
1025 constraintCls = /** @class */ (function () {
1026 function CustomConstraint() {
1027 }
1028 CustomConstraint.prototype.validate = function (value, validationArguments) {
1029 return validator_1.validate(value, validationArguments);
1030 };
1031 CustomConstraint.prototype.defaultMessage = function (validationArguments) {
1032 if (validator_1.defaultMessage) {
1033 return validator_1.defaultMessage(validationArguments);
1034 }
1035 return '';
1036 };
1037 return CustomConstraint;
1038 }());
1039 getMetadataStorage().addConstraintMetadata(new ConstraintMetadata(constraintCls, options.name, options.async));
1040 }
1041 var validationMetadataArgs = {
1042 type: options.name && ValidationTypes.isValid(options.name) ? options.name : ValidationTypes.CUSTOM_VALIDATION,
1043 target: options.target,
1044 propertyName: options.propertyName,
1045 validationOptions: options.options,
1046 constraintCls: constraintCls,
1047 constraints: options.constraints,
1048 };
1049 getMetadataStorage().addValidationMetadata(new ValidationMetadata(validationMetadataArgs));
1050 }
1051
1052 function buildMessage(impl, validationOptions) {
1053 return function (validationArguments) {
1054 var eachPrefix = validationOptions && validationOptions.each ? 'each value in ' : '';
1055 return impl(eachPrefix, validationArguments);
1056 };
1057 }
1058 function ValidateBy(options, validationOptions) {
1059 return function (object, propertyName) {
1060 registerDecorator({
1061 name: options.name,
1062 target: object.constructor,
1063 propertyName: propertyName,
1064 options: validationOptions,
1065 constraints: options.constraints,
1066 validator: options.validator,
1067 });
1068 };
1069 }
1070
1071 // isDefined is (yet) a special case
1072 var IS_DEFINED = ValidationTypes.IS_DEFINED;
1073 /**
1074 * Checks if value is defined (!== undefined, !== null).
1075 */
1076 function isDefined(value) {
1077 return value !== undefined && value !== null;
1078 }
1079 /**
1080 * Checks if value is defined (!== undefined, !== null).
1081 */
1082 function IsDefined(validationOptions) {
1083 return ValidateBy({
1084 name: IS_DEFINED,
1085 validator: {
1086 validate: function (value) { return isDefined(value); },
1087 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property should not be null or undefined'); }, validationOptions),
1088 },
1089 }, validationOptions);
1090 }
1091
1092 /**
1093 * Checks if value is missing and if so, ignores all validators.
1094 */
1095 function IsOptional(validationOptions) {
1096 return function (object, propertyName) {
1097 var args = {
1098 type: ValidationTypes.CONDITIONAL_VALIDATION,
1099 target: object.constructor,
1100 propertyName: propertyName,
1101 constraints: [
1102 function (object, value) {
1103 return object[propertyName] !== null && object[propertyName] !== undefined;
1104 },
1105 ],
1106 validationOptions: validationOptions,
1107 };
1108 getMetadataStorage().addValidationMetadata(new ValidationMetadata(args));
1109 };
1110 }
1111
1112 /**
1113 * Registers custom validator class.
1114 */
1115 function ValidatorConstraint(options) {
1116 return function (target) {
1117 var isAsync = options && options.async;
1118 var name = options && options.name ? options.name : '';
1119 if (!name) {
1120 name = target.name;
1121 if (!name)
1122 // generate name if it was not given
1123 name = name.replace(/\.?([A-Z]+)/g, function (x, y) { return '_' + y.toLowerCase(); }).replace(/^_/, '');
1124 }
1125 var metadata = new ConstraintMetadata(target, name, isAsync);
1126 getMetadataStorage().addConstraintMetadata(metadata);
1127 };
1128 }
1129 function Validate(constraintClass, constraintsOrValidationOptions, maybeValidationOptions) {
1130 return function (object, propertyName) {
1131 var args = {
1132 type: ValidationTypes.CUSTOM_VALIDATION,
1133 target: object.constructor,
1134 propertyName: propertyName,
1135 constraintCls: constraintClass,
1136 constraints: Array.isArray(constraintsOrValidationOptions) ? constraintsOrValidationOptions : undefined,
1137 validationOptions: !Array.isArray(constraintsOrValidationOptions)
1138 ? constraintsOrValidationOptions
1139 : maybeValidationOptions,
1140 };
1141 getMetadataStorage().addValidationMetadata(new ValidationMetadata(args));
1142 };
1143 }
1144
1145 /**
1146 * Ignores the other validators on a property when the provided condition function returns false.
1147 */
1148 function ValidateIf(condition, validationOptions) {
1149 return function (object, propertyName) {
1150 var args = {
1151 type: ValidationTypes.CONDITIONAL_VALIDATION,
1152 target: object.constructor,
1153 propertyName: propertyName,
1154 constraints: [condition],
1155 validationOptions: validationOptions,
1156 };
1157 getMetadataStorage().addValidationMetadata(new ValidationMetadata(args));
1158 };
1159 }
1160
1161 var __assign = (undefined && undefined.__assign) || function () {
1162 __assign = Object.assign || function(t) {
1163 for (var s, i = 1, n = arguments.length; i < n; i++) {
1164 s = arguments[i];
1165 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
1166 t[p] = s[p];
1167 }
1168 return t;
1169 };
1170 return __assign.apply(this, arguments);
1171 };
1172 /**
1173 * Objects / object arrays marked with this decorator will also be validated.
1174 */
1175 function ValidateNested(validationOptions) {
1176 var opts = __assign({}, validationOptions);
1177 var eachPrefix = opts.each ? getText('each value in ') : '';
1178 opts.message = opts.message || eachPrefix + getText('nested property $property must be either object or array');
1179 return function (object, propertyName) {
1180 var args = {
1181 type: ValidationTypes.NESTED_VALIDATION,
1182 target: object.constructor,
1183 propertyName: propertyName,
1184 validationOptions: opts,
1185 };
1186 getMetadataStorage().addValidationMetadata(new ValidationMetadata(args));
1187 };
1188 }
1189
1190 /**
1191 * Resolve promise before validation
1192 */
1193 function ValidatePromise(validationOptions) {
1194 return function (object, propertyName) {
1195 var args = {
1196 type: ValidationTypes.PROMISE_VALIDATION,
1197 target: object.constructor,
1198 propertyName: propertyName,
1199 validationOptions: validationOptions,
1200 };
1201 getMetadataStorage().addValidationMetadata(new ValidationMetadata(args));
1202 };
1203 }
1204
1205 function getDefaultExportFromCjs (x) {
1206 return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
1207 }
1208
1209 var isLatLong$1 = {exports: {}};
1210
1211 var assertString = {exports: {}};
1212
1213 (function (module, exports) {
1214
1215 Object.defineProperty(exports, "__esModule", {
1216 value: true
1217 });
1218 exports.default = assertString;
1219
1220 function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
1221
1222 function assertString(input) {
1223 var isString = typeof input === 'string' || input instanceof String;
1224
1225 if (!isString) {
1226 var invalidType = _typeof(input);
1227
1228 if (input === null) invalidType = 'null';else if (invalidType === 'object') invalidType = input.constructor.name;
1229 throw new TypeError("Expected a string but received a ".concat(invalidType));
1230 }
1231 }
1232
1233 module.exports = exports.default;
1234 module.exports.default = exports.default;
1235 }(assertString, assertString.exports));
1236
1237 var merge = {exports: {}};
1238
1239 (function (module, exports) {
1240
1241 Object.defineProperty(exports, "__esModule", {
1242 value: true
1243 });
1244 exports.default = merge;
1245
1246 function merge() {
1247 var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1248 var defaults = arguments.length > 1 ? arguments[1] : undefined;
1249
1250 for (var key in defaults) {
1251 if (typeof obj[key] === 'undefined') {
1252 obj[key] = defaults[key];
1253 }
1254 }
1255
1256 return obj;
1257 }
1258
1259 module.exports = exports.default;
1260 module.exports.default = exports.default;
1261 }(merge, merge.exports));
1262
1263 (function (module, exports) {
1264
1265 Object.defineProperty(exports, "__esModule", {
1266 value: true
1267 });
1268 exports.default = isLatLong;
1269
1270 var _assertString = _interopRequireDefault(assertString.exports);
1271
1272 var _merge = _interopRequireDefault(merge.exports);
1273
1274 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1275
1276 var lat = /^\(?[+-]?(90(\.0+)?|[1-8]?\d(\.\d+)?)$/;
1277 var long = /^\s?[+-]?(180(\.0+)?|1[0-7]\d(\.\d+)?|\d{1,2}(\.\d+)?)\)?$/;
1278 var latDMS = /^(([1-8]?\d)\D+([1-5]?\d|60)\D+([1-5]?\d|60)(\.\d+)?|90\D+0\D+0)\D+[NSns]?$/i;
1279 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;
1280 var defaultLatLongOptions = {
1281 checkDMS: false
1282 };
1283
1284 function isLatLong(str, options) {
1285 (0, _assertString.default)(str);
1286 options = (0, _merge.default)(options, defaultLatLongOptions);
1287 if (!str.includes(',')) return false;
1288 var pair = str.split(',');
1289 if (pair[0].startsWith('(') && !pair[1].endsWith(')') || pair[1].endsWith(')') && !pair[0].startsWith('(')) return false;
1290
1291 if (options.checkDMS) {
1292 return latDMS.test(pair[0]) && longDMS.test(pair[1]);
1293 }
1294
1295 return lat.test(pair[0]) && long.test(pair[1]);
1296 }
1297
1298 module.exports = exports.default;
1299 module.exports.default = exports.default;
1300 }(isLatLong$1, isLatLong$1.exports));
1301
1302 var isLatLongValidator = /*@__PURE__*/getDefaultExportFromCjs(isLatLong$1.exports);
1303
1304 var IS_LATLONG = 'isLatLong';
1305 /**
1306 * Checks if a value is string in format a "latitude,longitude".
1307 */
1308 function isLatLong(value) {
1309 return typeof value === 'string' && isLatLongValidator(value);
1310 }
1311 /**
1312 * Checks if a value is string in format a "latitude,longitude".
1313 */
1314 function IsLatLong(validationOptions) {
1315 return ValidateBy({
1316 name: IS_LATLONG,
1317 validator: {
1318 validate: function (value, args) { return isLatLong(value); },
1319 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be a latitude,longitude string'); }, validationOptions),
1320 },
1321 }, validationOptions);
1322 }
1323
1324 var IS_LATITUDE = 'isLatitude';
1325 /**
1326 * Checks if a given value is a latitude.
1327 */
1328 function isLatitude(value) {
1329 return (typeof value === 'number' || typeof value === 'string') && isLatLong("".concat(value, ",0"));
1330 }
1331 /**
1332 * Checks if a given value is a latitude.
1333 */
1334 function IsLatitude(validationOptions) {
1335 return ValidateBy({
1336 name: IS_LATITUDE,
1337 validator: {
1338 validate: function (value, args) { return isLatitude(value); },
1339 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be a latitude string or number'); }, validationOptions),
1340 },
1341 }, validationOptions);
1342 }
1343
1344 var IS_LONGITUDE = 'isLongitude';
1345 /**
1346 * Checks if a given value is a longitude.
1347 */
1348 function isLongitude(value) {
1349 return (typeof value === 'number' || typeof value === 'string') && isLatLong("0,".concat(value));
1350 }
1351 /**
1352 * Checks if a given value is a longitude.
1353 */
1354 function IsLongitude(validationOptions) {
1355 return ValidateBy({
1356 name: IS_LONGITUDE,
1357 validator: {
1358 validate: function (value, args) { return isLongitude(value); },
1359 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be a longitude string or number'); }, validationOptions),
1360 },
1361 }, validationOptions);
1362 }
1363
1364 var EQUALS = 'equals';
1365 /**
1366 * Checks if value matches ("===") the comparison.
1367 */
1368 function equals(value, comparison) {
1369 return value === comparison;
1370 }
1371 /**
1372 * Checks if value matches ("===") the comparison.
1373 */
1374 function Equals(comparison, validationOptions) {
1375 return ValidateBy({
1376 name: EQUALS,
1377 constraints: [comparison],
1378 validator: {
1379 validate: function (value, args) { return equals(value, args.constraints[0]); },
1380 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be equal to $constraint1'); }, validationOptions),
1381 },
1382 }, validationOptions);
1383 }
1384
1385 var NOT_EQUALS = 'notEquals';
1386 /**
1387 * Checks if value does not match ("!==") the comparison.
1388 */
1389 function notEquals(value, comparison) {
1390 return value !== comparison;
1391 }
1392 /**
1393 * Checks if value does not match ("!==") the comparison.
1394 */
1395 function NotEquals(comparison, validationOptions) {
1396 return ValidateBy({
1397 name: NOT_EQUALS,
1398 constraints: [comparison],
1399 validator: {
1400 validate: function (value, args) { return notEquals(value, args.constraints[0]); },
1401 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property should not be equal to $constraint1'); }, validationOptions),
1402 },
1403 }, validationOptions);
1404 }
1405
1406 var IS_EMPTY = 'isEmpty';
1407 /**
1408 * Checks if given value is empty (=== '', === null, === undefined).
1409 */
1410 function isEmpty(value) {
1411 return value === '' || value === null || value === undefined;
1412 }
1413 /**
1414 * Checks if given value is empty (=== '', === null, === undefined).
1415 */
1416 function IsEmpty(validationOptions) {
1417 return ValidateBy({
1418 name: IS_EMPTY,
1419 validator: {
1420 validate: function (value, args) { return isEmpty(value); },
1421 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be empty'); }, validationOptions),
1422 },
1423 }, validationOptions);
1424 }
1425
1426 var IS_NOT_EMPTY = 'isNotEmpty';
1427 /**
1428 * Checks if given value is not empty (!== '', !== null, !== undefined).
1429 */
1430 function isNotEmpty(value) {
1431 return value !== '' && value !== null && value !== undefined;
1432 }
1433 /**
1434 * Checks if given value is not empty (!== '', !== null, !== undefined).
1435 */
1436 function IsNotEmpty(validationOptions) {
1437 return ValidateBy({
1438 name: IS_NOT_EMPTY,
1439 validator: {
1440 validate: function (value, args) { return isNotEmpty(value); },
1441 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property should not be empty'); }, validationOptions),
1442 },
1443 }, validationOptions);
1444 }
1445
1446 var IS_IN = 'isIn';
1447 /**
1448 * Checks if given value is in a array of allowed values.
1449 */
1450 function isIn(value, possibleValues) {
1451 return !Array.isArray(possibleValues) || possibleValues.some(function (possibleValue) { return possibleValue === value; });
1452 }
1453 /**
1454 * Checks if given value is in a array of allowed values.
1455 */
1456 function IsIn(values, validationOptions) {
1457 return ValidateBy({
1458 name: IS_IN,
1459 constraints: [values],
1460 validator: {
1461 validate: function (value, args) { return isIn(value, args.constraints[0]); },
1462 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be one of the following values: $constraint1'); }, validationOptions),
1463 },
1464 }, validationOptions);
1465 }
1466
1467 var IS_NOT_IN = 'isNotIn';
1468 /**
1469 * Checks if given value not in a array of allowed values.
1470 */
1471 function isNotIn(value, possibleValues) {
1472 return !Array.isArray(possibleValues) || !possibleValues.some(function (possibleValue) { return possibleValue === value; });
1473 }
1474 /**
1475 * Checks if given value not in a array of allowed values.
1476 */
1477 function IsNotIn(values, validationOptions) {
1478 return ValidateBy({
1479 name: IS_NOT_IN,
1480 constraints: [values],
1481 validator: {
1482 validate: function (value, args) { return isNotIn(value, args.constraints[0]); },
1483 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property should not be one of the following values: $constraint1'); }, validationOptions),
1484 },
1485 }, validationOptions);
1486 }
1487
1488 var isDivisibleBy$1 = {exports: {}};
1489
1490 var toFloat = {exports: {}};
1491
1492 var isFloat$1 = {};
1493
1494 var alpha$1 = {};
1495
1496 Object.defineProperty(alpha$1, "__esModule", {
1497 value: true
1498 });
1499 alpha$1.commaDecimal = alpha$1.dotDecimal = alpha$1.farsiLocales = alpha$1.arabicLocales = alpha$1.englishLocales = alpha$1.decimal = alpha$1.alphanumeric = alpha$1.alpha = void 0;
1500 var alpha = {
1501 'en-US': /^[A-Z]+$/i,
1502 'az-AZ': /^[A-VXYZÇƏĞİıÖŞÜ]+$/i,
1503 'bg-BG': /^[А-Я]+$/i,
1504 'cs-CZ': /^[A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]+$/i,
1505 'da-DK': /^[A-ZÆØÅ]+$/i,
1506 'de-DE': /^[A-ZÄÖÜß]+$/i,
1507 'el-GR': /^[Α-ώ]+$/i,
1508 'es-ES': /^[A-ZÁÉÍÑÓÚÜ]+$/i,
1509 'fa-IR': /^[ابپتثجچحخدذرزژسشصضطظعغفقکگلمنوهی]+$/i,
1510 'fi-FI': /^[A-ZÅÄÖ]+$/i,
1511 'fr-FR': /^[A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i,
1512 'it-IT': /^[A-ZÀÉÈÌÎÓÒÙ]+$/i,
1513 'nb-NO': /^[A-ZÆØÅ]+$/i,
1514 'nl-NL': /^[A-ZÁÉËÏÓÖÜÚ]+$/i,
1515 'nn-NO': /^[A-ZÆØÅ]+$/i,
1516 'hu-HU': /^[A-ZÁÉÍÓÖŐÚÜŰ]+$/i,
1517 'pl-PL': /^[A-ZĄĆĘŚŁŃÓŻŹ]+$/i,
1518 'pt-PT': /^[A-ZÃÁÀÂÄÇÉÊËÍÏÕÓÔÖÚÜ]+$/i,
1519 'ru-RU': /^[А-ЯЁ]+$/i,
1520 'sl-SI': /^[A-ZČĆĐŠŽ]+$/i,
1521 'sk-SK': /^[A-ZÁČĎÉÍŇÓŠŤÚÝŽĹŔĽÄÔ]+$/i,
1522 'sr-RS@latin': /^[A-ZČĆŽŠĐ]+$/i,
1523 'sr-RS': /^[А-ЯЂЈЉЊЋЏ]+$/i,
1524 'sv-SE': /^[A-ZÅÄÖ]+$/i,
1525 'th-TH': /^[ก-๐\s]+$/i,
1526 'tr-TR': /^[A-ZÇĞİıÖŞÜ]+$/i,
1527 'uk-UA': /^[А-ЩЬЮЯЄIЇҐі]+$/i,
1528 'vi-VN': /^[A-ZÀÁẠẢÃÂẦẤẬẨẪĂẰẮẶẲẴĐÈÉẸẺẼÊỀẾỆỂỄÌÍỊỈĨÒÓỌỎÕÔỒỐỘỔỖƠỜỚỢỞỠÙÚỤỦŨƯỪỨỰỬỮỲÝỴỶỸ]+$/i,
1529 'ku-IQ': /^[ئابپتجچحخدرڕزژسشعغفڤقکگلڵمنوۆھەیێيطؤثآإأكضصةظذ]+$/i,
1530 ar: /^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/,
1531 he: /^[א-ת]+$/,
1532 fa: /^['آاءأؤئبپتثجچحخدذرزژسشصضطظعغفقکگلمنوهةی']+$/i,
1533 'hi-IN': /^[\u0900-\u0961]+[\u0972-\u097F]*$/i
1534 };
1535 alpha$1.alpha = alpha;
1536 var alphanumeric = {
1537 'en-US': /^[0-9A-Z]+$/i,
1538 'az-AZ': /^[0-9A-VXYZÇƏĞİıÖŞÜ]+$/i,
1539 'bg-BG': /^[0-9А-Я]+$/i,
1540 'cs-CZ': /^[0-9A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]+$/i,
1541 'da-DK': /^[0-9A-ZÆØÅ]+$/i,
1542 'de-DE': /^[0-9A-ZÄÖÜß]+$/i,
1543 'el-GR': /^[0-9Α-ω]+$/i,
1544 'es-ES': /^[0-9A-ZÁÉÍÑÓÚÜ]+$/i,
1545 'fi-FI': /^[0-9A-ZÅÄÖ]+$/i,
1546 'fr-FR': /^[0-9A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i,
1547 'it-IT': /^[0-9A-ZÀÉÈÌÎÓÒÙ]+$/i,
1548 'hu-HU': /^[0-9A-ZÁÉÍÓÖŐÚÜŰ]+$/i,
1549 'nb-NO': /^[0-9A-ZÆØÅ]+$/i,
1550 'nl-NL': /^[0-9A-ZÁÉËÏÓÖÜÚ]+$/i,
1551 'nn-NO': /^[0-9A-ZÆØÅ]+$/i,
1552 'pl-PL': /^[0-9A-ZĄĆĘŚŁŃÓŻŹ]+$/i,
1553 'pt-PT': /^[0-9A-ZÃÁÀÂÄÇÉÊËÍÏÕÓÔÖÚÜ]+$/i,
1554 'ru-RU': /^[0-9А-ЯЁ]+$/i,
1555 'sl-SI': /^[0-9A-ZČĆĐŠŽ]+$/i,
1556 'sk-SK': /^[0-9A-ZÁČĎÉÍŇÓŠŤÚÝŽĹŔĽÄÔ]+$/i,
1557 'sr-RS@latin': /^[0-9A-ZČĆŽŠĐ]+$/i,
1558 'sr-RS': /^[0-9А-ЯЂЈЉЊЋЏ]+$/i,
1559 'sv-SE': /^[0-9A-ZÅÄÖ]+$/i,
1560 'th-TH': /^[ก-๙\s]+$/i,
1561 'tr-TR': /^[0-9A-ZÇĞİıÖŞÜ]+$/i,
1562 'uk-UA': /^[0-9А-ЩЬЮЯЄIЇҐі]+$/i,
1563 'ku-IQ': /^[٠١٢٣٤٥٦٧٨٩0-9ئابپتجچحخدرڕزژسشعغفڤقکگلڵمنوۆھەیێيطؤثآإأكضصةظذ]+$/i,
1564 'vi-VN': /^[0-9A-ZÀÁẠẢÃÂẦẤẬẨẪĂẰẮẶẲẴĐÈÉẸẺẼÊỀẾỆỂỄÌÍỊỈĨÒÓỌỎÕÔỒỐỘỔỖƠỜỚỢỞỠÙÚỤỦŨƯỪỨỰỬỮỲÝỴỶỸ]+$/i,
1565 ar: /^[٠١٢٣٤٥٦٧٨٩0-9ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/,
1566 he: /^[0-9א-ת]+$/,
1567 fa: /^['0-9آاءأؤئبپتثجچحخدذرزژسشصضطظعغفقکگلمنوهةی۱۲۳۴۵۶۷۸۹۰']+$/i,
1568 'hi-IN': /^[\u0900-\u0963]+[\u0966-\u097F]*$/i
1569 };
1570 alpha$1.alphanumeric = alphanumeric;
1571 var decimal = {
1572 'en-US': '.',
1573 ar: '٫'
1574 };
1575 alpha$1.decimal = decimal;
1576 var englishLocales = ['AU', 'GB', 'HK', 'IN', 'NZ', 'ZA', 'ZM'];
1577 alpha$1.englishLocales = englishLocales;
1578
1579 for (var locale, i = 0; i < englishLocales.length; i++) {
1580 locale = "en-".concat(englishLocales[i]);
1581 alpha[locale] = alpha['en-US'];
1582 alphanumeric[locale] = alphanumeric['en-US'];
1583 decimal[locale] = decimal['en-US'];
1584 } // Source: http://www.localeplanet.com/java/
1585
1586
1587 var arabicLocales = ['AE', 'BH', 'DZ', 'EG', 'IQ', 'JO', 'KW', 'LB', 'LY', 'MA', 'QM', 'QA', 'SA', 'SD', 'SY', 'TN', 'YE'];
1588 alpha$1.arabicLocales = arabicLocales;
1589
1590 for (var _locale, _i = 0; _i < arabicLocales.length; _i++) {
1591 _locale = "ar-".concat(arabicLocales[_i]);
1592 alpha[_locale] = alpha.ar;
1593 alphanumeric[_locale] = alphanumeric.ar;
1594 decimal[_locale] = decimal.ar;
1595 }
1596
1597 var farsiLocales = ['IR', 'AF'];
1598 alpha$1.farsiLocales = farsiLocales;
1599
1600 for (var _locale2, _i2 = 0; _i2 < farsiLocales.length; _i2++) {
1601 _locale2 = "fa-".concat(farsiLocales[_i2]);
1602 alphanumeric[_locale2] = alphanumeric.fa;
1603 decimal[_locale2] = decimal.ar;
1604 } // Source: https://en.wikipedia.org/wiki/Decimal_mark
1605
1606
1607 var dotDecimal = ['ar-EG', 'ar-LB', 'ar-LY'];
1608 alpha$1.dotDecimal = dotDecimal;
1609 var commaDecimal = ['bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en-ZM', 'es-ES', 'fr-CA', 'fr-FR', 'id-ID', 'it-IT', 'ku-IQ', 'hi-IN', 'hu-HU', 'nb-NO', 'nn-NO', 'nl-NL', 'pl-PL', 'pt-PT', 'ru-RU', 'sl-SI', 'sr-RS@latin', 'sr-RS', 'sv-SE', 'tr-TR', 'uk-UA', 'vi-VN'];
1610 alpha$1.commaDecimal = commaDecimal;
1611
1612 for (var _i3 = 0; _i3 < dotDecimal.length; _i3++) {
1613 decimal[dotDecimal[_i3]] = decimal['en-US'];
1614 }
1615
1616 for (var _i4 = 0; _i4 < commaDecimal.length; _i4++) {
1617 decimal[commaDecimal[_i4]] = ',';
1618 }
1619
1620 alpha['fr-CA'] = alpha['fr-FR'];
1621 alphanumeric['fr-CA'] = alphanumeric['fr-FR'];
1622 alpha['pt-BR'] = alpha['pt-PT'];
1623 alphanumeric['pt-BR'] = alphanumeric['pt-PT'];
1624 decimal['pt-BR'] = decimal['pt-PT']; // see #862
1625
1626 alpha['pl-Pl'] = alpha['pl-PL'];
1627 alphanumeric['pl-Pl'] = alphanumeric['pl-PL'];
1628 decimal['pl-Pl'] = decimal['pl-PL']; // see #1455
1629
1630 alpha['fa-AF'] = alpha.fa;
1631
1632 Object.defineProperty(isFloat$1, "__esModule", {
1633 value: true
1634 });
1635 isFloat$1.default = isFloat;
1636 isFloat$1.locales = void 0;
1637
1638 var _assertString$8 = _interopRequireDefault$8(assertString.exports);
1639
1640 var _alpha$2 = alpha$1;
1641
1642 function _interopRequireDefault$8(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1643
1644 function isFloat(str, options) {
1645 (0, _assertString$8.default)(str);
1646 options = options || {};
1647 var float = new RegExp("^(?:[-+])?(?:[0-9]+)?(?:\\".concat(options.locale ? _alpha$2.decimal[options.locale] : '.', "[0-9]*)?(?:[eE][\\+\\-]?(?:[0-9]+))?$"));
1648
1649 if (str === '' || str === '.' || str === '-' || str === '+') {
1650 return false;
1651 }
1652
1653 var value = parseFloat(str.replace(',', '.'));
1654 return float.test(str) && (!options.hasOwnProperty('min') || value >= options.min) && (!options.hasOwnProperty('max') || value <= options.max) && (!options.hasOwnProperty('lt') || value < options.lt) && (!options.hasOwnProperty('gt') || value > options.gt);
1655 }
1656
1657 var locales$5 = Object.keys(_alpha$2.decimal);
1658 isFloat$1.locales = locales$5;
1659
1660 (function (module, exports) {
1661
1662 Object.defineProperty(exports, "__esModule", {
1663 value: true
1664 });
1665 exports.default = toFloat;
1666
1667 var _isFloat = _interopRequireDefault(isFloat$1);
1668
1669 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1670
1671 function toFloat(str) {
1672 if (!(0, _isFloat.default)(str)) return NaN;
1673 return parseFloat(str);
1674 }
1675
1676 module.exports = exports.default;
1677 module.exports.default = exports.default;
1678 }(toFloat, toFloat.exports));
1679
1680 (function (module, exports) {
1681
1682 Object.defineProperty(exports, "__esModule", {
1683 value: true
1684 });
1685 exports.default = isDivisibleBy;
1686
1687 var _assertString = _interopRequireDefault(assertString.exports);
1688
1689 var _toFloat = _interopRequireDefault(toFloat.exports);
1690
1691 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1692
1693 function isDivisibleBy(str, num) {
1694 (0, _assertString.default)(str);
1695 return (0, _toFloat.default)(str) % parseInt(num, 10) === 0;
1696 }
1697
1698 module.exports = exports.default;
1699 module.exports.default = exports.default;
1700 }(isDivisibleBy$1, isDivisibleBy$1.exports));
1701
1702 var isDivisibleByValidator = /*@__PURE__*/getDefaultExportFromCjs(isDivisibleBy$1.exports);
1703
1704 var IS_DIVISIBLE_BY = 'isDivisibleBy';
1705 /**
1706 * Checks if value is a number that's divisible by another.
1707 */
1708 function isDivisibleBy(value, num) {
1709 return typeof value === 'number' && typeof num === 'number' && isDivisibleByValidator(String(value), num);
1710 }
1711 /**
1712 * Checks if value is a number that's divisible by another.
1713 */
1714 function IsDivisibleBy(num, validationOptions) {
1715 return ValidateBy({
1716 name: IS_DIVISIBLE_BY,
1717 constraints: [num],
1718 validator: {
1719 validate: function (value, args) { return isDivisibleBy(value, args.constraints[0]); },
1720 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be divisible by $constraint1'); }, validationOptions),
1721 },
1722 }, validationOptions);
1723 }
1724
1725 var IS_POSITIVE = 'isPositive';
1726 /**
1727 * Checks if the value is a positive number greater than zero.
1728 */
1729 function isPositive(value) {
1730 return typeof value === 'number' && value > 0;
1731 }
1732 /**
1733 * Checks if the value is a positive number greater than zero.
1734 */
1735 function IsPositive(validationOptions) {
1736 return ValidateBy({
1737 name: IS_POSITIVE,
1738 validator: {
1739 validate: function (value, args) { return isPositive(value); },
1740 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be a positive number'); }, validationOptions),
1741 },
1742 }, validationOptions);
1743 }
1744
1745 var IS_NEGATIVE = 'isNegative';
1746 /**
1747 * Checks if the value is a negative number smaller than zero.
1748 */
1749 function isNegative(value) {
1750 return typeof value === 'number' && value < 0;
1751 }
1752 /**
1753 * Checks if the value is a negative number smaller than zero.
1754 */
1755 function IsNegative(validationOptions) {
1756 return ValidateBy({
1757 name: IS_NEGATIVE,
1758 validator: {
1759 validate: function (value, args) { return isNegative(value); },
1760 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be a negative number'); }, validationOptions),
1761 },
1762 }, validationOptions);
1763 }
1764
1765 var MAX = 'max';
1766 /**
1767 * Checks if the first number is less than or equal to the second.
1768 */
1769 function max(num, max) {
1770 return typeof num === 'number' && typeof max === 'number' && num <= max;
1771 }
1772 /**
1773 * Checks if the first number is less than or equal to the second.
1774 */
1775 function Max(maxValue, validationOptions) {
1776 return ValidateBy({
1777 name: MAX,
1778 constraints: [maxValue],
1779 validator: {
1780 validate: function (value, args) { return max(value, args.constraints[0]); },
1781 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must not be greater than $constraint1'); }, validationOptions),
1782 },
1783 }, validationOptions);
1784 }
1785
1786 var MIN = 'min';
1787 /**
1788 * Checks if the first number is greater than or equal to the second.
1789 */
1790 function min(num, min) {
1791 return typeof num === 'number' && typeof min === 'number' && num >= min;
1792 }
1793 /**
1794 * Checks if the first number is greater than or equal to the second.
1795 */
1796 function Min(minValue, validationOptions) {
1797 return ValidateBy({
1798 name: MIN,
1799 constraints: [minValue],
1800 validator: {
1801 validate: function (value, args) { return min(value, args.constraints[0]); },
1802 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must not be less than $constraint1'); }, validationOptions),
1803 },
1804 }, validationOptions);
1805 }
1806
1807 var MIN_DATE = 'minDate';
1808 /**
1809 * Checks if the value is a date that's after the specified date.
1810 */
1811 function minDate(date, minDate) {
1812 return date instanceof Date && date.getTime() >= minDate.getTime();
1813 }
1814 /**
1815 * Checks if the value is a date that's after the specified date.
1816 */
1817 function MinDate(date, validationOptions) {
1818 return ValidateBy({
1819 name: MIN_DATE,
1820 constraints: [date],
1821 validator: {
1822 validate: function (value, args) { return minDate(value, args.constraints[0]); },
1823 defaultMessage: buildMessage(function (eachPrefix) { return getText('minimal allowed date for ') + eachPrefix + getText('$property is $constraint1'); }, validationOptions),
1824 },
1825 }, validationOptions);
1826 }
1827
1828 var MAX_DATE = 'maxDate';
1829 /**
1830 * Checks if the value is a date that's before the specified date.
1831 */
1832 function maxDate(date, maxDate) {
1833 return date instanceof Date && date.getTime() <= maxDate.getTime();
1834 }
1835 /**
1836 * Checks if the value is a date that's after the specified date.
1837 */
1838 function MaxDate(date, validationOptions) {
1839 return ValidateBy({
1840 name: MAX_DATE,
1841 constraints: [date],
1842 validator: {
1843 validate: function (value, args) { return maxDate(value, args.constraints[0]); },
1844 defaultMessage: buildMessage(function (eachPrefix) { return getText('maximal allowed date for ') + eachPrefix + getText('$property is $constraint1'); }, validationOptions),
1845 },
1846 }, validationOptions);
1847 }
1848
1849 var contains$1 = {exports: {}};
1850
1851 var toString = {exports: {}};
1852
1853 (function (module, exports) {
1854
1855 Object.defineProperty(exports, "__esModule", {
1856 value: true
1857 });
1858 exports.default = toString;
1859
1860 function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
1861
1862 function toString(input) {
1863 if (_typeof(input) === 'object' && input !== null) {
1864 if (typeof input.toString === 'function') {
1865 input = input.toString();
1866 } else {
1867 input = '[object Object]';
1868 }
1869 } else if (input === null || typeof input === 'undefined' || isNaN(input) && !input.length) {
1870 input = '';
1871 }
1872
1873 return String(input);
1874 }
1875
1876 module.exports = exports.default;
1877 module.exports.default = exports.default;
1878 }(toString, toString.exports));
1879
1880 (function (module, exports) {
1881
1882 Object.defineProperty(exports, "__esModule", {
1883 value: true
1884 });
1885 exports.default = contains;
1886
1887 var _assertString = _interopRequireDefault(assertString.exports);
1888
1889 var _toString = _interopRequireDefault(toString.exports);
1890
1891 var _merge = _interopRequireDefault(merge.exports);
1892
1893 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1894
1895 var defaulContainsOptions = {
1896 ignoreCase: false,
1897 minOccurrences: 1
1898 };
1899
1900 function contains(str, elem, options) {
1901 (0, _assertString.default)(str);
1902 options = (0, _merge.default)(options, defaulContainsOptions);
1903
1904 if (options.ignoreCase) {
1905 return str.toLowerCase().split((0, _toString.default)(elem).toLowerCase()).length > options.minOccurrences;
1906 }
1907
1908 return str.split((0, _toString.default)(elem)).length > options.minOccurrences;
1909 }
1910
1911 module.exports = exports.default;
1912 module.exports.default = exports.default;
1913 }(contains$1, contains$1.exports));
1914
1915 var containsValidator = /*@__PURE__*/getDefaultExportFromCjs(contains$1.exports);
1916
1917 var CONTAINS = 'contains';
1918 /**
1919 * Checks if the string contains the seed.
1920 * If given value is not a string, then it returns false.
1921 */
1922 function contains(value, seed) {
1923 return typeof value === 'string' && containsValidator(value, seed);
1924 }
1925 /**
1926 * Checks if the string contains the seed.
1927 * If given value is not a string, then it returns false.
1928 */
1929 function Contains(seed, validationOptions) {
1930 return ValidateBy({
1931 name: CONTAINS,
1932 constraints: [seed],
1933 validator: {
1934 validate: function (value, args) { return contains(value, args.constraints[0]); },
1935 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must contain a $constraint1 string'); }, validationOptions),
1936 },
1937 }, validationOptions);
1938 }
1939
1940 var NOT_CONTAINS = 'notContains';
1941 /**
1942 * Checks if the string does not contain the seed.
1943 * If given value is not a string, then it returns false.
1944 */
1945 function notContains(value, seed) {
1946 return typeof value === 'string' && !containsValidator(value, seed);
1947 }
1948 /**
1949 * Checks if the string does not contain the seed.
1950 * If given value is not a string, then it returns false.
1951 */
1952 function NotContains(seed, validationOptions) {
1953 return ValidateBy({
1954 name: NOT_CONTAINS,
1955 constraints: [seed],
1956 validator: {
1957 validate: function (value, args) { return notContains(value, args.constraints[0]); },
1958 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property should not contain a $constraint1 string'); }, validationOptions),
1959 },
1960 }, validationOptions);
1961 }
1962
1963 var isAlpha$2 = {};
1964
1965 Object.defineProperty(isAlpha$2, "__esModule", {
1966 value: true
1967 });
1968 var _default$7 = isAlpha$2.default = isAlpha$1;
1969 isAlpha$2.locales = void 0;
1970
1971 var _assertString$7 = _interopRequireDefault$7(assertString.exports);
1972
1973 var _alpha$1 = alpha$1;
1974
1975 function _interopRequireDefault$7(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1976
1977 function isAlpha$1(_str) {
1978 var locale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'en-US';
1979 var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1980 (0, _assertString$7.default)(_str);
1981 var str = _str;
1982 var ignore = options.ignore;
1983
1984 if (ignore) {
1985 if (ignore instanceof RegExp) {
1986 str = str.replace(ignore, '');
1987 } else if (typeof ignore === 'string') {
1988 str = str.replace(new RegExp("[".concat(ignore.replace(/[-[\]{}()*+?.,\\^$|#\\s]/g, '\\$&'), "]"), 'g'), ''); // escape regex for ignore
1989 } else {
1990 throw new Error('ignore should be instance of a String or RegExp');
1991 }
1992 }
1993
1994 if (locale in _alpha$1.alpha) {
1995 return _alpha$1.alpha[locale].test(str);
1996 }
1997
1998 throw new Error("Invalid locale '".concat(locale, "'"));
1999 }
2000
2001 var locales$4 = Object.keys(_alpha$1.alpha);
2002 isAlpha$2.locales = locales$4;
2003
2004 var IS_ALPHA = 'isAlpha';
2005 /**
2006 * Checks if the string contains only letters (a-zA-Z).
2007 * If given value is not a string, then it returns false.
2008 */
2009 function isAlpha(value, locale) {
2010 return typeof value === 'string' && _default$7(value, locale);
2011 }
2012 /**
2013 * Checks if the string contains only letters (a-zA-Z).
2014 * If given value is not a string, then it returns false.
2015 */
2016 function IsAlpha(locale, validationOptions) {
2017 return ValidateBy({
2018 name: IS_ALPHA,
2019 constraints: [locale],
2020 validator: {
2021 validate: function (value, args) { return isAlpha(value, args.constraints[0]); },
2022 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must contain only letters (a-zA-Z)'); }, validationOptions),
2023 },
2024 }, validationOptions);
2025 }
2026
2027 var isAlphanumeric$2 = {};
2028
2029 Object.defineProperty(isAlphanumeric$2, "__esModule", {
2030 value: true
2031 });
2032 var _default$6 = isAlphanumeric$2.default = isAlphanumeric$1;
2033 isAlphanumeric$2.locales = void 0;
2034
2035 var _assertString$6 = _interopRequireDefault$6(assertString.exports);
2036
2037 var _alpha = alpha$1;
2038
2039 function _interopRequireDefault$6(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2040
2041 function isAlphanumeric$1(_str) {
2042 var locale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'en-US';
2043 var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2044 (0, _assertString$6.default)(_str);
2045 var str = _str;
2046 var ignore = options.ignore;
2047
2048 if (ignore) {
2049 if (ignore instanceof RegExp) {
2050 str = str.replace(ignore, '');
2051 } else if (typeof ignore === 'string') {
2052 str = str.replace(new RegExp("[".concat(ignore.replace(/[-[\]{}()*+?.,\\^$|#\\s]/g, '\\$&'), "]"), 'g'), ''); // escape regex for ignore
2053 } else {
2054 throw new Error('ignore should be instance of a String or RegExp');
2055 }
2056 }
2057
2058 if (locale in _alpha.alphanumeric) {
2059 return _alpha.alphanumeric[locale].test(str);
2060 }
2061
2062 throw new Error("Invalid locale '".concat(locale, "'"));
2063 }
2064
2065 var locales$3 = Object.keys(_alpha.alphanumeric);
2066 isAlphanumeric$2.locales = locales$3;
2067
2068 var IS_ALPHANUMERIC = 'isAlphanumeric';
2069 /**
2070 * Checks if the string contains only letters and numbers.
2071 * If given value is not a string, then it returns false.
2072 */
2073 function isAlphanumeric(value, locale) {
2074 return typeof value === 'string' && _default$6(value, locale);
2075 }
2076 /**
2077 * Checks if the string contains only letters and numbers.
2078 * If given value is not a string, then it returns false.
2079 */
2080 function IsAlphanumeric(locale, validationOptions) {
2081 return ValidateBy({
2082 name: IS_ALPHANUMERIC,
2083 constraints: [locale],
2084 validator: {
2085 validate: function (value, args) { return isAlphanumeric(value, args.constraints[0]); },
2086 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must contain only letters and numbers'); }, validationOptions),
2087 },
2088 }, validationOptions);
2089 }
2090
2091 var isDecimal$1 = {exports: {}};
2092
2093 var includes = {exports: {}};
2094
2095 (function (module, exports) {
2096
2097 Object.defineProperty(exports, "__esModule", {
2098 value: true
2099 });
2100 exports.default = void 0;
2101
2102 var includes = function includes(arr, val) {
2103 return arr.some(function (arrVal) {
2104 return val === arrVal;
2105 });
2106 };
2107
2108 var _default = includes;
2109 exports.default = _default;
2110 module.exports = exports.default;
2111 module.exports.default = exports.default;
2112 }(includes, includes.exports));
2113
2114 (function (module, exports) {
2115
2116 Object.defineProperty(exports, "__esModule", {
2117 value: true
2118 });
2119 exports.default = isDecimal;
2120
2121 var _merge = _interopRequireDefault(merge.exports);
2122
2123 var _assertString = _interopRequireDefault(assertString.exports);
2124
2125 var _includes = _interopRequireDefault(includes.exports);
2126
2127 var _alpha = alpha$1;
2128
2129 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2130
2131 function decimalRegExp(options) {
2132 var regExp = new RegExp("^[-+]?([0-9]+)?(\\".concat(_alpha.decimal[options.locale], "[0-9]{").concat(options.decimal_digits, "})").concat(options.force_decimal ? '' : '?', "$"));
2133 return regExp;
2134 }
2135
2136 var default_decimal_options = {
2137 force_decimal: false,
2138 decimal_digits: '1,',
2139 locale: 'en-US'
2140 };
2141 var blacklist = ['', '-', '+'];
2142
2143 function isDecimal(str, options) {
2144 (0, _assertString.default)(str);
2145 options = (0, _merge.default)(options, default_decimal_options);
2146
2147 if (options.locale in _alpha.decimal) {
2148 return !(0, _includes.default)(blacklist, str.replace(/ /g, '')) && decimalRegExp(options).test(str);
2149 }
2150
2151 throw new Error("Invalid locale '".concat(options.locale, "'"));
2152 }
2153
2154 module.exports = exports.default;
2155 module.exports.default = exports.default;
2156 }(isDecimal$1, isDecimal$1.exports));
2157
2158 var isDecimalValidator = /*@__PURE__*/getDefaultExportFromCjs(isDecimal$1.exports);
2159
2160 var IS_DECIMAL = 'isDecimal';
2161 /**
2162 * Checks if the string is a valid decimal.
2163 * If given value is not a string, then it returns false.
2164 */
2165 function isDecimal(value, options) {
2166 return typeof value === 'string' && isDecimalValidator(value, options);
2167 }
2168 /**
2169 * Checks if the string contains only letters and numbers.
2170 * If given value is not a string, then it returns false.
2171 */
2172 function IsDecimal(options, validationOptions) {
2173 return ValidateBy({
2174 name: IS_DECIMAL,
2175 constraints: [options],
2176 validator: {
2177 validate: function (value, args) { return isDecimal(value, args.constraints[0]); },
2178 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property is not a valid decimal number.'); }, validationOptions),
2179 },
2180 }, validationOptions);
2181 }
2182
2183 var isAscii$1 = {exports: {}};
2184
2185 (function (module, exports) {
2186
2187 Object.defineProperty(exports, "__esModule", {
2188 value: true
2189 });
2190 exports.default = isAscii;
2191
2192 var _assertString = _interopRequireDefault(assertString.exports);
2193
2194 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2195
2196 /* eslint-disable no-control-regex */
2197 var ascii = /^[\x00-\x7F]+$/;
2198 /* eslint-enable no-control-regex */
2199
2200 function isAscii(str) {
2201 (0, _assertString.default)(str);
2202 return ascii.test(str);
2203 }
2204
2205 module.exports = exports.default;
2206 module.exports.default = exports.default;
2207 }(isAscii$1, isAscii$1.exports));
2208
2209 var isAsciiValidator = /*@__PURE__*/getDefaultExportFromCjs(isAscii$1.exports);
2210
2211 var IS_ASCII = 'isAscii';
2212 /**
2213 * Checks if the string contains ASCII chars only.
2214 * If given value is not a string, then it returns false.
2215 */
2216 function isAscii(value) {
2217 return typeof value === 'string' && isAsciiValidator(value);
2218 }
2219 /**
2220 * Checks if the string contains ASCII chars only.
2221 * If given value is not a string, then it returns false.
2222 */
2223 function IsAscii(validationOptions) {
2224 return ValidateBy({
2225 name: IS_ASCII,
2226 validator: {
2227 validate: function (value, args) { return isAscii(value); },
2228 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must contain only ASCII characters'); }, validationOptions),
2229 },
2230 }, validationOptions);
2231 }
2232
2233 var isBase64$1 = {exports: {}};
2234
2235 (function (module, exports) {
2236
2237 Object.defineProperty(exports, "__esModule", {
2238 value: true
2239 });
2240 exports.default = isBase64;
2241
2242 var _assertString = _interopRequireDefault(assertString.exports);
2243
2244 var _merge = _interopRequireDefault(merge.exports);
2245
2246 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2247
2248 var notBase64 = /[^A-Z0-9+\/=]/i;
2249 var urlSafeBase64 = /^[A-Z0-9_\-]*$/i;
2250 var defaultBase64Options = {
2251 urlSafe: false
2252 };
2253
2254 function isBase64(str, options) {
2255 (0, _assertString.default)(str);
2256 options = (0, _merge.default)(options, defaultBase64Options);
2257 var len = str.length;
2258
2259 if (options.urlSafe) {
2260 return urlSafeBase64.test(str);
2261 }
2262
2263 if (len % 4 !== 0 || notBase64.test(str)) {
2264 return false;
2265 }
2266
2267 var firstPaddingChar = str.indexOf('=');
2268 return firstPaddingChar === -1 || firstPaddingChar === len - 1 || firstPaddingChar === len - 2 && str[len - 1] === '=';
2269 }
2270
2271 module.exports = exports.default;
2272 module.exports.default = exports.default;
2273 }(isBase64$1, isBase64$1.exports));
2274
2275 var isBase64Validator = /*@__PURE__*/getDefaultExportFromCjs(isBase64$1.exports);
2276
2277 var IS_BASE64 = 'isBase64';
2278 /**
2279 * Checks if a string is base64 encoded.
2280 * If given value is not a string, then it returns false.
2281 */
2282 function isBase64(value) {
2283 return typeof value === 'string' && isBase64Validator(value);
2284 }
2285 /**
2286 * Checks if a string is base64 encoded.
2287 * If given value is not a string, then it returns false.
2288 */
2289 function IsBase64(validationOptions) {
2290 return ValidateBy({
2291 name: IS_BASE64,
2292 validator: {
2293 validate: function (value, args) { return isBase64(value); },
2294 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be base64 encoded'); }, validationOptions),
2295 },
2296 }, validationOptions);
2297 }
2298
2299 var isByteLength$1 = {exports: {}};
2300
2301 (function (module, exports) {
2302
2303 Object.defineProperty(exports, "__esModule", {
2304 value: true
2305 });
2306 exports.default = isByteLength;
2307
2308 var _assertString = _interopRequireDefault(assertString.exports);
2309
2310 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2311
2312 function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
2313
2314 /* eslint-disable prefer-rest-params */
2315 function isByteLength(str, options) {
2316 (0, _assertString.default)(str);
2317 var min;
2318 var max;
2319
2320 if (_typeof(options) === 'object') {
2321 min = options.min || 0;
2322 max = options.max;
2323 } else {
2324 // backwards compatibility: isByteLength(str, min [, max])
2325 min = arguments[1];
2326 max = arguments[2];
2327 }
2328
2329 var len = encodeURI(str).split(/%..|./).length - 1;
2330 return len >= min && (typeof max === 'undefined' || len <= max);
2331 }
2332
2333 module.exports = exports.default;
2334 module.exports.default = exports.default;
2335 }(isByteLength$1, isByteLength$1.exports));
2336
2337 var isByteLengthValidator = /*@__PURE__*/getDefaultExportFromCjs(isByteLength$1.exports);
2338
2339 var IS_BYTE_LENGTH = 'isByteLength';
2340 /**
2341 * Checks if the string's length (in bytes) falls in a range.
2342 * If given value is not a string, then it returns false.
2343 */
2344 function isByteLength(value, min, max) {
2345 return typeof value === 'string' && isByteLengthValidator(value, { min: min, max: max });
2346 }
2347 /**
2348 * Checks if the string's length (in bytes) falls in a range.
2349 * If given value is not a string, then it returns false.
2350 */
2351 function IsByteLength(min, max, validationOptions) {
2352 return ValidateBy({
2353 name: IS_BYTE_LENGTH,
2354 constraints: [min, max],
2355 validator: {
2356 validate: function (value, args) { return isByteLength(value, args.constraints[0], args.constraints[1]); },
2357 defaultMessage: buildMessage(function (eachPrefix) {
2358 return eachPrefix + getText("$property's byte length must fall into ($constraint1, $constraint2) range");
2359 }, validationOptions),
2360 },
2361 }, validationOptions);
2362 }
2363
2364 var isCreditCard$1 = {exports: {}};
2365
2366 (function (module, exports) {
2367
2368 Object.defineProperty(exports, "__esModule", {
2369 value: true
2370 });
2371 exports.default = isCreditCard;
2372
2373 var _assertString = _interopRequireDefault(assertString.exports);
2374
2375 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2376
2377 /* eslint-disable max-len */
2378 var creditCard = /^(?:4[0-9]{12}(?:[0-9]{3,6})?|5[1-5][0-9]{14}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12,15}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11}|6[27][0-9]{14}|^(81[0-9]{14,17}))$/;
2379 /* eslint-enable max-len */
2380
2381 function isCreditCard(str) {
2382 (0, _assertString.default)(str);
2383 var sanitized = str.replace(/[- ]+/g, '');
2384
2385 if (!creditCard.test(sanitized)) {
2386 return false;
2387 }
2388
2389 var sum = 0;
2390 var digit;
2391 var tmpNum;
2392 var shouldDouble;
2393
2394 for (var i = sanitized.length - 1; i >= 0; i--) {
2395 digit = sanitized.substring(i, i + 1);
2396 tmpNum = parseInt(digit, 10);
2397
2398 if (shouldDouble) {
2399 tmpNum *= 2;
2400
2401 if (tmpNum >= 10) {
2402 sum += tmpNum % 10 + 1;
2403 } else {
2404 sum += tmpNum;
2405 }
2406 } else {
2407 sum += tmpNum;
2408 }
2409
2410 shouldDouble = !shouldDouble;
2411 }
2412
2413 return !!(sum % 10 === 0 ? sanitized : false);
2414 }
2415
2416 module.exports = exports.default;
2417 module.exports.default = exports.default;
2418 }(isCreditCard$1, isCreditCard$1.exports));
2419
2420 var isCreditCardValidator = /*@__PURE__*/getDefaultExportFromCjs(isCreditCard$1.exports);
2421
2422 var IS_CREDIT_CARD = 'isCreditCard';
2423 /**
2424 * Checks if the string is a credit card.
2425 * If given value is not a string, then it returns false.
2426 */
2427 function isCreditCard(value) {
2428 return typeof value === 'string' && isCreditCardValidator(value);
2429 }
2430 /**
2431 * Checks if the string is a credit card.
2432 * If given value is not a string, then it returns false.
2433 */
2434 function IsCreditCard(validationOptions) {
2435 return ValidateBy({
2436 name: IS_CREDIT_CARD,
2437 validator: {
2438 validate: function (value, args) { return isCreditCard(value); },
2439 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be a credit card'); }, validationOptions),
2440 },
2441 }, validationOptions);
2442 }
2443
2444 var isCurrency$1 = {exports: {}};
2445
2446 (function (module, exports) {
2447
2448 Object.defineProperty(exports, "__esModule", {
2449 value: true
2450 });
2451 exports.default = isCurrency;
2452
2453 var _merge = _interopRequireDefault(merge.exports);
2454
2455 var _assertString = _interopRequireDefault(assertString.exports);
2456
2457 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2458
2459 function currencyRegex(options) {
2460 var decimal_digits = "\\d{".concat(options.digits_after_decimal[0], "}");
2461 options.digits_after_decimal.forEach(function (digit, index) {
2462 if (index !== 0) decimal_digits = "".concat(decimal_digits, "|\\d{").concat(digit, "}");
2463 });
2464 var symbol = "(".concat(options.symbol.replace(/\W/, function (m) {
2465 return "\\".concat(m);
2466 }), ")").concat(options.require_symbol ? '' : '?'),
2467 negative = '-?',
2468 whole_dollar_amount_without_sep = '[1-9]\\d*',
2469 whole_dollar_amount_with_sep = "[1-9]\\d{0,2}(\\".concat(options.thousands_separator, "\\d{3})*"),
2470 valid_whole_dollar_amounts = ['0', whole_dollar_amount_without_sep, whole_dollar_amount_with_sep],
2471 whole_dollar_amount = "(".concat(valid_whole_dollar_amounts.join('|'), ")?"),
2472 decimal_amount = "(\\".concat(options.decimal_separator, "(").concat(decimal_digits, "))").concat(options.require_decimal ? '' : '?');
2473 var pattern = whole_dollar_amount + (options.allow_decimal || options.require_decimal ? decimal_amount : ''); // default is negative sign before symbol, but there are two other options (besides parens)
2474
2475 if (options.allow_negatives && !options.parens_for_negatives) {
2476 if (options.negative_sign_after_digits) {
2477 pattern += negative;
2478 } else if (options.negative_sign_before_digits) {
2479 pattern = negative + pattern;
2480 }
2481 } // South African Rand, for example, uses R 123 (space) and R-123 (no space)
2482
2483
2484 if (options.allow_negative_sign_placeholder) {
2485 pattern = "( (?!\\-))?".concat(pattern);
2486 } else if (options.allow_space_after_symbol) {
2487 pattern = " ?".concat(pattern);
2488 } else if (options.allow_space_after_digits) {
2489 pattern += '( (?!$))?';
2490 }
2491
2492 if (options.symbol_after_digits) {
2493 pattern += symbol;
2494 } else {
2495 pattern = symbol + pattern;
2496 }
2497
2498 if (options.allow_negatives) {
2499 if (options.parens_for_negatives) {
2500 pattern = "(\\(".concat(pattern, "\\)|").concat(pattern, ")");
2501 } else if (!(options.negative_sign_before_digits || options.negative_sign_after_digits)) {
2502 pattern = negative + pattern;
2503 }
2504 } // ensure there's a dollar and/or decimal amount, and that
2505 // it doesn't start with a space or a negative sign followed by a space
2506
2507
2508 return new RegExp("^(?!-? )(?=.*\\d)".concat(pattern, "$"));
2509 }
2510
2511 var default_currency_options = {
2512 symbol: '$',
2513 require_symbol: false,
2514 allow_space_after_symbol: false,
2515 symbol_after_digits: false,
2516 allow_negatives: true,
2517 parens_for_negatives: false,
2518 negative_sign_before_digits: false,
2519 negative_sign_after_digits: false,
2520 allow_negative_sign_placeholder: false,
2521 thousands_separator: ',',
2522 decimal_separator: '.',
2523 allow_decimal: true,
2524 require_decimal: false,
2525 digits_after_decimal: [2],
2526 allow_space_after_digits: false
2527 };
2528
2529 function isCurrency(str, options) {
2530 (0, _assertString.default)(str);
2531 options = (0, _merge.default)(options, default_currency_options);
2532 return currencyRegex(options).test(str);
2533 }
2534
2535 module.exports = exports.default;
2536 module.exports.default = exports.default;
2537 }(isCurrency$1, isCurrency$1.exports));
2538
2539 var isCurrencyValidator = /*@__PURE__*/getDefaultExportFromCjs(isCurrency$1.exports);
2540
2541 var IS_CURRENCY = 'isCurrency';
2542 /**
2543 * Checks if the string is a valid currency amount.
2544 * If given value is not a string, then it returns false.
2545 */
2546 function isCurrency(value, options) {
2547 return typeof value === 'string' && isCurrencyValidator(value, options);
2548 }
2549 /**
2550 * Checks if the string is a valid currency amount.
2551 * If given value is not a string, then it returns false.
2552 */
2553 function IsCurrency(options, validationOptions) {
2554 return ValidateBy({
2555 name: IS_CURRENCY,
2556 constraints: [options],
2557 validator: {
2558 validate: function (value, args) { return isCurrency(value, args.constraints[0]); },
2559 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be a currency'); }, validationOptions),
2560 },
2561 }, validationOptions);
2562 }
2563
2564 var isEmail$1 = {exports: {}};
2565
2566 var isFQDN$1 = {exports: {}};
2567
2568 (function (module, exports) {
2569
2570 Object.defineProperty(exports, "__esModule", {
2571 value: true
2572 });
2573 exports.default = isFQDN;
2574
2575 var _assertString = _interopRequireDefault(assertString.exports);
2576
2577 var _merge = _interopRequireDefault(merge.exports);
2578
2579 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2580
2581 var default_fqdn_options = {
2582 require_tld: true,
2583 allow_underscores: false,
2584 allow_trailing_dot: false,
2585 allow_numeric_tld: false,
2586 allow_wildcard: false
2587 };
2588
2589 function isFQDN(str, options) {
2590 (0, _assertString.default)(str);
2591 options = (0, _merge.default)(options, default_fqdn_options);
2592 /* Remove the optional trailing dot before checking validity */
2593
2594 if (options.allow_trailing_dot && str[str.length - 1] === '.') {
2595 str = str.substring(0, str.length - 1);
2596 }
2597 /* Remove the optional wildcard before checking validity */
2598
2599
2600 if (options.allow_wildcard === true && str.indexOf('*.') === 0) {
2601 str = str.substring(2);
2602 }
2603
2604 var parts = str.split('.');
2605 var tld = parts[parts.length - 1];
2606
2607 if (options.require_tld) {
2608 // disallow fqdns without tld
2609 if (parts.length < 2) {
2610 return false;
2611 }
2612
2613 if (!/^([a-z\u00A1-\u00A8\u00AA-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}|xn[a-z0-9-]{2,})$/i.test(tld)) {
2614 return false;
2615 } // disallow spaces
2616
2617
2618 if (/\s/.test(tld)) {
2619 return false;
2620 }
2621 } // reject numeric TLDs
2622
2623
2624 if (!options.allow_numeric_tld && /^\d+$/.test(tld)) {
2625 return false;
2626 }
2627
2628 return parts.every(function (part) {
2629 if (part.length > 63) {
2630 return false;
2631 }
2632
2633 if (!/^[a-z_\u00a1-\uffff0-9-]+$/i.test(part)) {
2634 return false;
2635 } // disallow full-width chars
2636
2637
2638 if (/[\uff01-\uff5e]/.test(part)) {
2639 return false;
2640 } // disallow parts starting or ending with hyphen
2641
2642
2643 if (/^-|-$/.test(part)) {
2644 return false;
2645 }
2646
2647 if (!options.allow_underscores && /_/.test(part)) {
2648 return false;
2649 }
2650
2651 return true;
2652 });
2653 }
2654
2655 module.exports = exports.default;
2656 module.exports.default = exports.default;
2657 }(isFQDN$1, isFQDN$1.exports));
2658
2659 var isFqdnValidator = /*@__PURE__*/getDefaultExportFromCjs(isFQDN$1.exports);
2660
2661 var isIP$1 = {exports: {}};
2662
2663 (function (module, exports) {
2664
2665 Object.defineProperty(exports, "__esModule", {
2666 value: true
2667 });
2668 exports.default = isIP;
2669
2670 var _assertString = _interopRequireDefault(assertString.exports);
2671
2672 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2673
2674 /**
2675 11.3. Examples
2676
2677 The following addresses
2678
2679 fe80::1234 (on the 1st link of the node)
2680 ff02::5678 (on the 5th link of the node)
2681 ff08::9abc (on the 10th organization of the node)
2682
2683 would be represented as follows:
2684
2685 fe80::1234%1
2686 ff02::5678%5
2687 ff08::9abc%10
2688
2689 (Here we assume a natural translation from a zone index to the
2690 <zone_id> part, where the Nth zone of any scope is translated into
2691 "N".)
2692
2693 If we use interface names as <zone_id>, those addresses could also be
2694 represented as follows:
2695
2696 fe80::1234%ne0
2697 ff02::5678%pvc1.3
2698 ff08::9abc%interface10
2699
2700 where the interface "ne0" belongs to the 1st link, "pvc1.3" belongs
2701 to the 5th link, and "interface10" belongs to the 10th organization.
2702 * * */
2703 var IPv4SegmentFormat = '(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])';
2704 var IPv4AddressFormat = "(".concat(IPv4SegmentFormat, "[.]){3}").concat(IPv4SegmentFormat);
2705 var IPv4AddressRegExp = new RegExp("^".concat(IPv4AddressFormat, "$"));
2706 var IPv6SegmentFormat = '(?:[0-9a-fA-F]{1,4})';
2707 var IPv6AddressRegExp = new RegExp('^(' + "(?:".concat(IPv6SegmentFormat, ":){7}(?:").concat(IPv6SegmentFormat, "|:)|") + "(?:".concat(IPv6SegmentFormat, ":){6}(?:").concat(IPv4AddressFormat, "|:").concat(IPv6SegmentFormat, "|:)|") + "(?:".concat(IPv6SegmentFormat, ":){5}(?::").concat(IPv4AddressFormat, "|(:").concat(IPv6SegmentFormat, "){1,2}|:)|") + "(?:".concat(IPv6SegmentFormat, ":){4}(?:(:").concat(IPv6SegmentFormat, "){0,1}:").concat(IPv4AddressFormat, "|(:").concat(IPv6SegmentFormat, "){1,3}|:)|") + "(?:".concat(IPv6SegmentFormat, ":){3}(?:(:").concat(IPv6SegmentFormat, "){0,2}:").concat(IPv4AddressFormat, "|(:").concat(IPv6SegmentFormat, "){1,4}|:)|") + "(?:".concat(IPv6SegmentFormat, ":){2}(?:(:").concat(IPv6SegmentFormat, "){0,3}:").concat(IPv4AddressFormat, "|(:").concat(IPv6SegmentFormat, "){1,5}|:)|") + "(?:".concat(IPv6SegmentFormat, ":){1}(?:(:").concat(IPv6SegmentFormat, "){0,4}:").concat(IPv4AddressFormat, "|(:").concat(IPv6SegmentFormat, "){1,6}|:)|") + "(?::((?::".concat(IPv6SegmentFormat, "){0,5}:").concat(IPv4AddressFormat, "|(?::").concat(IPv6SegmentFormat, "){1,7}|:))") + ')(%[0-9a-zA-Z-.:]{1,})?$');
2708
2709 function isIP(str) {
2710 var version = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
2711 (0, _assertString.default)(str);
2712 version = String(version);
2713
2714 if (!version) {
2715 return isIP(str, 4) || isIP(str, 6);
2716 }
2717
2718 if (version === '4') {
2719 if (!IPv4AddressRegExp.test(str)) {
2720 return false;
2721 }
2722
2723 var parts = str.split('.').sort(function (a, b) {
2724 return a - b;
2725 });
2726 return parts[3] <= 255;
2727 }
2728
2729 if (version === '6') {
2730 return !!IPv6AddressRegExp.test(str);
2731 }
2732
2733 return false;
2734 }
2735
2736 module.exports = exports.default;
2737 module.exports.default = exports.default;
2738 }(isIP$1, isIP$1.exports));
2739
2740 var isIPValidator = /*@__PURE__*/getDefaultExportFromCjs(isIP$1.exports);
2741
2742 (function (module, exports) {
2743
2744 Object.defineProperty(exports, "__esModule", {
2745 value: true
2746 });
2747 exports.default = isEmail;
2748
2749 var _assertString = _interopRequireDefault(assertString.exports);
2750
2751 var _merge = _interopRequireDefault(merge.exports);
2752
2753 var _isByteLength = _interopRequireDefault(isByteLength$1.exports);
2754
2755 var _isFQDN = _interopRequireDefault(isFQDN$1.exports);
2756
2757 var _isIP = _interopRequireDefault(isIP$1.exports);
2758
2759 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2760
2761 var default_email_options = {
2762 allow_display_name: false,
2763 require_display_name: false,
2764 allow_utf8_local_part: true,
2765 require_tld: true,
2766 blacklisted_chars: '',
2767 ignore_max_length: false,
2768 host_blacklist: []
2769 };
2770 /* eslint-disable max-len */
2771
2772 /* eslint-disable no-control-regex */
2773
2774 var splitNameAddress = /^([^\x00-\x1F\x7F-\x9F\cX]+)</i;
2775 var emailUserPart = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i;
2776 var gmailUserPart = /^[a-z\d]+$/;
2777 var quotedEmailUser = /^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i;
2778 var emailUserUtf8Part = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i;
2779 var quotedEmailUserUtf8 = /^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*$/i;
2780 var defaultMaxEmailLength = 254;
2781 /* eslint-enable max-len */
2782
2783 /* eslint-enable no-control-regex */
2784
2785 /**
2786 * Validate display name according to the RFC2822: https://tools.ietf.org/html/rfc2822#appendix-A.1.2
2787 * @param {String} display_name
2788 */
2789
2790 function validateDisplayName(display_name) {
2791 var display_name_without_quotes = display_name.replace(/^"(.+)"$/, '$1'); // display name with only spaces is not valid
2792
2793 if (!display_name_without_quotes.trim()) {
2794 return false;
2795 } // check whether display name contains illegal character
2796
2797
2798 var contains_illegal = /[\.";<>]/.test(display_name_without_quotes);
2799
2800 if (contains_illegal) {
2801 // if contains illegal characters,
2802 // must to be enclosed in double-quotes, otherwise it's not a valid display name
2803 if (display_name_without_quotes === display_name) {
2804 return false;
2805 } // the quotes in display name must start with character symbol \
2806
2807
2808 var all_start_with_back_slash = display_name_without_quotes.split('"').length === display_name_without_quotes.split('\\"').length;
2809
2810 if (!all_start_with_back_slash) {
2811 return false;
2812 }
2813 }
2814
2815 return true;
2816 }
2817
2818 function isEmail(str, options) {
2819 (0, _assertString.default)(str);
2820 options = (0, _merge.default)(options, default_email_options);
2821
2822 if (options.require_display_name || options.allow_display_name) {
2823 var display_email = str.match(splitNameAddress);
2824
2825 if (display_email) {
2826 var display_name = display_email[1]; // Remove display name and angle brackets to get email address
2827 // Can be done in the regex but will introduce a ReDOS (See #1597 for more info)
2828
2829 str = str.replace(display_name, '').replace(/(^<|>$)/g, ''); // sometimes need to trim the last space to get the display name
2830 // because there may be a space between display name and email address
2831 // eg. myname <address@gmail.com>
2832 // the display name is `myname` instead of `myname `, so need to trim the last space
2833
2834 if (display_name.endsWith(' ')) {
2835 display_name = display_name.substr(0, display_name.length - 1);
2836 }
2837
2838 if (!validateDisplayName(display_name)) {
2839 return false;
2840 }
2841 } else if (options.require_display_name) {
2842 return false;
2843 }
2844 }
2845
2846 if (!options.ignore_max_length && str.length > defaultMaxEmailLength) {
2847 return false;
2848 }
2849
2850 var parts = str.split('@');
2851 var domain = parts.pop();
2852 var lower_domain = domain.toLowerCase();
2853
2854 if (options.host_blacklist.includes(lower_domain)) {
2855 return false;
2856 }
2857
2858 var user = parts.join('@');
2859
2860 if (options.domain_specific_validation && (lower_domain === 'gmail.com' || lower_domain === 'googlemail.com')) {
2861 /*
2862 Previously we removed dots for gmail addresses before validating.
2863 This was removed because it allows `multiple..dots@gmail.com`
2864 to be reported as valid, but it is not.
2865 Gmail only normalizes single dots, removing them from here is pointless,
2866 should be done in normalizeEmail
2867 */
2868 user = user.toLowerCase(); // Removing sub-address from username before gmail validation
2869
2870 var username = user.split('+')[0]; // Dots are not included in gmail length restriction
2871
2872 if (!(0, _isByteLength.default)(username.replace(/\./g, ''), {
2873 min: 6,
2874 max: 30
2875 })) {
2876 return false;
2877 }
2878
2879 var _user_parts = username.split('.');
2880
2881 for (var i = 0; i < _user_parts.length; i++) {
2882 if (!gmailUserPart.test(_user_parts[i])) {
2883 return false;
2884 }
2885 }
2886 }
2887
2888 if (options.ignore_max_length === false && (!(0, _isByteLength.default)(user, {
2889 max: 64
2890 }) || !(0, _isByteLength.default)(domain, {
2891 max: 254
2892 }))) {
2893 return false;
2894 }
2895
2896 if (!(0, _isFQDN.default)(domain, {
2897 require_tld: options.require_tld
2898 })) {
2899 if (!options.allow_ip_domain) {
2900 return false;
2901 }
2902
2903 if (!(0, _isIP.default)(domain)) {
2904 if (!domain.startsWith('[') || !domain.endsWith(']')) {
2905 return false;
2906 }
2907
2908 var noBracketdomain = domain.substr(1, domain.length - 2);
2909
2910 if (noBracketdomain.length === 0 || !(0, _isIP.default)(noBracketdomain)) {
2911 return false;
2912 }
2913 }
2914 }
2915
2916 if (user[0] === '"') {
2917 user = user.slice(1, user.length - 1);
2918 return options.allow_utf8_local_part ? quotedEmailUserUtf8.test(user) : quotedEmailUser.test(user);
2919 }
2920
2921 var pattern = options.allow_utf8_local_part ? emailUserUtf8Part : emailUserPart;
2922 var user_parts = user.split('.');
2923
2924 for (var _i = 0; _i < user_parts.length; _i++) {
2925 if (!pattern.test(user_parts[_i])) {
2926 return false;
2927 }
2928 }
2929
2930 if (options.blacklisted_chars) {
2931 if (user.search(new RegExp("[".concat(options.blacklisted_chars, "]+"), 'g')) !== -1) return false;
2932 }
2933
2934 return true;
2935 }
2936
2937 module.exports = exports.default;
2938 module.exports.default = exports.default;
2939 }(isEmail$1, isEmail$1.exports));
2940
2941 var isEmailValidator = /*@__PURE__*/getDefaultExportFromCjs(isEmail$1.exports);
2942
2943 var IS_EMAIL = 'isEmail';
2944 /**
2945 * Checks if the string is an email.
2946 * If given value is not a string, then it returns false.
2947 */
2948 function isEmail(value, options) {
2949 return typeof value === 'string' && isEmailValidator(value, options);
2950 }
2951 /**
2952 * Checks if the string is an email.
2953 * If given value is not a string, then it returns false.
2954 */
2955 function IsEmail(options, validationOptions) {
2956 return ValidateBy({
2957 name: IS_EMAIL,
2958 constraints: [options],
2959 validator: {
2960 validate: function (value, args) { return isEmail(value, args.constraints[0]); },
2961 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be an email'); }, validationOptions),
2962 },
2963 }, validationOptions);
2964 }
2965
2966 var IS_FQDN = 'isFqdn';
2967 /**
2968 * Checks if the string is a fully qualified domain name (e.g. domain.com).
2969 * If given value is not a string, then it returns false.
2970 */
2971 function isFQDN(value, options) {
2972 return typeof value === 'string' && isFqdnValidator(value, options);
2973 }
2974 /**
2975 * Checks if the string is a fully qualified domain name (e.g. domain.com).
2976 * If given value is not a string, then it returns false.
2977 */
2978 function IsFQDN(options, validationOptions) {
2979 return ValidateBy({
2980 name: IS_FQDN,
2981 constraints: [options],
2982 validator: {
2983 validate: function (value, args) { return isFQDN(value, args.constraints[0]); },
2984 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be a valid domain name'); }, validationOptions),
2985 },
2986 }, validationOptions);
2987 }
2988
2989 var isFullWidth$2 = {};
2990
2991 Object.defineProperty(isFullWidth$2, "__esModule", {
2992 value: true
2993 });
2994 var _default$5 = isFullWidth$2.default = isFullWidth$1;
2995 isFullWidth$2.fullWidth = void 0;
2996
2997 var _assertString$5 = _interopRequireDefault$5(assertString.exports);
2998
2999 function _interopRequireDefault$5(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3000
3001 var fullWidth = /[^\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]/;
3002 isFullWidth$2.fullWidth = fullWidth;
3003
3004 function isFullWidth$1(str) {
3005 (0, _assertString$5.default)(str);
3006 return fullWidth.test(str);
3007 }
3008
3009 var IS_FULL_WIDTH = 'isFullWidth';
3010 /**
3011 * Checks if the string contains any full-width chars.
3012 * If given value is not a string, then it returns false.
3013 */
3014 function isFullWidth(value) {
3015 return typeof value === 'string' && _default$5(value);
3016 }
3017 /**
3018 * Checks if the string contains any full-width chars.
3019 * If given value is not a string, then it returns false.
3020 */
3021 function IsFullWidth(validationOptions) {
3022 return ValidateBy({
3023 name: IS_FULL_WIDTH,
3024 validator: {
3025 validate: function (value, args) { return isFullWidth(value); },
3026 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must contain a full-width characters'); }, validationOptions),
3027 },
3028 }, validationOptions);
3029 }
3030
3031 var isHalfWidth$2 = {};
3032
3033 Object.defineProperty(isHalfWidth$2, "__esModule", {
3034 value: true
3035 });
3036 var _default$4 = isHalfWidth$2.default = isHalfWidth$1;
3037 isHalfWidth$2.halfWidth = void 0;
3038
3039 var _assertString$4 = _interopRequireDefault$4(assertString.exports);
3040
3041 function _interopRequireDefault$4(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3042
3043 var halfWidth = /[\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]/;
3044 isHalfWidth$2.halfWidth = halfWidth;
3045
3046 function isHalfWidth$1(str) {
3047 (0, _assertString$4.default)(str);
3048 return halfWidth.test(str);
3049 }
3050
3051 var IS_HALF_WIDTH = 'isHalfWidth';
3052 /**
3053 * Checks if the string contains any half-width chars.
3054 * If given value is not a string, then it returns false.
3055 */
3056 function isHalfWidth(value) {
3057 return typeof value === 'string' && _default$4(value);
3058 }
3059 /**
3060 * Checks if the string contains any full-width chars.
3061 * If given value is not a string, then it returns false.
3062 */
3063 function IsHalfWidth(validationOptions) {
3064 return ValidateBy({
3065 name: IS_HALF_WIDTH,
3066 validator: {
3067 validate: function (value, args) { return isHalfWidth(value); },
3068 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must contain a half-width characters'); }, validationOptions),
3069 },
3070 }, validationOptions);
3071 }
3072
3073 var isVariableWidth$1 = {exports: {}};
3074
3075 (function (module, exports) {
3076
3077 Object.defineProperty(exports, "__esModule", {
3078 value: true
3079 });
3080 exports.default = isVariableWidth;
3081
3082 var _assertString = _interopRequireDefault(assertString.exports);
3083
3084 var _isFullWidth = isFullWidth$2;
3085
3086 var _isHalfWidth = isHalfWidth$2;
3087
3088 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3089
3090 function isVariableWidth(str) {
3091 (0, _assertString.default)(str);
3092 return _isFullWidth.fullWidth.test(str) && _isHalfWidth.halfWidth.test(str);
3093 }
3094
3095 module.exports = exports.default;
3096 module.exports.default = exports.default;
3097 }(isVariableWidth$1, isVariableWidth$1.exports));
3098
3099 var isVariableWidthValidator = /*@__PURE__*/getDefaultExportFromCjs(isVariableWidth$1.exports);
3100
3101 var IS_VARIABLE_WIDTH = 'isVariableWidth';
3102 /**
3103 * Checks if the string contains variable-width chars.
3104 * If given value is not a string, then it returns false.
3105 */
3106 function isVariableWidth(value) {
3107 return typeof value === 'string' && isVariableWidthValidator(value);
3108 }
3109 /**
3110 * Checks if the string contains variable-width chars.
3111 * If given value is not a string, then it returns false.
3112 */
3113 function IsVariableWidth(validationOptions) {
3114 return ValidateBy({
3115 name: IS_VARIABLE_WIDTH,
3116 validator: {
3117 validate: function (value, args) { return isVariableWidth(value); },
3118 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must contain a full-width and half-width characters'); }, validationOptions),
3119 },
3120 }, validationOptions);
3121 }
3122
3123 var isHexColor$1 = {exports: {}};
3124
3125 (function (module, exports) {
3126
3127 Object.defineProperty(exports, "__esModule", {
3128 value: true
3129 });
3130 exports.default = isHexColor;
3131
3132 var _assertString = _interopRequireDefault(assertString.exports);
3133
3134 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3135
3136 var hexcolor = /^#?([0-9A-F]{3}|[0-9A-F]{4}|[0-9A-F]{6}|[0-9A-F]{8})$/i;
3137
3138 function isHexColor(str) {
3139 (0, _assertString.default)(str);
3140 return hexcolor.test(str);
3141 }
3142
3143 module.exports = exports.default;
3144 module.exports.default = exports.default;
3145 }(isHexColor$1, isHexColor$1.exports));
3146
3147 var isHexColorValidator = /*@__PURE__*/getDefaultExportFromCjs(isHexColor$1.exports);
3148
3149 var IS_HEX_COLOR = 'isHexColor';
3150 /**
3151 * Checks if the string is a hexadecimal color.
3152 * If given value is not a string, then it returns false.
3153 */
3154 function isHexColor(value) {
3155 return typeof value === 'string' && isHexColorValidator(value);
3156 }
3157 /**
3158 * Checks if the string is a hexadecimal color.
3159 * If given value is not a string, then it returns false.
3160 */
3161 function IsHexColor(validationOptions) {
3162 return ValidateBy({
3163 name: IS_HEX_COLOR,
3164 validator: {
3165 validate: function (value, args) { return isHexColor(value); },
3166 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be a hexadecimal color'); }, validationOptions),
3167 },
3168 }, validationOptions);
3169 }
3170
3171 var isHexadecimal$1 = {exports: {}};
3172
3173 (function (module, exports) {
3174
3175 Object.defineProperty(exports, "__esModule", {
3176 value: true
3177 });
3178 exports.default = isHexadecimal;
3179
3180 var _assertString = _interopRequireDefault(assertString.exports);
3181
3182 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3183
3184 var hexadecimal = /^(0x|0h)?[0-9A-F]+$/i;
3185
3186 function isHexadecimal(str) {
3187 (0, _assertString.default)(str);
3188 return hexadecimal.test(str);
3189 }
3190
3191 module.exports = exports.default;
3192 module.exports.default = exports.default;
3193 }(isHexadecimal$1, isHexadecimal$1.exports));
3194
3195 var isHexadecimalValidator = /*@__PURE__*/getDefaultExportFromCjs(isHexadecimal$1.exports);
3196
3197 var IS_HEXADECIMAL = 'isHexadecimal';
3198 /**
3199 * Checks if the string is a hexadecimal number.
3200 * If given value is not a string, then it returns false.
3201 */
3202 function isHexadecimal(value) {
3203 return typeof value === 'string' && isHexadecimalValidator(value);
3204 }
3205 /**
3206 * Checks if the string is a hexadecimal number.
3207 * If given value is not a string, then it returns false.
3208 */
3209 function IsHexadecimal(validationOptions) {
3210 return ValidateBy({
3211 name: IS_HEXADECIMAL,
3212 validator: {
3213 validate: function (value, args) { return isHexadecimal(value); },
3214 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be a hexadecimal number'); }, validationOptions),
3215 },
3216 }, validationOptions);
3217 }
3218
3219 function isValidationOptions(val) {
3220 if (!val) {
3221 return false;
3222 }
3223 return 'each' in val || 'message' in val || 'groups' in val || 'always' in val || 'context' in val;
3224 }
3225
3226 var isMACAddress$1 = {exports: {}};
3227
3228 (function (module, exports) {
3229
3230 Object.defineProperty(exports, "__esModule", {
3231 value: true
3232 });
3233 exports.default = isMACAddress;
3234
3235 var _assertString = _interopRequireDefault(assertString.exports);
3236
3237 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3238
3239 var macAddress = /^(?:[0-9a-fA-F]{2}([-:\s]))([0-9a-fA-F]{2}\1){4}([0-9a-fA-F]{2})$/;
3240 var macAddressNoSeparators = /^([0-9a-fA-F]){12}$/;
3241 var macAddressWithDots = /^([0-9a-fA-F]{4}\.){2}([0-9a-fA-F]{4})$/;
3242
3243 function isMACAddress(str, options) {
3244 (0, _assertString.default)(str);
3245 /**
3246 * @deprecated `no_colons` TODO: remove it in the next major
3247 */
3248
3249 if (options && (options.no_colons || options.no_separators)) {
3250 return macAddressNoSeparators.test(str);
3251 }
3252
3253 return macAddress.test(str) || macAddressWithDots.test(str);
3254 }
3255
3256 module.exports = exports.default;
3257 module.exports.default = exports.default;
3258 }(isMACAddress$1, isMACAddress$1.exports));
3259
3260 var isMacAddressValidator = /*@__PURE__*/getDefaultExportFromCjs(isMACAddress$1.exports);
3261
3262 var IS_MAC_ADDRESS = 'isMacAddress';
3263 /**
3264 * Check if the string is a MAC address.
3265 * If given value is not a string, then it returns false.
3266 */
3267 function isMACAddress(value, options) {
3268 return typeof value === 'string' && isMacAddressValidator(value, options);
3269 }
3270 function IsMACAddress(optionsOrValidationOptionsArg, validationOptionsArg) {
3271 var options = !isValidationOptions(optionsOrValidationOptionsArg) ? optionsOrValidationOptionsArg : undefined;
3272 var validationOptions = isValidationOptions(optionsOrValidationOptionsArg)
3273 ? optionsOrValidationOptionsArg
3274 : validationOptionsArg;
3275 return ValidateBy({
3276 name: IS_MAC_ADDRESS,
3277 constraints: [options],
3278 validator: {
3279 validate: function (value, args) { return isMACAddress(value, options); },
3280 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be a MAC Address'); }, validationOptions),
3281 },
3282 }, validationOptions);
3283 }
3284
3285 var IS_IP = 'isIp';
3286 /**
3287 * Checks if the string is an IP (version 4 or 6).
3288 * If given value is not a string, then it returns false.
3289 */
3290 function isIP(value, version) {
3291 /* eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion */
3292 var versionStr = version ? "".concat(version) : undefined;
3293 return typeof value === 'string' && isIPValidator(value, versionStr);
3294 }
3295 /**
3296 * Checks if the string is an IP (version 4 or 6).
3297 * If given value is not a string, then it returns false.
3298 */
3299 function IsIP(version, validationOptions) {
3300 return ValidateBy({
3301 name: IS_IP,
3302 constraints: [version],
3303 validator: {
3304 validate: function (value, args) { return isIP(value, args.constraints[0]); },
3305 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be an ip address'); }, validationOptions),
3306 },
3307 }, validationOptions);
3308 }
3309
3310 var isPort$1 = {exports: {}};
3311
3312 var isInt$1 = {exports: {}};
3313
3314 (function (module, exports) {
3315
3316 Object.defineProperty(exports, "__esModule", {
3317 value: true
3318 });
3319 exports.default = isInt;
3320
3321 var _assertString = _interopRequireDefault(assertString.exports);
3322
3323 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3324
3325 var int = /^(?:[-+]?(?:0|[1-9][0-9]*))$/;
3326 var intLeadingZeroes = /^[-+]?[0-9]+$/;
3327
3328 function isInt(str, options) {
3329 (0, _assertString.default)(str);
3330 options = options || {}; // Get the regex to use for testing, based on whether
3331 // leading zeroes are allowed or not.
3332
3333 var regex = options.hasOwnProperty('allow_leading_zeroes') && !options.allow_leading_zeroes ? int : intLeadingZeroes; // Check min/max/lt/gt
3334
3335 var minCheckPassed = !options.hasOwnProperty('min') || str >= options.min;
3336 var maxCheckPassed = !options.hasOwnProperty('max') || str <= options.max;
3337 var ltCheckPassed = !options.hasOwnProperty('lt') || str < options.lt;
3338 var gtCheckPassed = !options.hasOwnProperty('gt') || str > options.gt;
3339 return regex.test(str) && minCheckPassed && maxCheckPassed && ltCheckPassed && gtCheckPassed;
3340 }
3341
3342 module.exports = exports.default;
3343 module.exports.default = exports.default;
3344 }(isInt$1, isInt$1.exports));
3345
3346 (function (module, exports) {
3347
3348 Object.defineProperty(exports, "__esModule", {
3349 value: true
3350 });
3351 exports.default = isPort;
3352
3353 var _isInt = _interopRequireDefault(isInt$1.exports);
3354
3355 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3356
3357 function isPort(str) {
3358 return (0, _isInt.default)(str, {
3359 min: 0,
3360 max: 65535
3361 });
3362 }
3363
3364 module.exports = exports.default;
3365 module.exports.default = exports.default;
3366 }(isPort$1, isPort$1.exports));
3367
3368 var isPortValidator = /*@__PURE__*/getDefaultExportFromCjs(isPort$1.exports);
3369
3370 var IS_PORT = 'isPort';
3371 /**
3372 * Check if the string is a valid port number.
3373 */
3374 function isPort(value) {
3375 return typeof value === 'string' && isPortValidator(value);
3376 }
3377 /**
3378 * Check if the string is a valid port number.
3379 */
3380 function IsPort(validationOptions) {
3381 return ValidateBy({
3382 name: IS_PORT,
3383 validator: {
3384 validate: function (value, args) { return isPort(value); },
3385 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be a port'); }, validationOptions),
3386 },
3387 }, validationOptions);
3388 }
3389
3390 var isISBN$1 = {exports: {}};
3391
3392 (function (module, exports) {
3393
3394 Object.defineProperty(exports, "__esModule", {
3395 value: true
3396 });
3397 exports.default = isISBN;
3398
3399 var _assertString = _interopRequireDefault(assertString.exports);
3400
3401 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3402
3403 var isbn10Maybe = /^(?:[0-9]{9}X|[0-9]{10})$/;
3404 var isbn13Maybe = /^(?:[0-9]{13})$/;
3405 var factor = [1, 3];
3406
3407 function isISBN(str) {
3408 var version = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
3409 (0, _assertString.default)(str);
3410 version = String(version);
3411
3412 if (!version) {
3413 return isISBN(str, 10) || isISBN(str, 13);
3414 }
3415
3416 var sanitized = str.replace(/[\s-]+/g, '');
3417 var checksum = 0;
3418 var i;
3419
3420 if (version === '10') {
3421 if (!isbn10Maybe.test(sanitized)) {
3422 return false;
3423 }
3424
3425 for (i = 0; i < 9; i++) {
3426 checksum += (i + 1) * sanitized.charAt(i);
3427 }
3428
3429 if (sanitized.charAt(9) === 'X') {
3430 checksum += 10 * 10;
3431 } else {
3432 checksum += 10 * sanitized.charAt(9);
3433 }
3434
3435 if (checksum % 11 === 0) {
3436 return !!sanitized;
3437 }
3438 } else if (version === '13') {
3439 if (!isbn13Maybe.test(sanitized)) {
3440 return false;
3441 }
3442
3443 for (i = 0; i < 12; i++) {
3444 checksum += factor[i % 2] * sanitized.charAt(i);
3445 }
3446
3447 if (sanitized.charAt(12) - (10 - checksum % 10) % 10 === 0) {
3448 return !!sanitized;
3449 }
3450 }
3451
3452 return false;
3453 }
3454
3455 module.exports = exports.default;
3456 module.exports.default = exports.default;
3457 }(isISBN$1, isISBN$1.exports));
3458
3459 var isIsbnValidator = /*@__PURE__*/getDefaultExportFromCjs(isISBN$1.exports);
3460
3461 var IS_ISBN = 'isIsbn';
3462 /**
3463 * Checks if the string is an ISBN (version 10 or 13).
3464 * If given value is not a string, then it returns false.
3465 */
3466 function isISBN(value, version) {
3467 /* eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion */
3468 var versionStr = version ? "".concat(version) : undefined;
3469 return typeof value === 'string' && isIsbnValidator(value, versionStr);
3470 }
3471 /**
3472 * Checks if the string is an ISBN (version 10 or 13).
3473 * If given value is not a string, then it returns false.
3474 */
3475 function IsISBN(version, validationOptions) {
3476 return ValidateBy({
3477 name: IS_ISBN,
3478 constraints: [version],
3479 validator: {
3480 validate: function (value, args) { return isISBN(value, args.constraints[0]); },
3481 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be an ISBN'); }, validationOptions),
3482 },
3483 }, validationOptions);
3484 }
3485
3486 var isISIN$1 = {exports: {}};
3487
3488 (function (module, exports) {
3489
3490 Object.defineProperty(exports, "__esModule", {
3491 value: true
3492 });
3493 exports.default = isISIN;
3494
3495 var _assertString = _interopRequireDefault(assertString.exports);
3496
3497 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3498
3499 var isin = /^[A-Z]{2}[0-9A-Z]{9}[0-9]$/; // this link details how the check digit is calculated:
3500 // https://www.isin.org/isin-format/. it is a little bit
3501 // odd in that it works with digits, not numbers. in order
3502 // to make only one pass through the ISIN characters, the
3503 // each alpha character is handled as 2 characters within
3504 // the loop.
3505
3506 function isISIN(str) {
3507 (0, _assertString.default)(str);
3508
3509 if (!isin.test(str)) {
3510 return false;
3511 }
3512
3513 var double = true;
3514 var sum = 0; // convert values
3515
3516 for (var i = str.length - 2; i >= 0; i--) {
3517 if (str[i] >= 'A' && str[i] <= 'Z') {
3518 var value = str[i].charCodeAt(0) - 55;
3519 var lo = value % 10;
3520 var hi = Math.trunc(value / 10); // letters have two digits, so handle the low order
3521 // and high order digits separately.
3522
3523 for (var _i = 0, _arr = [lo, hi]; _i < _arr.length; _i++) {
3524 var digit = _arr[_i];
3525
3526 if (double) {
3527 if (digit >= 5) {
3528 sum += 1 + (digit - 5) * 2;
3529 } else {
3530 sum += digit * 2;
3531 }
3532 } else {
3533 sum += digit;
3534 }
3535
3536 double = !double;
3537 }
3538 } else {
3539 var _digit = str[i].charCodeAt(0) - '0'.charCodeAt(0);
3540
3541 if (double) {
3542 if (_digit >= 5) {
3543 sum += 1 + (_digit - 5) * 2;
3544 } else {
3545 sum += _digit * 2;
3546 }
3547 } else {
3548 sum += _digit;
3549 }
3550
3551 double = !double;
3552 }
3553 }
3554
3555 var check = Math.trunc((sum + 9) / 10) * 10 - sum;
3556 return +str[str.length - 1] === check;
3557 }
3558
3559 module.exports = exports.default;
3560 module.exports.default = exports.default;
3561 }(isISIN$1, isISIN$1.exports));
3562
3563 var isIsinValidator = /*@__PURE__*/getDefaultExportFromCjs(isISIN$1.exports);
3564
3565 var IS_ISIN = 'isIsin';
3566 /**
3567 * Checks if the string is an ISIN (stock/security identifier).
3568 * If given value is not a string, then it returns false.
3569 */
3570 function isISIN(value) {
3571 return typeof value === 'string' && isIsinValidator(value);
3572 }
3573 /**
3574 * Checks if the string is an ISIN (stock/security identifier).
3575 * If given value is not a string, then it returns false.
3576 */
3577 function IsISIN(validationOptions) {
3578 return ValidateBy({
3579 name: IS_ISIN,
3580 validator: {
3581 validate: function (value, args) { return isISIN(value); },
3582 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be an ISIN (stock/security identifier)'); }, validationOptions),
3583 },
3584 }, validationOptions);
3585 }
3586
3587 var isISO8601$1 = {exports: {}};
3588
3589 (function (module, exports) {
3590
3591 Object.defineProperty(exports, "__esModule", {
3592 value: true
3593 });
3594 exports.default = isISO8601;
3595
3596 var _assertString = _interopRequireDefault(assertString.exports);
3597
3598 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3599
3600 /* eslint-disable max-len */
3601 // from http://goo.gl/0ejHHW
3602 var iso8601 = /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/; // same as above, except with a strict 'T' separator between date and time
3603
3604 var iso8601StrictSeparator = /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;
3605 /* eslint-enable max-len */
3606
3607 var isValidDate = function isValidDate(str) {
3608 // str must have passed the ISO8601 check
3609 // this check is meant to catch invalid dates
3610 // like 2009-02-31
3611 // first check for ordinal dates
3612 var ordinalMatch = str.match(/^(\d{4})-?(\d{3})([ T]{1}\.*|$)/);
3613
3614 if (ordinalMatch) {
3615 var oYear = Number(ordinalMatch[1]);
3616 var oDay = Number(ordinalMatch[2]); // if is leap year
3617
3618 if (oYear % 4 === 0 && oYear % 100 !== 0 || oYear % 400 === 0) return oDay <= 366;
3619 return oDay <= 365;
3620 }
3621
3622 var match = str.match(/(\d{4})-?(\d{0,2})-?(\d*)/).map(Number);
3623 var year = match[1];
3624 var month = match[2];
3625 var day = match[3];
3626 var monthString = month ? "0".concat(month).slice(-2) : month;
3627 var dayString = day ? "0".concat(day).slice(-2) : day; // create a date object and compare
3628
3629 var d = new Date("".concat(year, "-").concat(monthString || '01', "-").concat(dayString || '01'));
3630
3631 if (month && day) {
3632 return d.getUTCFullYear() === year && d.getUTCMonth() + 1 === month && d.getUTCDate() === day;
3633 }
3634
3635 return true;
3636 };
3637
3638 function isISO8601(str) {
3639 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3640 (0, _assertString.default)(str);
3641 var check = options.strictSeparator ? iso8601StrictSeparator.test(str) : iso8601.test(str);
3642 if (check && options.strict) return isValidDate(str);
3643 return check;
3644 }
3645
3646 module.exports = exports.default;
3647 module.exports.default = exports.default;
3648 }(isISO8601$1, isISO8601$1.exports));
3649
3650 var isIso8601Validator = /*@__PURE__*/getDefaultExportFromCjs(isISO8601$1.exports);
3651
3652 var IS_ISO8601 = 'isIso8601';
3653 /**
3654 * Checks if the string is a valid ISO 8601 date.
3655 * If given value is not a string, then it returns false.
3656 * Use the option strict = true for additional checks for a valid date, e.g. invalidates dates like 2019-02-29.
3657 */
3658 function isISO8601(value, options) {
3659 return typeof value === 'string' && isIso8601Validator(value, options);
3660 }
3661 /**
3662 * Checks if the string is a valid ISO 8601 date.
3663 * If given value is not a string, then it returns false.
3664 * Use the option strict = true for additional checks for a valid date, e.g. invalidates dates like 2019-02-29.
3665 */
3666 function IsISO8601(options, validationOptions) {
3667 return ValidateBy({
3668 name: IS_ISO8601,
3669 constraints: [options],
3670 validator: {
3671 validate: function (value, args) { return isISO8601(value, args.constraints[0]); },
3672 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be a valid ISO 8601 date string'); }, validationOptions),
3673 },
3674 }, validationOptions);
3675 }
3676
3677 var isJSON$1 = {exports: {}};
3678
3679 (function (module, exports) {
3680
3681 Object.defineProperty(exports, "__esModule", {
3682 value: true
3683 });
3684 exports.default = isJSON;
3685
3686 var _assertString = _interopRequireDefault(assertString.exports);
3687
3688 var _merge = _interopRequireDefault(merge.exports);
3689
3690 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3691
3692 function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
3693
3694 var default_json_options = {
3695 allow_primitives: false
3696 };
3697
3698 function isJSON(str, options) {
3699 (0, _assertString.default)(str);
3700
3701 try {
3702 options = (0, _merge.default)(options, default_json_options);
3703 var primitives = [];
3704
3705 if (options.allow_primitives) {
3706 primitives = [null, false, true];
3707 }
3708
3709 var obj = JSON.parse(str);
3710 return primitives.includes(obj) || !!obj && _typeof(obj) === 'object';
3711 } catch (e) {
3712 /* ignore */
3713 }
3714
3715 return false;
3716 }
3717
3718 module.exports = exports.default;
3719 module.exports.default = exports.default;
3720 }(isJSON$1, isJSON$1.exports));
3721
3722 var isJSONValidator = /*@__PURE__*/getDefaultExportFromCjs(isJSON$1.exports);
3723
3724 var IS_JSON = 'isJson';
3725 /**
3726 * Checks if the string is valid JSON (note: uses JSON.parse).
3727 * If given value is not a string, then it returns false.
3728 */
3729 function isJSON(value) {
3730 return typeof value === 'string' && isJSONValidator(value);
3731 }
3732 /**
3733 * Checks if the string is valid JSON (note: uses JSON.parse).
3734 * If given value is not a string, then it returns false.
3735 */
3736 function IsJSON(validationOptions) {
3737 return ValidateBy({
3738 name: IS_JSON,
3739 validator: {
3740 validate: function (value, args) { return isJSON(value); },
3741 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be a json string'); }, validationOptions),
3742 },
3743 }, validationOptions);
3744 }
3745
3746 var isJWT$1 = {exports: {}};
3747
3748 (function (module, exports) {
3749
3750 Object.defineProperty(exports, "__esModule", {
3751 value: true
3752 });
3753 exports.default = isJWT;
3754
3755 var _assertString = _interopRequireDefault(assertString.exports);
3756
3757 var _isBase = _interopRequireDefault(isBase64$1.exports);
3758
3759 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3760
3761 function isJWT(str) {
3762 (0, _assertString.default)(str);
3763 var dotSplit = str.split('.');
3764 var len = dotSplit.length;
3765
3766 if (len > 3 || len < 2) {
3767 return false;
3768 }
3769
3770 return dotSplit.reduce(function (acc, currElem) {
3771 return acc && (0, _isBase.default)(currElem, {
3772 urlSafe: true
3773 });
3774 }, true);
3775 }
3776
3777 module.exports = exports.default;
3778 module.exports.default = exports.default;
3779 }(isJWT$1, isJWT$1.exports));
3780
3781 var isJwtValidator = /*@__PURE__*/getDefaultExportFromCjs(isJWT$1.exports);
3782
3783 var IS_JWT = 'isJwt';
3784 /**
3785 * Checks if the string is valid JWT token.
3786 * If given value is not a string, then it returns false.
3787 */
3788 function isJWT(value) {
3789 return typeof value === 'string' && isJwtValidator(value);
3790 }
3791 /**
3792 * Checks if the string is valid JWT token.
3793 * If given value is not a string, then it returns false.
3794 */
3795 function IsJWT(validationOptions) {
3796 return ValidateBy({
3797 name: IS_JWT,
3798 validator: {
3799 validate: function (value, args) { return isJWT(value); },
3800 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be a jwt string'); }, validationOptions),
3801 },
3802 }, validationOptions);
3803 }
3804
3805 var isLowercase$1 = {exports: {}};
3806
3807 (function (module, exports) {
3808
3809 Object.defineProperty(exports, "__esModule", {
3810 value: true
3811 });
3812 exports.default = isLowercase;
3813
3814 var _assertString = _interopRequireDefault(assertString.exports);
3815
3816 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3817
3818 function isLowercase(str) {
3819 (0, _assertString.default)(str);
3820 return str === str.toLowerCase();
3821 }
3822
3823 module.exports = exports.default;
3824 module.exports.default = exports.default;
3825 }(isLowercase$1, isLowercase$1.exports));
3826
3827 var isLowercaseValidator = /*@__PURE__*/getDefaultExportFromCjs(isLowercase$1.exports);
3828
3829 var IS_LOWERCASE = 'isLowercase';
3830 /**
3831 * Checks if the string is lowercase.
3832 * If given value is not a string, then it returns false.
3833 */
3834 function isLowercase(value) {
3835 return typeof value === 'string' && isLowercaseValidator(value);
3836 }
3837 /**
3838 * Checks if the string is lowercase.
3839 * If given value is not a string, then it returns false.
3840 */
3841 function IsLowercase(validationOptions) {
3842 return ValidateBy({
3843 name: IS_LOWERCASE,
3844 validator: {
3845 validate: function (value, args) { return isLowercase(value); },
3846 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be a lowercase string'); }, validationOptions),
3847 },
3848 }, validationOptions);
3849 }
3850
3851 var isMobilePhone$2 = {};
3852
3853 Object.defineProperty(isMobilePhone$2, "__esModule", {
3854 value: true
3855 });
3856 var _default$3 = isMobilePhone$2.default = isMobilePhone$1;
3857 isMobilePhone$2.locales = void 0;
3858
3859 var _assertString$3 = _interopRequireDefault$3(assertString.exports);
3860
3861 function _interopRequireDefault$3(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3862
3863 /* eslint-disable max-len */
3864 var phones = {
3865 'am-AM': /^(\+?374|0)((10|[9|7][0-9])\d{6}$|[2-4]\d{7}$)/,
3866 'ar-AE': /^((\+?971)|0)?5[024568]\d{7}$/,
3867 'ar-BH': /^(\+?973)?(3|6)\d{7}$/,
3868 'ar-DZ': /^(\+?213|0)(5|6|7)\d{8}$/,
3869 'ar-LB': /^(\+?961)?((3|81)\d{6}|7\d{7})$/,
3870 'ar-EG': /^((\+?20)|0)?1[0125]\d{8}$/,
3871 'ar-IQ': /^(\+?964|0)?7[0-9]\d{8}$/,
3872 'ar-JO': /^(\+?962|0)?7[789]\d{7}$/,
3873 'ar-KW': /^(\+?965)[569]\d{7}$/,
3874 'ar-LY': /^((\+?218)|0)?(9[1-6]\d{7}|[1-8]\d{7,9})$/,
3875 'ar-MA': /^(?:(?:\+|00)212|0)[5-7]\d{8}$/,
3876 'ar-OM': /^((\+|00)968)?(9[1-9])\d{6}$/,
3877 'ar-PS': /^(\+?970|0)5[6|9](\d{7})$/,
3878 'ar-SA': /^(!?(\+?966)|0)?5\d{8}$/,
3879 'ar-SY': /^(!?(\+?963)|0)?9\d{8}$/,
3880 'ar-TN': /^(\+?216)?[2459]\d{7}$/,
3881 'az-AZ': /^(\+994|0)(5[015]|7[07]|99)\d{7}$/,
3882 'bs-BA': /^((((\+|00)3876)|06))((([0-3]|[5-6])\d{6})|(4\d{7}))$/,
3883 'be-BY': /^(\+?375)?(24|25|29|33|44)\d{7}$/,
3884 'bg-BG': /^(\+?359|0)?8[789]\d{7}$/,
3885 'bn-BD': /^(\+?880|0)1[13456789][0-9]{8}$/,
3886 'ca-AD': /^(\+376)?[346]\d{5}$/,
3887 'cs-CZ': /^(\+?420)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/,
3888 'da-DK': /^(\+?45)?\s?\d{2}\s?\d{2}\s?\d{2}\s?\d{2}$/,
3889 'de-DE': /^((\+49|0)[1|3])([0|5][0-45-9]\d|6([23]|0\d?)|7([0-57-9]|6\d))\d{7,9}$/,
3890 'de-AT': /^(\+43|0)\d{1,4}\d{3,12}$/,
3891 'de-CH': /^(\+41|0)([1-9])\d{1,9}$/,
3892 'de-LU': /^(\+352)?((6\d1)\d{6})$/,
3893 'dv-MV': /^(\+?960)?(7[2-9]|91|9[3-9])\d{7}$/,
3894 'el-GR': /^(\+?30|0)?(69\d{8})$/,
3895 'en-AU': /^(\+?61|0)4\d{8}$/,
3896 'en-BM': /^(\+?1)?441(((3|7)\d{6}$)|(5[0-3][0-9]\d{4}$)|(59\d{5}))/,
3897 'en-GB': /^(\+?44|0)7\d{9}$/,
3898 'en-GG': /^(\+?44|0)1481\d{6}$/,
3899 'en-GH': /^(\+233|0)(20|50|24|54|27|57|26|56|23|28|55|59)\d{7}$/,
3900 'en-GY': /^(\+592|0)6\d{6}$/,
3901 'en-HK': /^(\+?852[-\s]?)?[456789]\d{3}[-\s]?\d{4}$/,
3902 'en-MO': /^(\+?853[-\s]?)?[6]\d{3}[-\s]?\d{4}$/,
3903 'en-IE': /^(\+?353|0)8[356789]\d{7}$/,
3904 'en-IN': /^(\+?91|0)?[6789]\d{9}$/,
3905 'en-KE': /^(\+?254|0)(7|1)\d{8}$/,
3906 'en-KI': /^((\+686|686)?)?( )?((6|7)(2|3|8)[0-9]{6})$/,
3907 'en-MT': /^(\+?356|0)?(99|79|77|21|27|22|25)[0-9]{6}$/,
3908 'en-MU': /^(\+?230|0)?\d{8}$/,
3909 'en-NA': /^(\+?264|0)(6|8)\d{7}$/,
3910 'en-NG': /^(\+?234|0)?[789]\d{9}$/,
3911 'en-NZ': /^(\+?64|0)[28]\d{7,9}$/,
3912 'en-PK': /^((00|\+)?92|0)3[0-6]\d{8}$/,
3913 'en-PH': /^(09|\+639)\d{9}$/,
3914 'en-RW': /^(\+?250|0)?[7]\d{8}$/,
3915 'en-SG': /^(\+65)?[3689]\d{7}$/,
3916 'en-SL': /^(\+?232|0)\d{8}$/,
3917 'en-TZ': /^(\+?255|0)?[67]\d{8}$/,
3918 'en-UG': /^(\+?256|0)?[7]\d{8}$/,
3919 'en-US': /^((\+1|1)?( |-)?)?(\([2-9][0-9]{2}\)|[2-9][0-9]{2})( |-)?([2-9][0-9]{2}( |-)?[0-9]{4})$/,
3920 'en-ZA': /^(\+?27|0)\d{9}$/,
3921 'en-ZM': /^(\+?26)?09[567]\d{7}$/,
3922 'en-ZW': /^(\+263)[0-9]{9}$/,
3923 'en-BW': /^(\+?267)?(7[1-8]{1})\d{6}$/,
3924 'es-AR': /^\+?549(11|[2368]\d)\d{8}$/,
3925 'es-BO': /^(\+?591)?(6|7)\d{7}$/,
3926 'es-CO': /^(\+?57)?3(0(0|1|2|4|5)|1\d|2[0-4]|5(0|1))\d{7}$/,
3927 'es-CL': /^(\+?56|0)[2-9]\d{1}\d{7}$/,
3928 'es-CR': /^(\+506)?[2-8]\d{7}$/,
3929 'es-CU': /^(\+53|0053)?5\d{7}/,
3930 'es-DO': /^(\+?1)?8[024]9\d{7}$/,
3931 'es-HN': /^(\+?504)?[9|8]\d{7}$/,
3932 'es-EC': /^(\+?593|0)([2-7]|9[2-9])\d{7}$/,
3933 'es-ES': /^(\+?34)?[6|7]\d{8}$/,
3934 'es-PE': /^(\+?51)?9\d{8}$/,
3935 'es-MX': /^(\+?52)?(1|01)?\d{10,11}$/,
3936 'es-PA': /^(\+?507)\d{7,8}$/,
3937 'es-PY': /^(\+?595|0)9[9876]\d{7}$/,
3938 'es-SV': /^(\+?503)?[67]\d{7}$/,
3939 'es-UY': /^(\+598|0)9[1-9][\d]{6}$/,
3940 'es-VE': /^(\+?58)?(2|4)\d{9}$/,
3941 'et-EE': /^(\+?372)?\s?(5|8[1-4])\s?([0-9]\s?){6,7}$/,
3942 'fa-IR': /^(\+?98[\-\s]?|0)9[0-39]\d[\-\s]?\d{3}[\-\s]?\d{4}$/,
3943 'fi-FI': /^(\+?358|0)\s?(4(0|1|2|4|5|6)?|50)\s?(\d\s?){4,8}\d$/,
3944 'fj-FJ': /^(\+?679)?\s?\d{3}\s?\d{4}$/,
3945 'fo-FO': /^(\+?298)?\s?\d{2}\s?\d{2}\s?\d{2}$/,
3946 'fr-BF': /^(\+226|0)[67]\d{7}$/,
3947 'fr-CM': /^(\+?237)6[0-9]{8}$/,
3948 'fr-FR': /^(\+?33|0)[67]\d{8}$/,
3949 'fr-GF': /^(\+?594|0|00594)[67]\d{8}$/,
3950 'fr-GP': /^(\+?590|0|00590)[67]\d{8}$/,
3951 'fr-MQ': /^(\+?596|0|00596)[67]\d{8}$/,
3952 'fr-PF': /^(\+?689)?8[789]\d{6}$/,
3953 'fr-RE': /^(\+?262|0|00262)[67]\d{8}$/,
3954 'he-IL': /^(\+972|0)([23489]|5[012345689]|77)[1-9]\d{6}$/,
3955 'hu-HU': /^(\+?36|06)(20|30|31|50|70)\d{7}$/,
3956 'id-ID': /^(\+?62|0)8(1[123456789]|2[1238]|3[1238]|5[12356789]|7[78]|9[56789]|8[123456789])([\s?|\d]{5,11})$/,
3957 'it-IT': /^(\+?39)?\s?3\d{2} ?\d{6,7}$/,
3958 'it-SM': /^((\+378)|(0549)|(\+390549)|(\+3780549))?6\d{5,9}$/,
3959 'ja-JP': /^(\+81[ \-]?(\(0\))?|0)[6789]0[ \-]?\d{4}[ \-]?\d{4}$/,
3960 'ka-GE': /^(\+?995)?(5|79)\d{7}$/,
3961 'kk-KZ': /^(\+?7|8)?7\d{9}$/,
3962 'kl-GL': /^(\+?299)?\s?\d{2}\s?\d{2}\s?\d{2}$/,
3963 'ko-KR': /^((\+?82)[ \-]?)?0?1([0|1|6|7|8|9]{1})[ \-]?\d{3,4}[ \-]?\d{4}$/,
3964 'lt-LT': /^(\+370|8)\d{8}$/,
3965 'lv-LV': /^(\+?371)2\d{7}$/,
3966 'ms-MY': /^(\+?6?01){1}(([0145]{1}(\-|\s)?\d{7,8})|([236789]{1}(\s|\-)?\d{7}))$/,
3967 'mz-MZ': /^(\+?258)?8[234567]\d{7}$/,
3968 'nb-NO': /^(\+?47)?[49]\d{7}$/,
3969 'ne-NP': /^(\+?977)?9[78]\d{8}$/,
3970 'nl-BE': /^(\+?32|0)4\d{8}$/,
3971 'nl-NL': /^(((\+|00)?31\(0\))|((\+|00)?31)|0)6{1}\d{8}$/,
3972 'nn-NO': /^(\+?47)?[49]\d{7}$/,
3973 'pl-PL': /^(\+?48)? ?[5-8]\d ?\d{3} ?\d{2} ?\d{2}$/,
3974 '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[2-9]{1}\d{3}\-?\d{4}))$/,
3975 'pt-PT': /^(\+?351)?9[1236]\d{7}$/,
3976 'pt-AO': /^(\+244)\d{9}$/,
3977 'ro-RO': /^(\+?4?0)\s?7\d{2}(\/|\s|\.|\-)?\d{3}(\s|\.|\-)?\d{3}$/,
3978 'ru-RU': /^(\+?7|8)?9\d{9}$/,
3979 'si-LK': /^(?:0|94|\+94)?(7(0|1|2|4|5|6|7|8)( |-)?)\d{7}$/,
3980 'sl-SI': /^(\+386\s?|0)(\d{1}\s?\d{3}\s?\d{2}\s?\d{2}|\d{2}\s?\d{3}\s?\d{3})$/,
3981 'sk-SK': /^(\+?421)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/,
3982 'sq-AL': /^(\+355|0)6[789]\d{6}$/,
3983 'sr-RS': /^(\+3816|06)[- \d]{5,9}$/,
3984 'sv-SE': /^(\+?46|0)[\s\-]?7[\s\-]?[02369]([\s\-]?\d){7}$/,
3985 'tg-TJ': /^(\+?992)?[5][5]\d{7}$/,
3986 'th-TH': /^(\+66|66|0)\d{9}$/,
3987 'tr-TR': /^(\+?90|0)?5\d{9}$/,
3988 'tk-TM': /^(\+993|993|8)\d{8}$/,
3989 'uk-UA': /^(\+?38|8)?0\d{9}$/,
3990 'uz-UZ': /^(\+?998)?(6[125-79]|7[1-69]|88|9\d)\d{7}$/,
3991 'vi-VN': /^((\+?84)|0)((3([2-9]))|(5([25689]))|(7([0|6-9]))|(8([1-9]))|(9([0-9])))([0-9]{7})$/,
3992 'zh-CN': /^((\+|00)86)?(1[3-9]|9[28])\d{9}$/,
3993 'zh-TW': /^(\+?886\-?|0)?9\d{8}$/,
3994 'dz-BT': /^(\+?975|0)?(17|16|77|02)\d{6}$/
3995 };
3996 /* eslint-enable max-len */
3997 // aliases
3998
3999 phones['en-CA'] = phones['en-US'];
4000 phones['fr-CA'] = phones['en-CA'];
4001 phones['fr-BE'] = phones['nl-BE'];
4002 phones['zh-HK'] = phones['en-HK'];
4003 phones['zh-MO'] = phones['en-MO'];
4004 phones['ga-IE'] = phones['en-IE'];
4005 phones['fr-CH'] = phones['de-CH'];
4006 phones['it-CH'] = phones['fr-CH'];
4007
4008 function isMobilePhone$1(str, locale, options) {
4009 (0, _assertString$3.default)(str);
4010
4011 if (options && options.strictMode && !str.startsWith('+')) {
4012 return false;
4013 }
4014
4015 if (Array.isArray(locale)) {
4016 return locale.some(function (key) {
4017 // https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md#ignoring-code-for-coverage-purposes
4018 // istanbul ignore else
4019 if (phones.hasOwnProperty(key)) {
4020 var phone = phones[key];
4021
4022 if (phone.test(str)) {
4023 return true;
4024 }
4025 }
4026
4027 return false;
4028 });
4029 } else if (locale in phones) {
4030 return phones[locale].test(str); // alias falsey locale as 'any'
4031 } else if (!locale || locale === 'any') {
4032 for (var key in phones) {
4033 // istanbul ignore else
4034 if (phones.hasOwnProperty(key)) {
4035 var phone = phones[key];
4036
4037 if (phone.test(str)) {
4038 return true;
4039 }
4040 }
4041 }
4042
4043 return false;
4044 }
4045
4046 throw new Error("Invalid locale '".concat(locale, "'"));
4047 }
4048
4049 var locales$2 = Object.keys(phones);
4050 isMobilePhone$2.locales = locales$2;
4051
4052 var IS_MOBILE_PHONE = 'isMobilePhone';
4053 /**
4054 * Checks if the string is a mobile phone number (locale is either an array of locales (e.g ['sk-SK', 'sr-RS'])
4055 * OR one of ['am-Am', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', ar-JO', 'ar-KW', 'ar-SA', 'ar-SY', 'ar-TN', 'be-BY',
4056 * 'bg-BG', 'bn-BD', 'cs-CZ', 'da-DK', 'de-DE', 'de-AT', 'el-GR', 'en-AU', 'en-CA', 'en-GB', 'en-GG', 'en-GH', 'en-HK',
4057 * 'en-MO', 'en-IE', 'en-IN', 'en-KE', 'en-MT', 'en-MU', 'en-NG', 'en-NZ', 'en-PK', 'en-RW', 'en-SG', 'en-SL', 'en-UG',
4058 * 'en-US', 'en-TZ', 'en-ZA', 'en-ZM', 'es-CL', 'es-CR', 'es-EC', 'es-ES', 'es-MX', 'es-PA', 'es-PY', 'es-UY', 'et-EE',
4059 * 'fa-IR', 'fi-FI', 'fj-FJ', 'fo-FO', 'fr-BE', 'fr-FR', 'fr-GF', 'fr-GP', 'fr-MQ', 'fr-RE', 'he-IL', 'hu-HU', 'id-ID',
4060 * 'it-IT', 'ja-JP', 'kk-KZ', 'kl-GL', 'ko-KR', 'lt-LT', 'ms-MY', 'nb-NO', 'ne-NP', 'nl-BE', 'nl-NL', 'nn-NO', 'pl-PL',
4061 * 'pt-BR', 'pt-PT', 'ro-RO', 'ru-RU', 'sl-SI', 'sk-SK', 'sr-RS', 'sv-SE', 'th-TH', 'tr-TR', 'uk-UA', 'vi-VN', 'zh-CN',
4062 * 'zh-HK', 'zh-MO', 'zh-TW']
4063 * If given value is not a string, then it returns false.
4064 */
4065 function isMobilePhone(value, locale, options) {
4066 return typeof value === 'string' && _default$3(value, locale, options);
4067 }
4068 /**
4069 * Checks if the string is a mobile phone number (locale is either an array of locales (e.g ['sk-SK', 'sr-RS'])
4070 * OR one of ['am-Am', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', ar-JO', 'ar-KW', 'ar-SA', 'ar-SY', 'ar-TN', 'be-BY',
4071 * 'bg-BG', 'bn-BD', 'cs-CZ', 'da-DK', 'de-DE', 'de-AT', 'el-GR', 'en-AU', 'en-CA', 'en-GB', 'en-GG', 'en-GH', 'en-HK',
4072 * 'en-MO', 'en-IE', 'en-IN', 'en-KE', 'en-MT', 'en-MU', 'en-NG', 'en-NZ', 'en-PK', 'en-RW', 'en-SG', 'en-SL', 'en-UG',
4073 * 'en-US', 'en-TZ', 'en-ZA', 'en-ZM', 'es-CL', 'es-CR', 'es-EC', 'es-ES', 'es-MX', 'es-PA', 'es-PY', 'es-UY', 'et-EE',
4074 * 'fa-IR', 'fi-FI', 'fj-FJ', 'fo-FO', 'fr-BE', 'fr-FR', 'fr-GF', 'fr-GP', 'fr-MQ', 'fr-RE', 'he-IL', 'hu-HU', 'id-ID',
4075 * 'it-IT', 'ja-JP', 'kk-KZ', 'kl-GL', 'ko-KR', 'lt-LT', 'ms-MY', 'nb-NO', 'ne-NP', 'nl-BE', 'nl-NL', 'nn-NO', 'pl-PL',
4076 * 'pt-BR', 'pt-PT', 'ro-RO', 'ru-RU', 'sl-SI', 'sk-SK', 'sr-RS', 'sv-SE', 'th-TH', 'tr-TR', 'uk-UA', 'vi-VN', 'zh-CN',
4077 * 'zh-HK', 'zh-MO', 'zh-TW']
4078 * If given value is not a string, then it returns false.
4079 */
4080 function IsMobilePhone(locale, options, validationOptions) {
4081 return ValidateBy({
4082 name: IS_MOBILE_PHONE,
4083 constraints: [locale, options],
4084 validator: {
4085 validate: function (value, args) { return isMobilePhone(value, args.constraints[0], args.constraints[1]); },
4086 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be a phone number'); }, validationOptions),
4087 },
4088 }, validationOptions);
4089 }
4090
4091 var isISO31661Alpha2$2 = {};
4092
4093 Object.defineProperty(isISO31661Alpha2$2, "__esModule", {
4094 value: true
4095 });
4096 var _default$2 = isISO31661Alpha2$2.default = isISO31661Alpha2$1;
4097 isISO31661Alpha2$2.CountryCodes = void 0;
4098
4099 var _assertString$2 = _interopRequireDefault$2(assertString.exports);
4100
4101 function _interopRequireDefault$2(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4102
4103 // from https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
4104 var validISO31661Alpha2CountriesCodes = new Set(['AD', 'AE', 'AF', 'AG', 'AI', 'AL', 'AM', 'AO', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AW', 'AX', 'AZ', 'BA', 'BB', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ', 'BL', 'BM', 'BN', 'BO', 'BQ', 'BR', 'BS', 'BT', 'BV', 'BW', 'BY', 'BZ', 'CA', 'CC', 'CD', 'CF', 'CG', 'CH', 'CI', 'CK', 'CL', 'CM', 'CN', 'CO', 'CR', 'CU', 'CV', 'CW', 'CX', 'CY', 'CZ', 'DE', 'DJ', 'DK', 'DM', 'DO', 'DZ', 'EC', 'EE', 'EG', 'EH', 'ER', 'ES', 'ET', 'FI', 'FJ', 'FK', 'FM', 'FO', 'FR', 'GA', 'GB', 'GD', 'GE', 'GF', 'GG', 'GH', 'GI', 'GL', 'GM', 'GN', 'GP', 'GQ', 'GR', 'GS', 'GT', 'GU', 'GW', 'GY', 'HK', 'HM', 'HN', 'HR', 'HT', 'HU', 'ID', 'IE', 'IL', 'IM', 'IN', 'IO', 'IQ', 'IR', 'IS', 'IT', 'JE', 'JM', 'JO', 'JP', 'KE', 'KG', 'KH', 'KI', 'KM', 'KN', 'KP', 'KR', 'KW', 'KY', 'KZ', 'LA', 'LB', 'LC', 'LI', 'LK', 'LR', 'LS', 'LT', 'LU', 'LV', 'LY', 'MA', 'MC', 'MD', 'ME', 'MF', 'MG', 'MH', 'MK', 'ML', 'MM', 'MN', 'MO', 'MP', 'MQ', 'MR', 'MS', 'MT', 'MU', 'MV', 'MW', 'MX', 'MY', 'MZ', 'NA', 'NC', 'NE', 'NF', 'NG', 'NI', 'NL', 'NO', 'NP', 'NR', 'NU', 'NZ', 'OM', 'PA', 'PE', 'PF', 'PG', 'PH', 'PK', 'PL', 'PM', 'PN', 'PR', 'PS', 'PT', 'PW', 'PY', 'QA', 'RE', 'RO', 'RS', 'RU', 'RW', 'SA', 'SB', 'SC', 'SD', 'SE', 'SG', 'SH', 'SI', 'SJ', 'SK', 'SL', 'SM', 'SN', 'SO', 'SR', 'SS', 'ST', 'SV', 'SX', 'SY', 'SZ', 'TC', 'TD', 'TF', 'TG', 'TH', 'TJ', 'TK', 'TL', 'TM', 'TN', 'TO', 'TR', 'TT', 'TV', 'TW', 'TZ', 'UA', 'UG', 'UM', 'US', 'UY', 'UZ', 'VA', 'VC', 'VE', 'VG', 'VI', 'VN', 'VU', 'WF', 'WS', 'YE', 'YT', 'ZA', 'ZM', 'ZW']);
4105
4106 function isISO31661Alpha2$1(str) {
4107 (0, _assertString$2.default)(str);
4108 return validISO31661Alpha2CountriesCodes.has(str.toUpperCase());
4109 }
4110
4111 var CountryCodes = validISO31661Alpha2CountriesCodes;
4112 isISO31661Alpha2$2.CountryCodes = CountryCodes;
4113
4114 var IS_ISO31661_ALPHA_2 = 'isISO31661Alpha2';
4115 /**
4116 * Check if the string is a valid [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) officially assigned country code.
4117 */
4118 function isISO31661Alpha2(value) {
4119 return typeof value === 'string' && _default$2(value);
4120 }
4121 /**
4122 * Check if the string is a valid [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) officially assigned country code.
4123 */
4124 function IsISO31661Alpha2(validationOptions) {
4125 return ValidateBy({
4126 name: IS_ISO31661_ALPHA_2,
4127 validator: {
4128 validate: function (value, args) { return isISO31661Alpha2(value); },
4129 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be a valid ISO31661 Alpha2 code'); }, validationOptions),
4130 },
4131 }, validationOptions);
4132 }
4133
4134 var isISO31661Alpha3$1 = {exports: {}};
4135
4136 (function (module, exports) {
4137
4138 Object.defineProperty(exports, "__esModule", {
4139 value: true
4140 });
4141 exports.default = isISO31661Alpha3;
4142
4143 var _assertString = _interopRequireDefault(assertString.exports);
4144
4145 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4146
4147 // from https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3
4148 var validISO31661Alpha3CountriesCodes = new Set(['AFG', 'ALA', 'ALB', 'DZA', 'ASM', 'AND', 'AGO', 'AIA', 'ATA', 'ATG', 'ARG', 'ARM', 'ABW', 'AUS', 'AUT', 'AZE', 'BHS', 'BHR', 'BGD', 'BRB', 'BLR', 'BEL', 'BLZ', 'BEN', 'BMU', 'BTN', 'BOL', 'BES', 'BIH', 'BWA', 'BVT', 'BRA', 'IOT', 'BRN', 'BGR', 'BFA', 'BDI', 'KHM', 'CMR', 'CAN', 'CPV', 'CYM', 'CAF', 'TCD', 'CHL', 'CHN', 'CXR', 'CCK', 'COL', 'COM', 'COG', 'COD', 'COK', 'CRI', 'CIV', 'HRV', 'CUB', 'CUW', 'CYP', 'CZE', 'DNK', 'DJI', 'DMA', 'DOM', 'ECU', 'EGY', 'SLV', 'GNQ', 'ERI', 'EST', 'ETH', 'FLK', 'FRO', 'FJI', 'FIN', 'FRA', 'GUF', 'PYF', 'ATF', 'GAB', 'GMB', 'GEO', 'DEU', 'GHA', 'GIB', 'GRC', 'GRL', 'GRD', 'GLP', 'GUM', 'GTM', 'GGY', 'GIN', 'GNB', 'GUY', 'HTI', 'HMD', 'VAT', 'HND', 'HKG', 'HUN', 'ISL', 'IND', 'IDN', 'IRN', 'IRQ', 'IRL', 'IMN', 'ISR', 'ITA', 'JAM', 'JPN', 'JEY', 'JOR', 'KAZ', 'KEN', 'KIR', 'PRK', 'KOR', 'KWT', 'KGZ', 'LAO', 'LVA', 'LBN', 'LSO', 'LBR', 'LBY', 'LIE', 'LTU', 'LUX', 'MAC', 'MKD', 'MDG', 'MWI', 'MYS', 'MDV', 'MLI', 'MLT', 'MHL', 'MTQ', 'MRT', 'MUS', 'MYT', 'MEX', 'FSM', 'MDA', 'MCO', 'MNG', 'MNE', 'MSR', 'MAR', 'MOZ', 'MMR', 'NAM', 'NRU', 'NPL', 'NLD', 'NCL', 'NZL', 'NIC', 'NER', 'NGA', 'NIU', 'NFK', 'MNP', 'NOR', 'OMN', 'PAK', 'PLW', 'PSE', 'PAN', 'PNG', 'PRY', 'PER', 'PHL', 'PCN', 'POL', 'PRT', 'PRI', 'QAT', 'REU', 'ROU', 'RUS', 'RWA', 'BLM', 'SHN', 'KNA', 'LCA', 'MAF', 'SPM', 'VCT', 'WSM', 'SMR', 'STP', 'SAU', 'SEN', 'SRB', 'SYC', 'SLE', 'SGP', 'SXM', 'SVK', 'SVN', 'SLB', 'SOM', 'ZAF', 'SGS', 'SSD', 'ESP', 'LKA', 'SDN', 'SUR', 'SJM', 'SWZ', 'SWE', 'CHE', 'SYR', 'TWN', 'TJK', 'TZA', 'THA', 'TLS', 'TGO', 'TKL', 'TON', 'TTO', 'TUN', 'TUR', 'TKM', 'TCA', 'TUV', 'UGA', 'UKR', 'ARE', 'GBR', 'USA', 'UMI', 'URY', 'UZB', 'VUT', 'VEN', 'VNM', 'VGB', 'VIR', 'WLF', 'ESH', 'YEM', 'ZMB', 'ZWE']);
4149
4150 function isISO31661Alpha3(str) {
4151 (0, _assertString.default)(str);
4152 return validISO31661Alpha3CountriesCodes.has(str.toUpperCase());
4153 }
4154
4155 module.exports = exports.default;
4156 module.exports.default = exports.default;
4157 }(isISO31661Alpha3$1, isISO31661Alpha3$1.exports));
4158
4159 var isISO31661Alpha3Validator = /*@__PURE__*/getDefaultExportFromCjs(isISO31661Alpha3$1.exports);
4160
4161 var IS_ISO31661_ALPHA_3 = 'isISO31661Alpha3';
4162 /**
4163 * Check if the string is a valid [ISO 3166-1 alpha-3](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3) officially assigned country code.
4164 */
4165 function isISO31661Alpha3(value) {
4166 return typeof value === 'string' && isISO31661Alpha3Validator(value);
4167 }
4168 /**
4169 * Check if the string is a valid [ISO 3166-1 alpha-3](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3) officially assigned country code.
4170 */
4171 function IsISO31661Alpha3(validationOptions) {
4172 return ValidateBy({
4173 name: IS_ISO31661_ALPHA_3,
4174 validator: {
4175 validate: function (value, args) { return isISO31661Alpha3(value); },
4176 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be a valid ISO31661 Alpha3 code'); }, validationOptions),
4177 },
4178 }, validationOptions);
4179 }
4180
4181 var isMongoId$1 = {exports: {}};
4182
4183 (function (module, exports) {
4184
4185 Object.defineProperty(exports, "__esModule", {
4186 value: true
4187 });
4188 exports.default = isMongoId;
4189
4190 var _assertString = _interopRequireDefault(assertString.exports);
4191
4192 var _isHexadecimal = _interopRequireDefault(isHexadecimal$1.exports);
4193
4194 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4195
4196 function isMongoId(str) {
4197 (0, _assertString.default)(str);
4198 return (0, _isHexadecimal.default)(str) && str.length === 24;
4199 }
4200
4201 module.exports = exports.default;
4202 module.exports.default = exports.default;
4203 }(isMongoId$1, isMongoId$1.exports));
4204
4205 var isMongoIdValidator = /*@__PURE__*/getDefaultExportFromCjs(isMongoId$1.exports);
4206
4207 var IS_MONGO_ID = 'isMongoId';
4208 /**
4209 * Checks if the string is a valid hex-encoded representation of a MongoDB ObjectId.
4210 * If given value is not a string, then it returns false.
4211 */
4212 function isMongoId(value) {
4213 return typeof value === 'string' && isMongoIdValidator(value);
4214 }
4215 /**
4216 * Checks if the string is a valid hex-encoded representation of a MongoDB ObjectId.
4217 * If given value is not a string, then it returns false.
4218 */
4219 function IsMongoId(validationOptions) {
4220 return ValidateBy({
4221 name: IS_MONGO_ID,
4222 validator: {
4223 validate: function (value, args) { return isMongoId(value); },
4224 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be a mongodb id'); }, validationOptions),
4225 },
4226 }, validationOptions);
4227 }
4228
4229 var isMultibyte$1 = {exports: {}};
4230
4231 (function (module, exports) {
4232
4233 Object.defineProperty(exports, "__esModule", {
4234 value: true
4235 });
4236 exports.default = isMultibyte;
4237
4238 var _assertString = _interopRequireDefault(assertString.exports);
4239
4240 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4241
4242 /* eslint-disable no-control-regex */
4243 var multibyte = /[^\x00-\x7F]/;
4244 /* eslint-enable no-control-regex */
4245
4246 function isMultibyte(str) {
4247 (0, _assertString.default)(str);
4248 return multibyte.test(str);
4249 }
4250
4251 module.exports = exports.default;
4252 module.exports.default = exports.default;
4253 }(isMultibyte$1, isMultibyte$1.exports));
4254
4255 var isMultibyteValidator = /*@__PURE__*/getDefaultExportFromCjs(isMultibyte$1.exports);
4256
4257 var IS_MULTIBYTE = 'isMultibyte';
4258 /**
4259 * Checks if the string contains one or more multibyte chars.
4260 * If given value is not a string, then it returns false.
4261 */
4262 function isMultibyte(value) {
4263 return typeof value === 'string' && isMultibyteValidator(value);
4264 }
4265 /**
4266 * Checks if the string contains one or more multibyte chars.
4267 * If given value is not a string, then it returns false.
4268 */
4269 function IsMultibyte(validationOptions) {
4270 return ValidateBy({
4271 name: IS_MULTIBYTE,
4272 validator: {
4273 validate: function (value, args) { return isMultibyte(value); },
4274 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must contain one or more multibyte chars'); }, validationOptions),
4275 },
4276 }, validationOptions);
4277 }
4278
4279 var isSurrogatePair$1 = {exports: {}};
4280
4281 (function (module, exports) {
4282
4283 Object.defineProperty(exports, "__esModule", {
4284 value: true
4285 });
4286 exports.default = isSurrogatePair;
4287
4288 var _assertString = _interopRequireDefault(assertString.exports);
4289
4290 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4291
4292 var surrogatePair = /[\uD800-\uDBFF][\uDC00-\uDFFF]/;
4293
4294 function isSurrogatePair(str) {
4295 (0, _assertString.default)(str);
4296 return surrogatePair.test(str);
4297 }
4298
4299 module.exports = exports.default;
4300 module.exports.default = exports.default;
4301 }(isSurrogatePair$1, isSurrogatePair$1.exports));
4302
4303 var isSurrogatePairValidator = /*@__PURE__*/getDefaultExportFromCjs(isSurrogatePair$1.exports);
4304
4305 var IS_SURROGATE_PAIR = 'isSurrogatePair';
4306 /**
4307 * Checks if the string contains any surrogate pairs chars.
4308 * If given value is not a string, then it returns false.
4309 */
4310 function isSurrogatePair(value) {
4311 return typeof value === 'string' && isSurrogatePairValidator(value);
4312 }
4313 /**
4314 * Checks if the string contains any surrogate pairs chars.
4315 * If given value is not a string, then it returns false.
4316 */
4317 function IsSurrogatePair(validationOptions) {
4318 return ValidateBy({
4319 name: IS_SURROGATE_PAIR,
4320 validator: {
4321 validate: function (value, args) { return isSurrogatePair(value); },
4322 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must contain any surrogate pairs chars'); }, validationOptions),
4323 },
4324 }, validationOptions);
4325 }
4326
4327 var isURL$1 = {exports: {}};
4328
4329 (function (module, exports) {
4330
4331 Object.defineProperty(exports, "__esModule", {
4332 value: true
4333 });
4334 exports.default = isURL;
4335
4336 var _assertString = _interopRequireDefault(assertString.exports);
4337
4338 var _isFQDN = _interopRequireDefault(isFQDN$1.exports);
4339
4340 var _isIP = _interopRequireDefault(isIP$1.exports);
4341
4342 var _merge = _interopRequireDefault(merge.exports);
4343
4344 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4345
4346 function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
4347
4348 function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4349
4350 function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4351
4352 function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
4353
4354 function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
4355
4356 function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
4357
4358 /*
4359 options for isURL method
4360
4361 require_protocol - if set as true isURL will return false if protocol is not present in the URL
4362 require_valid_protocol - isURL will check if the URL's protocol is present in the protocols option
4363 protocols - valid protocols can be modified with this option
4364 require_host - if set as false isURL will not check if host is present in the URL
4365 require_port - if set as true isURL will check if port is present in the URL
4366 allow_protocol_relative_urls - if set as true protocol relative URLs will be allowed
4367 validate_length - if set as false isURL will skip string length validation (IE maximum is 2083)
4368
4369 */
4370 var default_url_options = {
4371 protocols: ['http', 'https', 'ftp'],
4372 require_tld: true,
4373 require_protocol: false,
4374 require_host: true,
4375 require_port: false,
4376 require_valid_protocol: true,
4377 allow_underscores: false,
4378 allow_trailing_dot: false,
4379 allow_protocol_relative_urls: false,
4380 allow_fragments: true,
4381 allow_query_components: true,
4382 validate_length: true
4383 };
4384 var wrapped_ipv6 = /^\[([^\]]+)\](?::([0-9]+))?$/;
4385
4386 function isRegExp(obj) {
4387 return Object.prototype.toString.call(obj) === '[object RegExp]';
4388 }
4389
4390 function checkHost(host, matches) {
4391 for (var i = 0; i < matches.length; i++) {
4392 var match = matches[i];
4393
4394 if (host === match || isRegExp(match) && match.test(host)) {
4395 return true;
4396 }
4397 }
4398
4399 return false;
4400 }
4401
4402 function isURL(url, options) {
4403 (0, _assertString.default)(url);
4404
4405 if (!url || /[\s<>]/.test(url)) {
4406 return false;
4407 }
4408
4409 if (url.indexOf('mailto:') === 0) {
4410 return false;
4411 }
4412
4413 options = (0, _merge.default)(options, default_url_options);
4414
4415 if (options.validate_length && url.length >= 2083) {
4416 return false;
4417 }
4418
4419 if (!options.allow_fragments && url.includes('#')) {
4420 return false;
4421 }
4422
4423 if (!options.allow_query_components && (url.includes('?') || url.includes('&'))) {
4424 return false;
4425 }
4426
4427 var protocol, auth, host, hostname, port, port_str, split, ipv6;
4428 split = url.split('#');
4429 url = split.shift();
4430 split = url.split('?');
4431 url = split.shift();
4432 split = url.split('://');
4433
4434 if (split.length > 1) {
4435 protocol = split.shift().toLowerCase();
4436
4437 if (options.require_valid_protocol && options.protocols.indexOf(protocol) === -1) {
4438 return false;
4439 }
4440 } else if (options.require_protocol) {
4441 return false;
4442 } else if (url.substr(0, 2) === '//') {
4443 if (!options.allow_protocol_relative_urls) {
4444 return false;
4445 }
4446
4447 split[0] = url.substr(2);
4448 }
4449
4450 url = split.join('://');
4451
4452 if (url === '') {
4453 return false;
4454 }
4455
4456 split = url.split('/');
4457 url = split.shift();
4458
4459 if (url === '' && !options.require_host) {
4460 return true;
4461 }
4462
4463 split = url.split('@');
4464
4465 if (split.length > 1) {
4466 if (options.disallow_auth) {
4467 return false;
4468 }
4469
4470 if (split[0] === '') {
4471 return false;
4472 }
4473
4474 auth = split.shift();
4475
4476 if (auth.indexOf(':') >= 0 && auth.split(':').length > 2) {
4477 return false;
4478 }
4479
4480 var _auth$split = auth.split(':'),
4481 _auth$split2 = _slicedToArray(_auth$split, 2),
4482 user = _auth$split2[0],
4483 password = _auth$split2[1];
4484
4485 if (user === '' && password === '') {
4486 return false;
4487 }
4488 }
4489
4490 hostname = split.join('@');
4491 port_str = null;
4492 ipv6 = null;
4493 var ipv6_match = hostname.match(wrapped_ipv6);
4494
4495 if (ipv6_match) {
4496 host = '';
4497 ipv6 = ipv6_match[1];
4498 port_str = ipv6_match[2] || null;
4499 } else {
4500 split = hostname.split(':');
4501 host = split.shift();
4502
4503 if (split.length) {
4504 port_str = split.join(':');
4505 }
4506 }
4507
4508 if (port_str !== null && port_str.length > 0) {
4509 port = parseInt(port_str, 10);
4510
4511 if (!/^[0-9]+$/.test(port_str) || port <= 0 || port > 65535) {
4512 return false;
4513 }
4514 } else if (options.require_port) {
4515 return false;
4516 }
4517
4518 if (options.host_whitelist) {
4519 return checkHost(host, options.host_whitelist);
4520 }
4521
4522 if (!(0, _isIP.default)(host) && !(0, _isFQDN.default)(host, options) && (!ipv6 || !(0, _isIP.default)(ipv6, 6))) {
4523 return false;
4524 }
4525
4526 host = host || ipv6;
4527
4528 if (options.host_blacklist && checkHost(host, options.host_blacklist)) {
4529 return false;
4530 }
4531
4532 return true;
4533 }
4534
4535 module.exports = exports.default;
4536 module.exports.default = exports.default;
4537 }(isURL$1, isURL$1.exports));
4538
4539 var isUrlValidator = /*@__PURE__*/getDefaultExportFromCjs(isURL$1.exports);
4540
4541 var IS_URL = 'isUrl';
4542 /**
4543 * Checks if the string is an url.
4544 * If given value is not a string, then it returns false.
4545 */
4546 function isURL(value, options) {
4547 return typeof value === 'string' && isUrlValidator(value, options);
4548 }
4549 /**
4550 * Checks if the string is an url.
4551 * If given value is not a string, then it returns false.
4552 */
4553 function IsUrl(options, validationOptions) {
4554 return ValidateBy({
4555 name: IS_URL,
4556 constraints: [options],
4557 validator: {
4558 validate: function (value, args) { return isURL(value, args.constraints[0]); },
4559 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be an URL address'); }, validationOptions),
4560 },
4561 }, validationOptions);
4562 }
4563
4564 var isUUID$1 = {exports: {}};
4565
4566 (function (module, exports) {
4567
4568 Object.defineProperty(exports, "__esModule", {
4569 value: true
4570 });
4571 exports.default = isUUID;
4572
4573 var _assertString = _interopRequireDefault(assertString.exports);
4574
4575 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4576
4577 var uuid = {
4578 1: /^[0-9A-F]{8}-[0-9A-F]{4}-1[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i,
4579 2: /^[0-9A-F]{8}-[0-9A-F]{4}-2[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i,
4580 3: /^[0-9A-F]{8}-[0-9A-F]{4}-3[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i,
4581 4: /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,
4582 5: /^[0-9A-F]{8}-[0-9A-F]{4}-5[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,
4583 all: /^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i
4584 };
4585
4586 function isUUID(str, version) {
4587 (0, _assertString.default)(str);
4588 var pattern = uuid[![undefined, null].includes(version) ? version : 'all'];
4589 return !!pattern && pattern.test(str);
4590 }
4591
4592 module.exports = exports.default;
4593 module.exports.default = exports.default;
4594 }(isUUID$1, isUUID$1.exports));
4595
4596 var isUuidValidator = /*@__PURE__*/getDefaultExportFromCjs(isUUID$1.exports);
4597
4598 var IS_UUID = 'isUuid';
4599 /**
4600 * Checks if the string is a UUID (version 3, 4 or 5).
4601 * If given value is not a string, then it returns false.
4602 */
4603 function isUUID(value, version) {
4604 return typeof value === 'string' && isUuidValidator(value, version);
4605 }
4606 /**
4607 * Checks if the string is a UUID (version 3, 4 or 5).
4608 * If given value is not a string, then it returns false.
4609 */
4610 function IsUUID(version, validationOptions) {
4611 return ValidateBy({
4612 name: IS_UUID,
4613 constraints: [version],
4614 validator: {
4615 validate: function (value, args) { return isUUID(value, args.constraints[0]); },
4616 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be a UUID'); }, validationOptions),
4617 },
4618 }, validationOptions);
4619 }
4620
4621 var IS_FIREBASE_PUSH_ID = 'IsFirebasePushId';
4622 /**
4623 * Checks if the string is a Firebase Push Id
4624 * If given value is not a Firebase Push Id, it returns false
4625 */
4626 function isFirebasePushId(value) {
4627 var webSafeRegex = /^[a-zA-Z0-9_-]*$/;
4628 return typeof value === 'string' && value.length === 20 && webSafeRegex.test(value);
4629 }
4630 /**
4631 * Checks if the string is a Firebase Push Id
4632 * If given value is not a Firebase Push Id, it returns false
4633 */
4634 function IsFirebasePushId(validationOptions) {
4635 return ValidateBy({
4636 name: IS_FIREBASE_PUSH_ID,
4637 validator: {
4638 validate: function (value, args) { return isFirebasePushId(value); },
4639 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be a Firebase Push Id'); }, validationOptions),
4640 },
4641 }, validationOptions);
4642 }
4643
4644 var isUppercase$1 = {exports: {}};
4645
4646 (function (module, exports) {
4647
4648 Object.defineProperty(exports, "__esModule", {
4649 value: true
4650 });
4651 exports.default = isUppercase;
4652
4653 var _assertString = _interopRequireDefault(assertString.exports);
4654
4655 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4656
4657 function isUppercase(str) {
4658 (0, _assertString.default)(str);
4659 return str === str.toUpperCase();
4660 }
4661
4662 module.exports = exports.default;
4663 module.exports.default = exports.default;
4664 }(isUppercase$1, isUppercase$1.exports));
4665
4666 var isUppercaseValidator = /*@__PURE__*/getDefaultExportFromCjs(isUppercase$1.exports);
4667
4668 var IS_UPPERCASE = 'isUppercase';
4669 /**
4670 * Checks if the string is uppercase.
4671 * If given value is not a string, then it returns false.
4672 */
4673 function isUppercase(value) {
4674 return typeof value === 'string' && isUppercaseValidator(value);
4675 }
4676 /**
4677 * Checks if the string is uppercase.
4678 * If given value is not a string, then it returns false.
4679 */
4680 function IsUppercase(validationOptions) {
4681 return ValidateBy({
4682 name: IS_UPPERCASE,
4683 validator: {
4684 validate: function (value, args) { return isUppercase(value); },
4685 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be uppercase'); }, validationOptions),
4686 },
4687 }, validationOptions);
4688 }
4689
4690 var isLength = {exports: {}};
4691
4692 (function (module, exports) {
4693
4694 Object.defineProperty(exports, "__esModule", {
4695 value: true
4696 });
4697 exports.default = isLength;
4698
4699 var _assertString = _interopRequireDefault(assertString.exports);
4700
4701 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4702
4703 function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4704
4705 /* eslint-disable prefer-rest-params */
4706 function isLength(str, options) {
4707 (0, _assertString.default)(str);
4708 var min;
4709 var max;
4710
4711 if (_typeof(options) === 'object') {
4712 min = options.min || 0;
4713 max = options.max;
4714 } else {
4715 // backwards compatibility: isLength(str, min [, max])
4716 min = arguments[1] || 0;
4717 max = arguments[2];
4718 }
4719
4720 var surrogatePairs = str.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g) || [];
4721 var len = str.length - surrogatePairs.length;
4722 return len >= min && (typeof max === 'undefined' || len <= max);
4723 }
4724
4725 module.exports = exports.default;
4726 module.exports.default = exports.default;
4727 }(isLength, isLength.exports));
4728
4729 var isLengthValidator = /*@__PURE__*/getDefaultExportFromCjs(isLength.exports);
4730
4731 var IS_LENGTH = 'isLength';
4732 /**
4733 * Checks if the string's length falls in a range. Note: this function takes into account surrogate pairs.
4734 * If given value is not a string, then it returns false.
4735 */
4736 function length(value, min, max) {
4737 return typeof value === 'string' && isLengthValidator(value, { min: min, max: max });
4738 }
4739 /**
4740 * Checks if the string's length falls in a range. Note: this function takes into account surrogate pairs.
4741 * If given value is not a string, then it returns false.
4742 */
4743 function Length(min, max, validationOptions) {
4744 return ValidateBy({
4745 name: IS_LENGTH,
4746 constraints: [min, max],
4747 validator: {
4748 validate: function (value, args) { return length(value, args.constraints[0], args.constraints[1]); },
4749 defaultMessage: buildMessage(function (eachPrefix, args) {
4750 var isMinLength = args.constraints[0] !== null && args.constraints[0] !== undefined;
4751 var isMaxLength = args.constraints[1] !== null && args.constraints[1] !== undefined;
4752 if (isMinLength && (!args.value || args.value.length < args.constraints[0])) {
4753 return eachPrefix + getText('$property must be longer than or equal to $constraint1 characters');
4754 }
4755 else if (isMaxLength && args.value.length > args.constraints[1]) {
4756 return eachPrefix + getText('$property must be shorter than or equal to $constraint2 characters');
4757 }
4758 return (eachPrefix +
4759 getText('$property must be longer than or equal to $constraint1 and shorter than or equal to $constraint2 characters'));
4760 }, validationOptions),
4761 },
4762 }, validationOptions);
4763 }
4764
4765 var MAX_LENGTH = 'maxLength';
4766 /**
4767 * Checks if the string's length is not more than given number. Note: this function takes into account surrogate pairs.
4768 * If given value is not a string, then it returns false.
4769 */
4770 function maxLength(value, max) {
4771 return typeof value === 'string' && isLengthValidator(value, { min: 0, max: max });
4772 }
4773 /**
4774 * Checks if the string's length is not more than given number. Note: this function takes into account surrogate pairs.
4775 * If given value is not a string, then it returns false.
4776 */
4777 function MaxLength(max, validationOptions) {
4778 return ValidateBy({
4779 name: MAX_LENGTH,
4780 constraints: [max],
4781 validator: {
4782 validate: function (value, args) { return maxLength(value, args.constraints[0]); },
4783 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be shorter than or equal to $constraint1 characters'); }, validationOptions),
4784 },
4785 }, validationOptions);
4786 }
4787
4788 var MIN_LENGTH = 'minLength';
4789 /**
4790 * Checks if the string's length is not less than given number. Note: this function takes into account surrogate pairs.
4791 * If given value is not a string, then it returns false.
4792 */
4793 function minLength(value, min) {
4794 return typeof value === 'string' && isLengthValidator(value, { min: min });
4795 }
4796 /**
4797 * Checks if the string's length is not less than given number. Note: this function takes into account surrogate pairs.
4798 * If given value is not a string, then it returns false.
4799 */
4800 function MinLength(min, validationOptions) {
4801 return ValidateBy({
4802 name: MIN_LENGTH,
4803 constraints: [min],
4804 validator: {
4805 validate: function (value, args) { return minLength(value, args.constraints[0]); },
4806 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be longer than or equal to $constraint1 characters'); }, validationOptions),
4807 },
4808 }, validationOptions);
4809 }
4810
4811 var matches$1 = {exports: {}};
4812
4813 (function (module, exports) {
4814
4815 Object.defineProperty(exports, "__esModule", {
4816 value: true
4817 });
4818 exports.default = matches;
4819
4820 var _assertString = _interopRequireDefault(assertString.exports);
4821
4822 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4823
4824 function matches(str, pattern, modifiers) {
4825 (0, _assertString.default)(str);
4826
4827 if (Object.prototype.toString.call(pattern) !== '[object RegExp]') {
4828 pattern = new RegExp(pattern, modifiers);
4829 }
4830
4831 return pattern.test(str);
4832 }
4833
4834 module.exports = exports.default;
4835 module.exports.default = exports.default;
4836 }(matches$1, matches$1.exports));
4837
4838 var matchesValidator = /*@__PURE__*/getDefaultExportFromCjs(matches$1.exports);
4839
4840 var MATCHES = 'matches';
4841 function matches(value, pattern, modifiers) {
4842 return typeof value === 'string' && matchesValidator(value, pattern, modifiers);
4843 }
4844 function Matches(pattern, modifiersOrAnnotationOptions, validationOptions) {
4845 var modifiers;
4846 if (modifiersOrAnnotationOptions && modifiersOrAnnotationOptions instanceof Object && !validationOptions) {
4847 validationOptions = modifiersOrAnnotationOptions;
4848 }
4849 else {
4850 modifiers = modifiersOrAnnotationOptions;
4851 }
4852 return ValidateBy({
4853 name: MATCHES,
4854 constraints: [pattern, modifiers],
4855 validator: {
4856 validate: function (value, args) { return matches(value, args.constraints[0], args.constraints[1]); },
4857 defaultMessage: buildMessage(function (eachPrefix, args) { return eachPrefix + getText('$property must match $constraint1 regular expression'); }, validationOptions),
4858 },
4859 }, validationOptions);
4860 }
4861
4862 // This file is a workaround for a bug in web browsers' "native"
4863 // ES6 importing system which is uncapable of importing "*.json" files.
4864 // https://github.com/catamphetamine/libphonenumber-js/issues/239
4865 var metadata = {"version":4,"country_calling_codes":{"1":["US","AG","AI","AS","BB","BM","BS","CA","DM","DO","GD","GU","JM","KN","KY","LC","MP","MS","PR","SX","TC","TT","VC","VG","VI"],"7":["RU","KZ"],"20":["EG"],"27":["ZA"],"30":["GR"],"31":["NL"],"32":["BE"],"33":["FR"],"34":["ES"],"36":["HU"],"39":["IT","VA"],"40":["RO"],"41":["CH"],"43":["AT"],"44":["GB","GG","IM","JE"],"45":["DK"],"46":["SE"],"47":["NO","SJ"],"48":["PL"],"49":["DE"],"51":["PE"],"52":["MX"],"53":["CU"],"54":["AR"],"55":["BR"],"56":["CL"],"57":["CO"],"58":["VE"],"60":["MY"],"61":["AU","CC","CX"],"62":["ID"],"63":["PH"],"64":["NZ"],"65":["SG"],"66":["TH"],"81":["JP"],"82":["KR"],"84":["VN"],"86":["CN"],"90":["TR"],"91":["IN"],"92":["PK"],"93":["AF"],"94":["LK"],"95":["MM"],"98":["IR"],"211":["SS"],"212":["MA","EH"],"213":["DZ"],"216":["TN"],"218":["LY"],"220":["GM"],"221":["SN"],"222":["MR"],"223":["ML"],"224":["GN"],"225":["CI"],"226":["BF"],"227":["NE"],"228":["TG"],"229":["BJ"],"230":["MU"],"231":["LR"],"232":["SL"],"233":["GH"],"234":["NG"],"235":["TD"],"236":["CF"],"237":["CM"],"238":["CV"],"239":["ST"],"240":["GQ"],"241":["GA"],"242":["CG"],"243":["CD"],"244":["AO"],"245":["GW"],"246":["IO"],"247":["AC"],"248":["SC"],"249":["SD"],"250":["RW"],"251":["ET"],"252":["SO"],"253":["DJ"],"254":["KE"],"255":["TZ"],"256":["UG"],"257":["BI"],"258":["MZ"],"260":["ZM"],"261":["MG"],"262":["RE","YT"],"263":["ZW"],"264":["NA"],"265":["MW"],"266":["LS"],"267":["BW"],"268":["SZ"],"269":["KM"],"290":["SH","TA"],"291":["ER"],"297":["AW"],"298":["FO"],"299":["GL"],"350":["GI"],"351":["PT"],"352":["LU"],"353":["IE"],"354":["IS"],"355":["AL"],"356":["MT"],"357":["CY"],"358":["FI","AX"],"359":["BG"],"370":["LT"],"371":["LV"],"372":["EE"],"373":["MD"],"374":["AM"],"375":["BY"],"376":["AD"],"377":["MC"],"378":["SM"],"380":["UA"],"381":["RS"],"382":["ME"],"383":["XK"],"385":["HR"],"386":["SI"],"387":["BA"],"389":["MK"],"420":["CZ"],"421":["SK"],"423":["LI"],"500":["FK"],"501":["BZ"],"502":["GT"],"503":["SV"],"504":["HN"],"505":["NI"],"506":["CR"],"507":["PA"],"508":["PM"],"509":["HT"],"590":["GP","BL","MF"],"591":["BO"],"592":["GY"],"593":["EC"],"594":["GF"],"595":["PY"],"596":["MQ"],"597":["SR"],"598":["UY"],"599":["CW","BQ"],"670":["TL"],"672":["NF"],"673":["BN"],"674":["NR"],"675":["PG"],"676":["TO"],"677":["SB"],"678":["VU"],"679":["FJ"],"680":["PW"],"681":["WF"],"682":["CK"],"683":["NU"],"685":["WS"],"686":["KI"],"687":["NC"],"688":["TV"],"689":["PF"],"690":["TK"],"691":["FM"],"692":["MH"],"850":["KP"],"852":["HK"],"853":["MO"],"855":["KH"],"856":["LA"],"880":["BD"],"886":["TW"],"960":["MV"],"961":["LB"],"962":["JO"],"963":["SY"],"964":["IQ"],"965":["KW"],"966":["SA"],"967":["YE"],"968":["OM"],"970":["PS"],"971":["AE"],"972":["IL"],"973":["BH"],"974":["QA"],"975":["BT"],"976":["MN"],"977":["NP"],"992":["TJ"],"993":["TM"],"994":["AZ"],"995":["GE"],"996":["KG"],"998":["UZ"]},"countries":{"AC":["247","00","(?:[01589]\\d|[46])\\d{4}",[5,6]],"AD":["376","00","(?:1|6\\d)\\d{7}|[135-9]\\d{5}",[6,8,9],[["(\\d{3})(\\d{3})","$1 $2",["[135-9]"]],["(\\d{4})(\\d{4})","$1 $2",["1"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6"]]]],"AE":["971","00","(?:[4-7]\\d|9[0-689])\\d{7}|800\\d{2,9}|[2-4679]\\d{7}",[5,6,7,8,9,10,11,12],[["(\\d{3})(\\d{2,9})","$1 $2",["60|8"]],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[236]|[479][2-8]"],"0$1"],["(\\d{3})(\\d)(\\d{5})","$1 $2 $3",["[479]"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["5"],"0$1"]],"0"],"AF":["93","00","[2-7]\\d{8}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[2-7]"],"0$1"]],"0"],"AG":["1","011","(?:268|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"1|([457]\\d{6})$","268$1",0,"268"],"AI":["1","011","(?:264|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"1|([2457]\\d{6})$","264$1",0,"264"],"AL":["355","00","(?:700\\d\\d|900)\\d{3}|8\\d{5,7}|(?:[2-5]|6\\d)\\d{7}",[6,7,8,9],[["(\\d{3})(\\d{3,4})","$1 $2",["80|9"],"0$1"],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["4[2-6]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[2358][2-5]|4"],"0$1"],["(\\d{3})(\\d{5})","$1 $2",["[23578]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["6"],"0$1"]],"0"],"AM":["374","00","(?:[1-489]\\d|55|60|77)\\d{6}",[8],[["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["[89]0"],"0 $1"],["(\\d{3})(\\d{5})","$1 $2",["2|3[12]"],"(0$1)"],["(\\d{2})(\\d{6})","$1 $2",["1|47"],"(0$1)"],["(\\d{2})(\\d{6})","$1 $2",["[3-9]"],"0$1"]],"0"],"AO":["244","00","[29]\\d{8}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[29]"]]]],"AR":["54","00","(?:11|[89]\\d\\d)\\d{8}|[2368]\\d{9}",[10,11],[["(\\d{4})(\\d{2})(\\d{4})","$1 $2-$3",["2(?:2[024-9]|3[0-59]|47|6[245]|9[02-8])|3(?:3[28]|4[03-9]|5[2-46-8]|7[1-578]|8[2-9])","2(?:[23]02|6(?:[25]|4[6-8])|9(?:[02356]|4[02568]|72|8[23]))|3(?:3[28]|4(?:[04679]|3[5-8]|5[4-68]|8[2379])|5(?:[2467]|3[237]|8[2-5])|7[1-578]|8(?:[2469]|3[2578]|5[4-8]|7[36-8]|8[5-8]))|2(?:2[24-9]|3[1-59]|47)","2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3[78]|5(?:4[46]|8)|8[2379])|5(?:[2467]|3[237]|8[23])|7[1-578]|8(?:[2469]|3[278]|5[56][46]|86[3-6]))|2(?:2[24-9]|3[1-59]|47)|38(?:[58][78]|7[378])|3(?:4[35][56]|58[45]|8(?:[38]5|54|76))[4-6]","2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3(?:5(?:4[0-25689]|[56])|[78])|58|8[2379])|5(?:[2467]|3[237]|8(?:[23]|4(?:[45]|60)|5(?:4[0-39]|5|64)))|7[1-578]|8(?:[2469]|3[278]|54(?:4|5[13-7]|6[89])|86[3-6]))|2(?:2[24-9]|3[1-59]|47)|38(?:[58][78]|7[378])|3(?:454|85[56])[46]|3(?:4(?:36|5[56])|8(?:[38]5|76))[4-6]"],"0$1",1],["(\\d{2})(\\d{4})(\\d{4})","$1 $2-$3",["1"],"0$1",1],["(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["[68]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2-$3",["[23]"],"0$1",1],["(\\d)(\\d{4})(\\d{2})(\\d{4})","$2 15-$3-$4",["9(?:2[2-469]|3[3-578])","9(?:2(?:2[024-9]|3[0-59]|47|6[245]|9[02-8])|3(?:3[28]|4[03-9]|5[2-46-8]|7[1-578]|8[2-9]))","9(?:2(?:[23]02|6(?:[25]|4[6-8])|9(?:[02356]|4[02568]|72|8[23]))|3(?:3[28]|4(?:[04679]|3[5-8]|5[4-68]|8[2379])|5(?:[2467]|3[237]|8[2-5])|7[1-578]|8(?:[2469]|3[2578]|5[4-8]|7[36-8]|8[5-8])))|92(?:2[24-9]|3[1-59]|47)","9(?:2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3[78]|5(?:4[46]|8)|8[2379])|5(?:[2467]|3[237]|8[23])|7[1-578]|8(?:[2469]|3[278]|5(?:[56][46]|[78])|7[378]|8(?:6[3-6]|[78]))))|92(?:2[24-9]|3[1-59]|47)|93(?:4[35][56]|58[45]|8(?:[38]5|54|76))[4-6]","9(?:2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3(?:5(?:4[0-25689]|[56])|[78])|5(?:4[46]|8)|8[2379])|5(?:[2467]|3[237]|8(?:[23]|4(?:[45]|60)|5(?:4[0-39]|5|64)))|7[1-578]|8(?:[2469]|3[278]|5(?:4(?:4|5[13-7]|6[89])|[56][46]|[78])|7[378]|8(?:6[3-6]|[78]))))|92(?:2[24-9]|3[1-59]|47)|93(?:4(?:36|5[56])|8(?:[38]5|76))[4-6]"],"0$1",0,"$1 $2 $3-$4"],["(\\d)(\\d{2})(\\d{4})(\\d{4})","$2 15-$3-$4",["91"],"0$1",0,"$1 $2 $3-$4"],["(\\d{3})(\\d{3})(\\d{5})","$1-$2-$3",["8"],"0$1"],["(\\d)(\\d{3})(\\d{3})(\\d{4})","$2 15-$3-$4",["9"],"0$1",0,"$1 $2 $3-$4"]],"0",0,"0?(?:(11|2(?:2(?:02?|[13]|2[13-79]|4[1-6]|5[2457]|6[124-8]|7[1-4]|8[13-6]|9[1267])|3(?:02?|1[467]|2[03-6]|3[13-8]|[49][2-6]|5[2-8]|[67])|4(?:7[3-578]|9)|6(?:[0136]|2[24-6]|4[6-8]?|5[15-8])|80|9(?:0[1-3]|[19]|2\\d|3[1-6]|4[02568]?|5[2-4]|6[2-46]|72?|8[23]?))|3(?:3(?:2[79]|6|8[2578])|4(?:0[0-24-9]|[12]|3[5-8]?|4[24-7]|5[4-68]?|6[02-9]|7[126]|8[2379]?|9[1-36-8])|5(?:1|2[1245]|3[237]?|4[1-46-9]|6[2-4]|7[1-6]|8[2-5]?)|6[24]|7(?:[069]|1[1568]|2[15]|3[145]|4[13]|5[14-8]|7[2-57]|8[126])|8(?:[01]|2[15-7]|3[2578]?|4[13-6]|5[4-8]?|6[1-357-9]|7[36-8]?|8[5-8]?|9[124])))15)?","9$1"],"AS":["1","011","(?:[58]\\d\\d|684|900)\\d{7}",[10],0,"1",0,"1|([267]\\d{6})$","684$1",0,"684"],"AT":["43","00","1\\d{3,12}|2\\d{6,12}|43(?:(?:0\\d|5[02-9])\\d{3,9}|2\\d{4,5}|[3467]\\d{4}|8\\d{4,6}|9\\d{4,7})|5\\d{4,12}|8\\d{7,12}|9\\d{8,12}|(?:[367]\\d|4[0-24-9])\\d{4,11}",[4,5,6,7,8,9,10,11,12,13],[["(\\d)(\\d{3,12})","$1 $2",["1(?:11|[2-9])"],"0$1"],["(\\d{3})(\\d{2})","$1 $2",["517"],"0$1"],["(\\d{2})(\\d{3,5})","$1 $2",["5[079]"],"0$1"],["(\\d{3})(\\d{3,10})","$1 $2",["(?:31|4)6|51|6(?:5[0-3579]|[6-9])|7(?:20|32|8)|[89]"],"0$1"],["(\\d{4})(\\d{3,9})","$1 $2",["[2-467]|5[2-6]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["5"],"0$1"],["(\\d{2})(\\d{4})(\\d{4,7})","$1 $2 $3",["5"],"0$1"]],"0"],"AU":["61","001[14-689]|14(?:1[14]|34|4[17]|[56]6|7[47]|88)0011","1(?:[0-79]\\d{7}(?:\\d(?:\\d{2})?)?|8[0-24-9]\\d{7})|[2-478]\\d{8}|1\\d{4,7}",[5,6,7,8,9,10,12],[["(\\d{2})(\\d{3,4})","$1 $2",["16"],"0$1"],["(\\d{2})(\\d{3})(\\d{2,4})","$1 $2 $3",["16"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["14|4"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["[2378]"],"(0$1)"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1(?:30|[89])"]]],"0",0,"0|(183[12])",0,0,0,[["(?:(?:2(?:[0-26-9]\\d|3[0-8]|4[02-9]|5[0135-9])|3(?:[0-3589]\\d|4[0-578]|6[1-9]|7[0-35-9])|7(?:[013-57-9]\\d|2[0-8]))\\d{3}|8(?:51(?:0(?:0[03-9]|[12479]\\d|3[2-9]|5[0-8]|6[1-9]|8[0-7])|1(?:[0235689]\\d|1[0-69]|4[0-589]|7[0-47-9])|2(?:0[0-79]|[18][13579]|2[14-9]|3[0-46-9]|[4-6]\\d|7[89]|9[0-4]))|(?:6[0-8]|[78]\\d)\\d{3}|9(?:[02-9]\\d{3}|1(?:(?:[0-58]\\d|6[0135-9])\\d|7(?:0[0-24-9]|[1-9]\\d)|9(?:[0-46-9]\\d|5[0-79])))))\\d{3}",[9]],["4(?:83[0-38]|93[0-6])\\d{5}|4(?:[0-3]\\d|4[047-9]|5[0-25-9]|6[06-9]|7[02-9]|8[0-24-9]|9[0-27-9])\\d{6}",[9]],["180(?:0\\d{3}|2)\\d{3}",[7,10]],["190[0-26]\\d{6}",[10]],0,0,0,["163\\d{2,6}",[5,6,7,8,9]],["14(?:5(?:1[0458]|[23][458])|71\\d)\\d{4}",[9]],["13(?:00\\d{6}(?:\\d{2})?|45[0-4]\\d{3})|13\\d{4}",[6,8,10,12]]],"0011"],"AW":["297","00","(?:[25-79]\\d\\d|800)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[25-9]"]]]],"AX":["358","00|99(?:[01469]|5(?:[14]1|3[23]|5[59]|77|88|9[09]))","2\\d{4,9}|35\\d{4,5}|(?:60\\d\\d|800)\\d{4,6}|7\\d{5,11}|(?:[14]\\d|3[0-46-9]|50)\\d{4,8}",[5,6,7,8,9,10,11,12],0,"0",0,0,0,0,"18",0,"00"],"AZ":["994","00","365\\d{6}|(?:[124579]\\d|60|88)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["90"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1[28]|2|365|46","1[28]|2|365[45]|46","1[28]|2|365(?:4|5[02])|46"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[13-9]"],"0$1"]],"0"],"BA":["387","00","6\\d{8}|(?:[35689]\\d|49|70)\\d{6}",[8,9],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["6[1-3]|[7-9]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2-$3",["[3-5]|6[56]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3 $4",["6"],"0$1"]],"0"],"BB":["1","011","(?:246|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"1|([2-9]\\d{6})$","246$1",0,"246"],"BD":["880","00","[1-469]\\d{9}|8[0-79]\\d{7,8}|[2-79]\\d{8}|[2-9]\\d{7}|[3-9]\\d{6}|[57-9]\\d{5}",[6,7,8,9,10],[["(\\d{2})(\\d{4,6})","$1-$2",["31[5-8]|[459]1"],"0$1"],["(\\d{3})(\\d{3,7})","$1-$2",["3(?:[67]|8[013-9])|4(?:6[168]|7|[89][18])|5(?:6[128]|9)|6(?:28|4[14]|5)|7[2-589]|8(?:0[014-9]|[12])|9[358]|(?:3[2-5]|4[235]|5[2-578]|6[0389]|76|8[3-7]|9[24])1|(?:44|66)[01346-9]"],"0$1"],["(\\d{4})(\\d{3,6})","$1-$2",["[13-9]|22"],"0$1"],["(\\d)(\\d{7,8})","$1-$2",["2"],"0$1"]],"0"],"BE":["32","00","4\\d{8}|[1-9]\\d{7}",[8,9],[["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["(?:80|9)0"],"0$1"],["(\\d)(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[239]|4[23]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[15-8]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["4"],"0$1"]],"0"],"BF":["226","00","[025-7]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[025-7]"]]]],"BG":["359","00","[2-7]\\d{6,7}|[89]\\d{6,8}|2\\d{5}",[6,7,8,9],[["(\\d)(\\d)(\\d{2})(\\d{2})","$1 $2 $3 $4",["2"],"0$1"],["(\\d{3})(\\d{4})","$1 $2",["43[1-6]|70[1-9]"],"0$1"],["(\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{2,3})","$1 $2 $3",["[356]|4[124-7]|7[1-9]|8[1-6]|9[1-7]"],"0$1"],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["(?:70|8)0"],"0$1"],["(\\d{3})(\\d{3})(\\d{2})","$1 $2 $3",["43[1-7]|7"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[48]|9[08]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["9"],"0$1"]],"0"],"BH":["973","00","[136-9]\\d{7}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[13679]|8[047]"]]]],"BI":["257","00","(?:[267]\\d|31)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2367]"]]]],"BJ":["229","00","[25689]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[25689]"]]]],"BL":["590","00","(?:590|(?:69|80)\\d|976)\\d{6}",[9],0,"0",0,0,0,0,0,[["590(?:2[7-9]|5[12]|87)\\d{4}"],["69(?:0\\d\\d|1(?:2[2-9]|3[0-5]))\\d{4}"],["80[0-5]\\d{6}"],0,0,0,0,0,["976[01]\\d{5}"]]],"BM":["1","011","(?:441|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"1|([2-8]\\d{6})$","441$1",0,"441"],"BN":["673","00","[2-578]\\d{6}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-578]"]]]],"BO":["591","00(?:1\\d)?","(?:[2-467]\\d\\d|8001)\\d{5}",[8,9],[["(\\d)(\\d{7})","$1 $2",["[23]|4[46]"]],["(\\d{8})","$1",["[67]"]],["(\\d{3})(\\d{2})(\\d{4})","$1 $2 $3",["8"]]],"0",0,"0(1\\d)?"],"BQ":["599","00","(?:[34]1|7\\d)\\d{5}",[7],0,0,0,0,0,0,"[347]"],"BR":["55","00(?:1[245]|2[1-35]|31|4[13]|[56]5|99)","(?:[1-46-9]\\d\\d|5(?:[0-46-9]\\d|5[0-24679]))\\d{8}|[1-9]\\d{9}|[3589]\\d{8}|[34]\\d{7}",[8,9,10,11],[["(\\d{4})(\\d{4})","$1-$2",["300|4(?:0[02]|37)","4(?:02|37)0|[34]00"]],["(\\d{3})(\\d{2,3})(\\d{4})","$1 $2 $3",["(?:[358]|90)0"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1 $2-$3",["(?:[14689][1-9]|2[12478]|3[1-578]|5[13-5]|7[13-579])[2-57]"],"($1)"],["(\\d{2})(\\d{5})(\\d{4})","$1 $2-$3",["[16][1-9]|[2-57-9]"],"($1)"]],"0",0,"(?:0|90)(?:(1[245]|2[1-35]|31|4[13]|[56]5|99)(\\d{10,11}))?","$2"],"BS":["1","011","(?:242|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"1|([3-8]\\d{6})$","242$1",0,"242"],"BT":["975","00","[17]\\d{7}|[2-8]\\d{6}",[7,8],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[2-68]|7[246]"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1[67]|7"]]]],"BW":["267","00","(?:0800|(?:[37]|800)\\d)\\d{6}|(?:[2-6]\\d|90)\\d{5}",[7,8,10],[["(\\d{2})(\\d{5})","$1 $2",["90"]],["(\\d{3})(\\d{4})","$1 $2",["[24-6]|3[15-79]"]],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[37]"]],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["0"]],["(\\d{3})(\\d{4})(\\d{3})","$1 $2 $3",["8"]]]],"BY":["375","810","(?:[12]\\d|33|44|902)\\d{7}|8(?:0[0-79]\\d{5,7}|[1-7]\\d{9})|8(?:1[0-489]|[5-79]\\d)\\d{7}|8[1-79]\\d{6,7}|8[0-79]\\d{5}|8\\d{5}",[6,7,8,9,10,11],[["(\\d{3})(\\d{3})","$1 $2",["800"],"8 $1"],["(\\d{3})(\\d{2})(\\d{2,4})","$1 $2 $3",["800"],"8 $1"],["(\\d{4})(\\d{2})(\\d{3})","$1 $2-$3",["1(?:5[169]|6[3-5]|7[179])|2(?:1[35]|2[34]|3[3-5])","1(?:5[169]|6(?:3[1-3]|4|5[125])|7(?:1[3-9]|7[0-24-6]|9[2-7]))|2(?:1[35]|2[34]|3[3-5])"],"8 0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2-$3-$4",["1(?:[56]|7[467])|2[1-3]"],"8 0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2-$3-$4",["[1-4]"],"8 0$1"],["(\\d{3})(\\d{3,4})(\\d{4})","$1 $2 $3",["[89]"],"8 $1"]],"8",0,"0|80?",0,0,0,0,"8~10"],"BZ":["501","00","(?:0800\\d|[2-8])\\d{6}",[7,11],[["(\\d{3})(\\d{4})","$1-$2",["[2-8]"]],["(\\d)(\\d{3})(\\d{4})(\\d{3})","$1-$2-$3-$4",["0"]]]],"CA":["1","011","(?:[2-8]\\d|90)\\d{8}",[10],0,"1",0,0,0,0,0,[["(?:2(?:04|[23]6|[48]9|50)|3(?:06|43|6[578])|4(?:03|1[68]|3[178]|50|74)|5(?:06|1[49]|48|79|8[17])|6(?:04|13|39|47|72)|7(?:0[59]|78|8[02])|8(?:[06]7|19|25|73)|90[25])[2-9]\\d{6}"],[""],["8(?:00|33|44|55|66|77|88)[2-9]\\d{6}"],["900[2-9]\\d{6}"],["52(?:3(?:[2-46-9][02-9]\\d|5(?:[02-46-9]\\d|5[0-46-9]))|4(?:[2-478][02-9]\\d|5(?:[034]\\d|2[024-9]|5[0-46-9])|6(?:0[1-9]|[2-9]\\d)|9(?:[05-9]\\d|2[0-5]|49)))\\d{4}|52[34][2-9]1[02-9]\\d{4}|(?:5(?:00|2[12]|33|44|66|77|88)|622)[2-9]\\d{6}"],0,0,0,["600[2-9]\\d{6}"]]],"CC":["61","001[14-689]|14(?:1[14]|34|4[17]|[56]6|7[47]|88)0011","1(?:[0-79]\\d{8}(?:\\d{2})?|8[0-24-9]\\d{7})|[148]\\d{8}|1\\d{5,7}",[6,7,8,9,10,12],0,"0",0,"0|([59]\\d{7})$","8$1",0,0,[["8(?:51(?:0(?:02|31|60|89)|1(?:18|76)|223)|91(?:0(?:1[0-2]|29)|1(?:[28]2|50|79)|2(?:10|64)|3(?:[06]8|22)|4[29]8|62\\d|70[23]|959))\\d{3}",[9]],["4(?:83[0-38]|93[0-6])\\d{5}|4(?:[0-3]\\d|4[047-9]|5[0-25-9]|6[06-9]|7[02-9]|8[0-24-9]|9[0-27-9])\\d{6}",[9]],["180(?:0\\d{3}|2)\\d{3}",[7,10]],["190[0-26]\\d{6}",[10]],0,0,0,0,["14(?:5(?:1[0458]|[23][458])|71\\d)\\d{4}",[9]],["13(?:00\\d{6}(?:\\d{2})?|45[0-4]\\d{3})|13\\d{4}",[6,8,10,12]]],"0011"],"CD":["243","00","[189]\\d{8}|[1-68]\\d{6}",[7,9],[["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["88"],"0$1"],["(\\d{2})(\\d{5})","$1 $2",["[1-6]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[89]"],"0$1"]],"0"],"CF":["236","00","(?:[27]\\d{3}|8776)\\d{4}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[278]"]]]],"CG":["242","00","(?:0\\d\\d|222|800)\\d{6}",[9],[["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["8"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[02]"]]]],"CH":["41","00","8\\d{11}|[2-9]\\d{8}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8[047]|90"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-79]|81"],"0$1"],["(\\d{3})(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["8"],"0$1"]],"0"],"CI":["225","00","[02]\\d{9}",[10],[["(\\d{2})(\\d{2})(\\d)(\\d{5})","$1 $2 $3 $4",["2"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3 $4",["0"]]]],"CK":["682","00","[2-578]\\d{4}",[5],[["(\\d{2})(\\d{3})","$1 $2",["[2-578]"]]]],"CL":["56","(?:0|1(?:1[0-69]|2[02-5]|5[13-58]|69|7[0167]|8[018]))0","12300\\d{6}|6\\d{9,10}|[2-9]\\d{8}",[9,10,11],[["(\\d{5})(\\d{4})","$1 $2",["219","2196"],"($1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["44"]],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["2[1-3]"],"($1)"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["9[2-9]"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["3[2-5]|[47]|5[1-3578]|6[13-57]|8(?:0[1-9]|[1-9])"],"($1)"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["60|8"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]],["(\\d{3})(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3 $4",["60"]]]],"CM":["237","00","[26]\\d{8}|88\\d{6,7}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["88"]],["(\\d)(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["[26]|88"]]]],"CN":["86","00|1(?:[12]\\d|79)\\d\\d00","1[127]\\d{8,9}|2\\d{9}(?:\\d{2})?|[12]\\d{6,7}|86\\d{6}|(?:1[03-689]\\d|6)\\d{7,9}|(?:[3-579]\\d|8[0-57-9])\\d{6,9}",[7,8,9,10,11,12],[["(\\d{2})(\\d{5,6})","$1 $2",["(?:10|2[0-57-9])[19]","(?:10|2[0-57-9])(?:10|9[56])","(?:10|2[0-57-9])(?:100|9[56])"],"0$1"],["(\\d{3})(\\d{5,6})","$1 $2",["3(?:[157]|35|49|9[1-68])|4(?:[17]|2[179]|6[47-9]|8[23])|5(?:[1357]|2[37]|4[36]|6[1-46]|80)|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]|4[13]|5[1-5])|(?:4[35]|59|85)[1-9]","(?:3(?:[157]\\d|35|49|9[1-68])|4(?:[17]\\d|2[179]|[35][1-9]|6[47-9]|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]\\d|4[13]|5[1-5]))[19]","85[23](?:10|95)|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:[17]\\d|2[179]|[35][1-9]|6[47-9]|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[14-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]\\d|4[13]|5[1-5]))(?:10|9[56])","85[23](?:100|95)|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:[17]\\d|2[179]|[35][1-9]|6[47-9]|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[14-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]\\d|4[13]|5[1-5]))(?:100|9[56])"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["(?:4|80)0"]],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["10|2(?:[02-57-9]|1[1-9])","10|2(?:[02-57-9]|1[1-9])","10[0-79]|2(?:[02-57-9]|1[1-79])|(?:10|21)8(?:0[1-9]|[1-9])"],"0$1",1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["3(?:[3-59]|7[02-68])|4(?:[26-8]|3[3-9]|5[2-9])|5(?:3[03-9]|[468]|7[028]|9[2-46-9])|6|7(?:[0-247]|3[04-9]|5[0-4689]|6[2368])|8(?:[1-358]|9[1-7])|9(?:[013479]|5[1-5])|(?:[34]1|55|79|87)[02-9]"],"0$1",1],["(\\d{3})(\\d{7,8})","$1 $2",["9"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["80"],"0$1",1],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["[3-578]"],"0$1",1],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["1[3-9]"]],["(\\d{2})(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3 $4",["[12]"],"0$1",1]],"0",0,"0|(1(?:[12]\\d|79)\\d\\d)",0,0,0,0,"00"],"CO":["57","00(?:4(?:[14]4|56)|[579])","(?:(?:1\\d|[36])\\d{3}|9101)\\d{6}|[124-8]\\d{7}",[8,10,11],[["(\\d)(\\d{7})","$1 $2",["[146][2-9]|[2578]"],"($1)"],["(\\d{3})(\\d{7})","$1 $2",["6"],"($1)"],["(\\d{3})(\\d{7})","$1 $2",["[39]"]],["(\\d)(\\d{3})(\\d{7})","$1-$2-$3",["1"],"0$1",0,"$1 $2 $3"]],"0",0,"0([3579]|4(?:[14]4|56))?"],"CR":["506","00","(?:8\\d|90)\\d{8}|(?:[24-8]\\d{3}|3005)\\d{4}",[8,10],[["(\\d{4})(\\d{4})","$1 $2",["[2-7]|8[3-9]"]],["(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["[89]"]]],0,0,"(19(?:0[0-2468]|1[09]|20|66|77|99))"],"CU":["53","119","[27]\\d{6,7}|[34]\\d{5,7}|(?:5|8\\d\\d)\\d{7}",[6,7,8,10],[["(\\d{2})(\\d{4,6})","$1 $2",["2[1-4]|[34]"],"(0$1)"],["(\\d)(\\d{6,7})","$1 $2",["7"],"(0$1)"],["(\\d)(\\d{7})","$1 $2",["5"],"0$1"],["(\\d{3})(\\d{7})","$1 $2",["8"],"0$1"]],"0"],"CV":["238","0","(?:[2-59]\\d\\d|800)\\d{4}",[7],[["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",["[2-589]"]]]],"CW":["599","00","(?:[34]1|60|(?:7|9\\d)\\d)\\d{5}",[7,8],[["(\\d{3})(\\d{4})","$1 $2",["[3467]"]],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["9[4-8]"]]],0,0,0,0,0,"[69]"],"CX":["61","001[14-689]|14(?:1[14]|34|4[17]|[56]6|7[47]|88)0011","1(?:[0-79]\\d{8}(?:\\d{2})?|8[0-24-9]\\d{7})|[148]\\d{8}|1\\d{5,7}",[6,7,8,9,10,12],0,"0",0,"0|([59]\\d{7})$","8$1",0,0,[["8(?:51(?:0(?:01|30|59|88)|1(?:17|46|75)|2(?:22|35))|91(?:00[6-9]|1(?:[28]1|49|78)|2(?:09|63)|3(?:12|26|75)|4(?:56|97)|64\\d|7(?:0[01]|1[0-2])|958))\\d{3}",[9]],["4(?:83[0-38]|93[0-6])\\d{5}|4(?:[0-3]\\d|4[047-9]|5[0-25-9]|6[06-9]|7[02-9]|8[0-24-9]|9[0-27-9])\\d{6}",[9]],["180(?:0\\d{3}|2)\\d{3}",[7,10]],["190[0-26]\\d{6}",[10]],0,0,0,0,["14(?:5(?:1[0458]|[23][458])|71\\d)\\d{4}",[9]],["13(?:00\\d{6}(?:\\d{2})?|45[0-4]\\d{3})|13\\d{4}",[6,8,10,12]]],"0011"],"CY":["357","00","(?:[279]\\d|[58]0)\\d{6}",[8],[["(\\d{2})(\\d{6})","$1 $2",["[257-9]"]]]],"CZ":["420","00","(?:[2-578]\\d|60)\\d{7}|9\\d{8,11}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[2-8]|9[015-7]"]],["(\\d{2})(\\d{3})(\\d{3})(\\d{2})","$1 $2 $3 $4",["96"]],["(\\d{2})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["9"]],["(\\d{3})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["9"]]]],"DE":["49","00","[2579]\\d{5,14}|49(?:[34]0|69|8\\d)\\d\\d?|49(?:37|49|60|7[089]|9\\d)\\d{1,3}|49(?:1\\d|2[02-9]|3[2-689]|7[1-7])\\d{1,8}|(?:1|[368]\\d|4[0-8])\\d{3,13}|49(?:[05]\\d|[23]1|[46][1-8])\\d{1,9}",[4,5,6,7,8,9,10,11,12,13,14,15],[["(\\d{2})(\\d{3,13})","$1 $2",["3[02]|40|[68]9"],"0$1"],["(\\d{3})(\\d{3,12})","$1 $2",["2(?:0[1-389]|1[124]|2[18]|3[14])|3(?:[35-9][15]|4[015])|906|(?:2[4-9]|4[2-9]|[579][1-9]|[68][1-8])1","2(?:0[1-389]|12[0-8])|3(?:[35-9][15]|4[015])|906|2(?:[13][14]|2[18])|(?:2[4-9]|4[2-9]|[579][1-9]|[68][1-8])1"],"0$1"],["(\\d{4})(\\d{2,11})","$1 $2",["[24-6]|3(?:[3569][02-46-9]|4[2-4679]|7[2-467]|8[2-46-8])|70[2-8]|8(?:0[2-9]|[1-8])|90[7-9]|[79][1-9]","[24-6]|3(?:3(?:0[1-467]|2[127-9]|3[124578]|7[1257-9]|8[1256]|9[145])|4(?:2[135]|4[13578]|9[1346])|5(?:0[14]|2[1-3589]|6[1-4]|7[13468]|8[13568])|6(?:2[1-489]|3[124-6]|6[13]|7[12579]|8[1-356]|9[135])|7(?:2[1-7]|4[145]|6[1-5]|7[1-4])|8(?:21|3[1468]|6|7[1467]|8[136])|9(?:0[12479]|2[1358]|4[134679]|6[1-9]|7[136]|8[147]|9[1468]))|70[2-8]|8(?:0[2-9]|[1-8])|90[7-9]|[79][1-9]|3[68]4[1347]|3(?:47|60)[1356]|3(?:3[46]|46|5[49])[1246]|3[4579]3[1357]"],"0$1"],["(\\d{3})(\\d{4})","$1 $2",["138"],"0$1"],["(\\d{5})(\\d{2,10})","$1 $2",["3"],"0$1"],["(\\d{3})(\\d{5,11})","$1 $2",["181"],"0$1"],["(\\d{3})(\\d)(\\d{4,10})","$1 $2 $3",["1(?:3|80)|9"],"0$1"],["(\\d{3})(\\d{7,8})","$1 $2",["1[67]"],"0$1"],["(\\d{3})(\\d{7,12})","$1 $2",["8"],"0$1"],["(\\d{5})(\\d{6})","$1 $2",["185","1850","18500"],"0$1"],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["7"],"0$1"],["(\\d{4})(\\d{7})","$1 $2",["18[68]"],"0$1"],["(\\d{5})(\\d{6})","$1 $2",["15[0568]"],"0$1"],["(\\d{4})(\\d{7})","$1 $2",["15[1279]"],"0$1"],["(\\d{3})(\\d{8})","$1 $2",["18"],"0$1"],["(\\d{3})(\\d{2})(\\d{7,8})","$1 $2 $3",["1(?:6[023]|7)"],"0$1"],["(\\d{4})(\\d{2})(\\d{7})","$1 $2 $3",["15[279]"],"0$1"],["(\\d{3})(\\d{2})(\\d{8})","$1 $2 $3",["15"],"0$1"]],"0"],"DJ":["253","00","(?:2\\d|77)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[27]"]]]],"DK":["45","00","[2-9]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-9]"]]]],"DM":["1","011","(?:[58]\\d\\d|767|900)\\d{7}",[10],0,"1",0,"1|([2-7]\\d{6})$","767$1",0,"767"],"DO":["1","011","(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,0,0,0,"8001|8[024]9"],"DZ":["213","00","(?:[1-4]|[5-79]\\d|80)\\d{7}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[1-4]"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["9"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-8]"],"0$1"]],"0"],"EC":["593","00","1\\d{9,10}|(?:[2-7]|9\\d)\\d{7}",[8,9,10,11],[["(\\d)(\\d{3})(\\d{4})","$1 $2-$3",["[2-7]"],"(0$1)",0,"$1-$2-$3"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["9"],"0$1"],["(\\d{4})(\\d{3})(\\d{3,4})","$1 $2 $3",["1"]]],"0"],"EE":["372","00","8\\d{9}|[4578]\\d{7}|(?:[3-8]\\d|90)\\d{5}",[7,8,10],[["(\\d{3})(\\d{4})","$1 $2",["[369]|4[3-8]|5(?:[0-2]|5[0-478]|6[45])|7[1-9]|88","[369]|4[3-8]|5(?:[02]|1(?:[0-8]|95)|5[0-478]|6(?:4[0-4]|5[1-589]))|7[1-9]|88"]],["(\\d{4})(\\d{3,4})","$1 $2",["[45]|8(?:00|[1-49])","[45]|8(?:00[1-9]|[1-49])"]],["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["7"]],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["8"]]]],"EG":["20","00","[189]\\d{8,9}|[24-6]\\d{8}|[135]\\d{7}",[8,9,10],[["(\\d)(\\d{7,8})","$1 $2",["[23]"],"0$1"],["(\\d{2})(\\d{6,7})","$1 $2",["1[35]|[4-6]|8[2468]|9[235-7]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[189]"],"0$1"]],"0"],"EH":["212","00","[5-8]\\d{8}",[9],0,"0",0,0,0,0,"528[89]"],"ER":["291","00","[178]\\d{6}",[7],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[178]"],"0$1"]],"0"],"ES":["34","00","[5-9]\\d{8}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[89]00"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-9]"]]]],"ET":["251","00","(?:11|[2-59]\\d)\\d{7}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[1-59]"],"0$1"]],"0"],"FI":["358","00|99(?:[01469]|5(?:[14]1|3[23]|5[59]|77|88|9[09]))","[1-35689]\\d{4}|7\\d{10,11}|(?:[124-7]\\d|3[0-46-9])\\d{8}|[1-9]\\d{5,8}",[5,6,7,8,9,10,11,12],[["(\\d)(\\d{4,9})","$1 $2",["[2568][1-8]|3(?:0[1-9]|[1-9])|9"],"0$1"],["(\\d{3})(\\d{3,7})","$1 $2",["[12]00|[368]|70[07-9]"],"0$1"],["(\\d{2})(\\d{4,8})","$1 $2",["[1245]|7[135]"],"0$1"],["(\\d{2})(\\d{6,10})","$1 $2",["7"],"0$1"]],"0",0,0,0,0,"1[03-79]|[2-9]",0,"00"],"FJ":["679","0(?:0|52)","45\\d{5}|(?:0800\\d|[235-9])\\d{6}",[7,11],[["(\\d{3})(\\d{4})","$1 $2",["[235-9]|45"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["0"]]],0,0,0,0,0,0,0,"00"],"FK":["500","00","[2-7]\\d{4}",[5]],"FM":["691","00","(?:[39]\\d\\d|820)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[389]"]]]],"FO":["298","00","[2-9]\\d{5}",[6],[["(\\d{6})","$1",["[2-9]"]]],0,0,"(10(?:01|[12]0|88))"],"FR":["33","00","[1-9]\\d{8}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0 $1"],["(\\d)(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["[1-79]"],"0$1"]],"0"],"GA":["241","00","(?:[067]\\d|11)\\d{6}|[2-7]\\d{6}",[7,8],[["(\\d)(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-7]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["11|[67]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["0"]]],0,0,"0(11\\d{6}|60\\d{6}|61\\d{6}|6[256]\\d{6}|7[47]\\d{6}|76\\d{6})","$1"],"GB":["44","00","[1-357-9]\\d{9}|[18]\\d{8}|8\\d{6}",[7,9,10],[["(\\d{3})(\\d{4})","$1 $2",["800","8001","80011","800111","8001111"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",["845","8454","84546","845464"],"0$1"],["(\\d{3})(\\d{6})","$1 $2",["800"],"0$1"],["(\\d{5})(\\d{4,5})","$1 $2",["1(?:38|5[23]|69|76|94)","1(?:(?:38|69)7|5(?:24|39)|768|946)","1(?:3873|5(?:242|39[4-6])|(?:697|768)[347]|9467)"],"0$1"],["(\\d{4})(\\d{5,6})","$1 $2",["1(?:[2-69][02-9]|[78])"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["[25]|7(?:0|6[02-9])","[25]|7(?:0|6(?:[03-9]|2[356]))"],"0$1"],["(\\d{4})(\\d{6})","$1 $2",["7"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[1389]"],"0$1"]],"0",0,0,0,0,0,[["(?:1(?:1(?:3(?:[0-58]\\d\\d|73[0235])|4(?:[0-5]\\d\\d|69[7-9]|70[0359])|(?:5[0-26-9]|[78][0-49])\\d\\d|6(?:[0-4]\\d\\d|50[0-24-69]))|2(?:(?:0[024-9]|2[3-9]|3[3-79]|4[1-689]|[58][02-9]|6[0-47-9]|7[013-9]|9\\d)\\d\\d|1(?:[0-7]\\d\\d|8(?:[02]\\d|1[0-278])))|(?:3(?:0\\d|1[0-8]|[25][02-9]|3[02-579]|[468][0-46-9]|7[1-35-79]|9[2-578])|4(?:0[03-9]|[137]\\d|[28][02-57-9]|4[02-69]|5[0-8]|[69][0-79])|5(?:0[1-35-9]|[16]\\d|2[024-9]|3[015689]|4[02-9]|5[03-9]|7[0-35-9]|8[0-468]|9[0-57-9])|6(?:0[034689]|1\\d|2[0-35689]|[38][013-9]|4[1-467]|5[0-69]|6[13-9]|7[0-8]|9[0-24578])|7(?:0[0246-9]|2\\d|3[0236-8]|4[03-9]|5[0-46-9]|6[013-9]|7[0-35-9]|8[024-9]|9[02-9])|8(?:0[35-9]|2[1-57-9]|3[02-578]|4[0-578]|5[124-9]|6[2-69]|7\\d|8[02-9]|9[02569])|9(?:0[02-589]|[18]\\d|2[02-689]|3[1-57-9]|4[2-9]|5[0-579]|6[2-47-9]|7[0-24578]|9[2-57]))\\d\\d)|2(?:0[013478]|3[0189]|4[017]|8[0-46-9]|9[0-2])\\d{3})\\d{4}|1(?:2(?:0(?:46[1-4]|87[2-9])|545[1-79]|76(?:2\\d|3[1-8]|6[1-6])|9(?:7(?:2[0-4]|3[2-5])|8(?:2[2-8]|7[0-47-9]|8[3-5])))|3(?:6(?:38[2-5]|47[23])|8(?:47[04-9]|64[0157-9]))|4(?:044[1-7]|20(?:2[23]|8\\d)|6(?:0(?:30|5[2-57]|6[1-8]|7[2-8])|140)|8(?:052|87[1-3]))|5(?:2(?:4(?:3[2-79]|6\\d)|76\\d)|6(?:26[06-9]|686))|6(?:06(?:4\\d|7[4-79])|295[5-7]|35[34]\\d|47(?:24|61)|59(?:5[08]|6[67]|74)|9(?:55[0-4]|77[23]))|7(?:26(?:6[13-9]|7[0-7])|(?:442|688)\\d|50(?:2[0-3]|[3-68]2|76))|8(?:27[56]\\d|37(?:5[2-5]|8[239])|843[2-58])|9(?:0(?:0(?:6[1-8]|85)|52\\d)|3583|4(?:66[1-8]|9(?:2[01]|81))|63(?:23|3[1-4])|9561))\\d{3}",[9,10]],["7(?:457[0-57-9]|700[01]|911[028])\\d{5}|7(?:[1-3]\\d\\d|4(?:[0-46-9]\\d|5[0-689])|5(?:0[0-8]|[13-9]\\d|2[0-35-9])|7(?:0[1-9]|[1-7]\\d|8[02-9]|9[0-689])|8(?:[014-9]\\d|[23][0-8])|9(?:[024-9]\\d|1[02-9]|3[0-689]))\\d{6}",[10]],["80[08]\\d{7}|800\\d{6}|8001111"],["(?:8(?:4[2-5]|7[0-3])|9(?:[01]\\d|8[2-49]))\\d{7}|845464\\d",[7,10]],["70\\d{8}",[10]],0,["(?:3[0347]|55)\\d{8}",[10]],["76(?:464|652)\\d{5}|76(?:0[0-2]|2[356]|34|4[01347]|5[49]|6[0-369]|77|81|9[139])\\d{6}",[10]],["56\\d{8}",[10]]],0," x"],"GD":["1","011","(?:473|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"1|([2-9]\\d{6})$","473$1",0,"473"],"GE":["995","00","(?:[3-57]\\d\\d|800)\\d{6}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["70"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["32"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[57]"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[348]"],"0$1"]],"0"],"GF":["594","00","(?:[56]94|80\\d|976)\\d{6}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[569]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0$1"]],"0"],"GG":["44","00","(?:1481|[357-9]\\d{3})\\d{6}|8\\d{6}(?:\\d{2})?",[7,9,10],0,"0",0,"0|([25-9]\\d{5})$","1481$1",0,0,[["1481[25-9]\\d{5}",[10]],["7(?:(?:781|839)\\d|911[17])\\d{5}",[10]],["80[08]\\d{7}|800\\d{6}|8001111"],["(?:8(?:4[2-5]|7[0-3])|9(?:[01]\\d|8[0-3]))\\d{7}|845464\\d",[7,10]],["70\\d{8}",[10]],0,["(?:3[0347]|55)\\d{8}",[10]],["76(?:464|652)\\d{5}|76(?:0[0-2]|2[356]|34|4[01347]|5[49]|6[0-369]|77|81|9[139])\\d{6}",[10]],["56\\d{8}",[10]]]],"GH":["233","00","(?:[235]\\d{3}|800)\\d{5}",[8,9],[["(\\d{3})(\\d{5})","$1 $2",["8"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[235]"],"0$1"]],"0"],"GI":["350","00","(?:[25]\\d\\d|606)\\d{5}",[8],[["(\\d{3})(\\d{5})","$1 $2",["2"]]]],"GL":["299","00","(?:19|[2-689]\\d|70)\\d{4}",[6],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["19|[2-9]"]]]],"GM":["220","00","[2-9]\\d{6}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-9]"]]]],"GN":["224","00","722\\d{6}|(?:3|6\\d)\\d{7}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["3"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[67]"]]]],"GP":["590","00","(?:590|(?:69|80)\\d|976)\\d{6}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[569]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0$1"]],"0",0,0,0,0,0,[["590(?:0[1-68]|1[0-2]|2[0-68]|3[1289]|4[0-24-9]|5[3-579]|6[0189]|7[08]|8[0-689]|9\\d)\\d{4}"],["69(?:0\\d\\d|1(?:2[2-9]|3[0-5]))\\d{4}"],["80[0-5]\\d{6}"],0,0,0,0,0,["976[01]\\d{5}"]]],"GQ":["240","00","222\\d{6}|(?:3\\d|55|[89]0)\\d{7}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[235]"]],["(\\d{3})(\\d{6})","$1 $2",["[89]"]]]],"GR":["30","00","5005000\\d{3}|8\\d{9,11}|(?:[269]\\d|70)\\d{8}",[10,11,12],[["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["21|7"]],["(\\d{4})(\\d{6})","$1 $2",["2(?:2|3[2-57-9]|4[2-469]|5[2-59]|6[2-9]|7[2-69]|8[2-49])|5"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[2689]"]],["(\\d{3})(\\d{3,4})(\\d{5})","$1 $2 $3",["8"]]]],"GT":["502","00","(?:1\\d{3}|[2-7])\\d{7}",[8,11],[["(\\d{4})(\\d{4})","$1 $2",["[2-7]"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]]]],"GU":["1","011","(?:[58]\\d\\d|671|900)\\d{7}",[10],0,"1",0,"1|([3-9]\\d{6})$","671$1",0,"671"],"GW":["245","00","[49]\\d{8}|4\\d{6}",[7,9],[["(\\d{3})(\\d{4})","$1 $2",["40"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[49]"]]]],"GY":["592","001","(?:862\\d|9008)\\d{3}|(?:[2-46]\\d|77)\\d{5}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-46-9]"]]]],"HK":["852","00(?:30|5[09]|[126-9]?)","8[0-46-9]\\d{6,7}|9\\d{4}(?:\\d(?:\\d(?:\\d{4})?)?)?|(?:[235-79]\\d|46)\\d{6}",[5,6,7,8,9,11],[["(\\d{3})(\\d{2,5})","$1 $2",["900","9003"]],["(\\d{4})(\\d{4})","$1 $2",["[2-7]|8[1-4]|9(?:0[1-9]|[1-8])"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8"]],["(\\d{3})(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3 $4",["9"]]],0,0,0,0,0,0,0,"00"],"HN":["504","00","8\\d{10}|[237-9]\\d{7}",[8,11],[["(\\d{4})(\\d{4})","$1-$2",["[237-9]"]]]],"HR":["385","00","(?:[24-69]\\d|3[0-79])\\d{7}|80\\d{5,7}|[1-79]\\d{7}|6\\d{5,6}",[6,7,8,9],[["(\\d{2})(\\d{2})(\\d{2,3})","$1 $2 $3",["6[01]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2,3})","$1 $2 $3",["8"],"0$1"],["(\\d)(\\d{4})(\\d{3})","$1 $2 $3",["1"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[67]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["9"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-5]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8"],"0$1"]],"0"],"HT":["509","00","[2-489]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["[2-489]"]]]],"HU":["36","00","[235-7]\\d{8}|[1-9]\\d{7}",[8,9],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["1"],"(06 $1)"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[27][2-9]|3[2-7]|4[24-9]|5[2-79]|6|8[2-57-9]|9[2-69]"],"(06 $1)"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-9]"],"06 $1"]],"06"],"ID":["62","00[89]","(?:(?:00[1-9]|8\\d)\\d{4}|[1-36])\\d{6}|00\\d{10}|[1-9]\\d{8,10}|[2-9]\\d{7}",[7,8,9,10,11,12,13],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["15"]],["(\\d{2})(\\d{5,9})","$1 $2",["2[124]|[36]1"],"(0$1)"],["(\\d{3})(\\d{5,7})","$1 $2",["800"],"0$1"],["(\\d{3})(\\d{5,8})","$1 $2",["[2-79]"],"(0$1)"],["(\\d{3})(\\d{3,4})(\\d{3})","$1-$2-$3",["8[1-35-9]"],"0$1"],["(\\d{3})(\\d{6,8})","$1 $2",["1"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["804"],"0$1"],["(\\d{3})(\\d)(\\d{3})(\\d{3})","$1 $2 $3 $4",["80"],"0$1"],["(\\d{3})(\\d{4})(\\d{4,5})","$1-$2-$3",["8"],"0$1"]],"0"],"IE":["353","00","(?:1\\d|[2569])\\d{6,8}|4\\d{6,9}|7\\d{8}|8\\d{8,9}",[7,8,9,10],[["(\\d{2})(\\d{5})","$1 $2",["2[24-9]|47|58|6[237-9]|9[35-9]"],"(0$1)"],["(\\d{3})(\\d{5})","$1 $2",["[45]0"],"(0$1)"],["(\\d)(\\d{3,4})(\\d{4})","$1 $2 $3",["1"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2569]|4[1-69]|7[14]"],"(0$1)"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["70"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["81"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[78]"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1"]],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["4"],"(0$1)"],["(\\d{2})(\\d)(\\d{3})(\\d{4})","$1 $2 $3 $4",["8"],"0$1"]],"0"],"IL":["972","0(?:0|1[2-9])","1\\d{6}(?:\\d{3,5})?|[57]\\d{8}|[1-489]\\d{7}",[7,8,9,10,11,12],[["(\\d{4})(\\d{3})","$1-$2",["125"]],["(\\d{4})(\\d{2})(\\d{2})","$1-$2-$3",["121"]],["(\\d)(\\d{3})(\\d{4})","$1-$2-$3",["[2-489]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["[57]"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1-$2-$3",["12"]],["(\\d{4})(\\d{6})","$1-$2",["159"]],["(\\d)(\\d{3})(\\d{3})(\\d{3})","$1-$2-$3-$4",["1[7-9]"]],["(\\d{3})(\\d{1,2})(\\d{3})(\\d{4})","$1-$2 $3-$4",["15"]]],"0"],"IM":["44","00","1624\\d{6}|(?:[3578]\\d|90)\\d{8}",[10],0,"0",0,"0|([25-8]\\d{5})$","1624$1",0,"74576|(?:16|7[56])24"],"IN":["91","00","(?:000800|[2-9]\\d\\d)\\d{7}|1\\d{7,12}",[8,9,10,11,12,13],[["(\\d{8})","$1",["5(?:0|2[23]|3[03]|[67]1|88)","5(?:0|2(?:21|3)|3(?:0|3[23])|616|717|888)","5(?:0|2(?:21|3)|3(?:0|3[23])|616|717|8888)"],0,1],["(\\d{4})(\\d{4,5})","$1 $2",["180","1800"],0,1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["140"],0,1],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["11|2[02]|33|4[04]|79[1-7]|80[2-46]","11|2[02]|33|4[04]|79(?:[1-6]|7[19])|80(?:[2-4]|6[0-589])","11|2[02]|33|4[04]|79(?:[124-6]|3(?:[02-9]|1[0-24-9])|7(?:1|9[1-6]))|80(?:[2-4]|6[0-589])"],"0$1",1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["1(?:2[0-249]|3[0-25]|4[145]|[68]|7[1257])|2(?:1[257]|3[013]|4[01]|5[0137]|6[0158]|78|8[1568])|3(?:26|4[1-3]|5[34]|6[01489]|7[02-46]|8[159])|4(?:1[36]|2[1-47]|5[12]|6[0-26-9]|7[0-24-9]|8[013-57]|9[014-7])|5(?:1[025]|22|[36][25]|4[28]|5[12]|[78]1)|6(?:12|[2-4]1|5[17]|6[13]|80)|7(?:12|3[134]|4[47]|61|88)|8(?:16|2[014]|3[126]|6[136]|7[078]|8[34]|91)|(?:43|59|75)[15]|(?:1[59]|29|67|72)[14]","1(?:2[0-24]|3[0-25]|4[145]|[59][14]|6[1-9]|7[1257]|8[1-57-9])|2(?:1[257]|3[013]|4[01]|5[0137]|6[058]|78|8[1568]|9[14])|3(?:26|4[1-3]|5[34]|6[01489]|7[02-46]|8[159])|4(?:1[36]|2[1-47]|3[15]|5[12]|6[0-26-9]|7[0-24-9]|8[013-57]|9[014-7])|5(?:1[025]|22|[36][25]|4[28]|[578]1|9[15])|674|7(?:(?:2[14]|3[34]|5[15])[2-6]|61[346]|88[0-8])|8(?:70[2-6]|84[235-7]|91[3-7])|(?:1(?:29|60|8[06])|261|552|6(?:12|[2-47]1|5[17]|6[13]|80)|7(?:12|31|4[47])|8(?:16|2[014]|3[126]|6[136]|7[78]|83))[2-7]","1(?:2[0-24]|3[0-25]|4[145]|[59][14]|6[1-9]|7[1257]|8[1-57-9])|2(?:1[257]|3[013]|4[01]|5[0137]|6[058]|78|8[1568]|9[14])|3(?:26|4[1-3]|5[34]|6[01489]|7[02-46]|8[159])|4(?:1[36]|2[1-47]|3[15]|5[12]|6[0-26-9]|7[0-24-9]|8[013-57]|9[014-7])|5(?:1[025]|22|[36][25]|4[28]|[578]1|9[15])|6(?:12(?:[2-6]|7[0-8])|74[2-7])|7(?:(?:2[14]|5[15])[2-6]|3171|61[346]|88(?:[2-7]|82))|8(?:70[2-6]|84(?:[2356]|7[19])|91(?:[3-6]|7[19]))|73[134][2-6]|(?:74[47]|8(?:16|2[014]|3[126]|6[136]|7[78]|83))(?:[2-6]|7[19])|(?:1(?:29|60|8[06])|261|552|6(?:[2-4]1|5[17]|6[13]|7(?:1|4[0189])|80)|7(?:12|88[01]))[2-7]"],"0$1",1],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1(?:[2-479]|5[0235-9])|[2-5]|6(?:1[1358]|2[2457-9]|3[2-5]|4[235-7]|5[2-689]|6[24578]|7[235689]|8[1-6])|7(?:1[013-9]|28|3[129]|4[1-35689]|5[29]|6[02-5]|70)|807","1(?:[2-479]|5[0235-9])|[2-5]|6(?:1[1358]|2(?:[2457]|84|95)|3(?:[2-4]|55)|4[235-7]|5[2-689]|6[24578]|7[235689]|8[1-6])|7(?:1(?:[013-8]|9[6-9])|28[6-8]|3(?:17|2[0-49]|9[2-57])|4(?:1[2-4]|[29][0-7]|3[0-8]|[56]|8[0-24-7])|5(?:2[1-3]|9[0-6])|6(?:0[5689]|2[5-9]|3[02-8]|4|5[0-367])|70[13-7])|807[19]","1(?:[2-479]|5(?:[0236-9]|5[013-9]))|[2-5]|6(?:2(?:84|95)|355|83)|73179|807(?:1|9[1-3])|(?:1552|6(?:1[1358]|2[2457]|3[2-4]|4[235-7]|5[2-689]|6[24578]|7[235689]|8[124-6])\\d|7(?:1(?:[013-8]\\d|9[6-9])|28[6-8]|3(?:2[0-49]|9[2-57])|4(?:1[2-4]|[29][0-7]|3[0-8]|[56]\\d|8[0-24-7])|5(?:2[1-3]|9[0-6])|6(?:0[5689]|2[5-9]|3[02-8]|4\\d|5[0-367])|70[13-7]))[2-7]"],"0$1",1],["(\\d{5})(\\d{5})","$1 $2",["[6-9]"],"0$1",1],["(\\d{4})(\\d{2,4})(\\d{4})","$1 $2 $3",["1(?:6|8[06])","1(?:6|8[06]0)"],0,1],["(\\d{4})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["18"],0,1]],"0"],"IO":["246","00","3\\d{6}",[7],[["(\\d{3})(\\d{4})","$1 $2",["3"]]]],"IQ":["964","00","(?:1|7\\d\\d)\\d{7}|[2-6]\\d{7,8}",[8,9,10],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-6]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"0$1"]],"0"],"IR":["98","00","[1-9]\\d{9}|(?:[1-8]\\d\\d|9)\\d{3,4}",[4,5,6,7,10],[["(\\d{4,5})","$1",["96"],"0$1"],["(\\d{2})(\\d{4,5})","$1 $2",["(?:1[137]|2[13-68]|3[1458]|4[145]|5[1468]|6[16]|7[1467]|8[13467])[12689]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["9"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["[1-8]"],"0$1"]],"0"],"IS":["354","00|1(?:0(?:01|[12]0)|100)","(?:38\\d|[4-9])\\d{6}",[7,9],[["(\\d{3})(\\d{4})","$1 $2",["[4-9]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["3"]]],0,0,0,0,0,0,0,"00"],"IT":["39","00","0\\d{5,10}|1\\d{8,10}|3(?:[0-8]\\d{7,10}|9\\d{7,8})|55\\d{8}|8\\d{5}(?:\\d{2,4})?",[6,7,8,9,10,11],[["(\\d{2})(\\d{4,6})","$1 $2",["0[26]"]],["(\\d{3})(\\d{3,6})","$1 $2",["0[13-57-9][0159]|8(?:03|4[17]|9[2-5])","0[13-57-9][0159]|8(?:03|4[17]|9(?:2|3[04]|[45][0-4]))"]],["(\\d{4})(\\d{2,6})","$1 $2",["0(?:[13-579][2-46-8]|8[236-8])"]],["(\\d{4})(\\d{4})","$1 $2",["894"]],["(\\d{2})(\\d{3,4})(\\d{4})","$1 $2 $3",["0[26]|5"]],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["1(?:44|[679])|[38]"]],["(\\d{3})(\\d{3,4})(\\d{4})","$1 $2 $3",["0[13-57-9][0159]|14"]],["(\\d{2})(\\d{4})(\\d{5})","$1 $2 $3",["0[26]"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["0"]],["(\\d{3})(\\d{4})(\\d{4,5})","$1 $2 $3",["3"]]],0,0,0,0,0,0,[["0669[0-79]\\d{1,6}|0(?:1(?:[0159]\\d|[27][1-5]|31|4[1-4]|6[1356]|8[2-57])|2\\d\\d|3(?:[0159]\\d|2[1-4]|3[12]|[48][1-6]|6[2-59]|7[1-7])|4(?:[0159]\\d|[23][1-9]|4[245]|6[1-5]|7[1-4]|81)|5(?:[0159]\\d|2[1-5]|3[2-6]|4[1-79]|6[4-6]|7[1-578]|8[3-8])|6(?:[0-57-9]\\d|6[0-8])|7(?:[0159]\\d|2[12]|3[1-7]|4[2-46]|6[13569]|7[13-6]|8[1-59])|8(?:[0159]\\d|2[3-578]|3[1-356]|[6-8][1-5])|9(?:[0159]\\d|[238][1-5]|4[12]|6[1-8]|7[1-6]))\\d{2,7}"],["3[1-9]\\d{8}|3[2-9]\\d{7}",[9,10]],["80(?:0\\d{3}|3)\\d{3}",[6,9]],["(?:0878\\d{3}|89(?:2\\d|3[04]|4(?:[0-4]|[5-9]\\d\\d)|5[0-4]))\\d\\d|(?:1(?:44|6[346])|89(?:38|5[5-9]|9))\\d{6}",[6,8,9,10]],["1(?:78\\d|99)\\d{6}",[9,10]],0,0,0,["55\\d{8}",[10]],["84(?:[08]\\d{3}|[17])\\d{3}",[6,9]]]],"JE":["44","00","1534\\d{6}|(?:[3578]\\d|90)\\d{8}",[10],0,"0",0,"0|([0-24-8]\\d{5})$","1534$1",0,0,[["1534[0-24-8]\\d{5}"],["7(?:(?:(?:50|82)9|937)\\d|7(?:00[378]|97[7-9]))\\d{5}"],["80(?:07(?:35|81)|8901)\\d{4}"],["(?:8(?:4(?:4(?:4(?:05|42|69)|703)|5(?:041|800))|7(?:0002|1206))|90(?:066[59]|1810|71(?:07|55)))\\d{4}"],["701511\\d{4}"],0,["(?:3(?:0(?:07(?:35|81)|8901)|3\\d{4}|4(?:4(?:4(?:05|42|69)|703)|5(?:041|800))|7(?:0002|1206))|55\\d{4})\\d{4}"],["76(?:464|652)\\d{5}|76(?:0[0-2]|2[356]|34|4[01347]|5[49]|6[0-369]|77|81|9[139])\\d{6}"],["56\\d{8}"]]],"JM":["1","011","(?:[58]\\d\\d|658|900)\\d{7}",[10],0,"1",0,0,0,0,"658|876"],"JO":["962","00","(?:(?:[2689]|7\\d)\\d|32|53)\\d{6}",[8,9],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[2356]|87"],"(0$1)"],["(\\d{3})(\\d{5,6})","$1 $2",["[89]"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["70"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["7"],"0$1"]],"0"],"JP":["81","010","00[1-9]\\d{6,14}|[257-9]\\d{9}|(?:00|[1-9]\\d\\d)\\d{6}",[8,9,10,11,12,13,14,15,16,17],[["(\\d{3})(\\d{3})(\\d{3})","$1-$2-$3",["(?:12|57|99)0"],"0$1"],["(\\d{4})(\\d)(\\d{4})","$1-$2-$3",["1(?:26|3[79]|4[56]|5[4-68]|6[3-5])|499|5(?:76|97)|746|8(?:3[89]|47|51|63)|9(?:49|80|9[16])","1(?:267|3(?:7[247]|9[278])|466|5(?:47|58|64)|6(?:3[245]|48|5[4-68]))|499[2468]|5(?:76|97)9|7468|8(?:3(?:8[7-9]|96)|477|51[2-9]|636)|9(?:496|802|9(?:1[23]|69))|1(?:45|58)[67]","1(?:267|3(?:7[247]|9[278])|466|5(?:47|58|64)|6(?:3[245]|48|5[4-68]))|499[2468]|5(?:769|979[2-69])|7468|8(?:3(?:8[7-9]|96[2457-9])|477|51[2-9]|636[457-9])|9(?:496|802|9(?:1[23]|69))|1(?:45|58)[67]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["60"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1-$2-$3",["[36]|4(?:2[09]|7[01])","[36]|4(?:2(?:0|9[02-69])|7(?:0[019]|1))"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["1(?:1|5[45]|77|88|9[69])|2(?:2[1-37]|3[0-269]|4[59]|5|6[24]|7[1-358]|8[1369]|9[0-38])|4(?:[28][1-9]|3[0-57]|[45]|6[248]|7[2-579]|9[29])|5(?:2|3[045]|4[0-369]|5[29]|8[02389]|9[0-389])|7(?:2[02-46-9]|34|[58]|6[0249]|7[57]|9[2-6])|8(?:2[124589]|3[27-9]|49|51|6|7[0-468]|8[68]|9[019])|9(?:[23][1-9]|4[15]|5[138]|6[1-3]|7[156]|8[189]|9[1-489])","1(?:1|5(?:4[018]|5[017])|77|88|9[69])|2(?:2(?:[127]|3[014-9])|3[0-269]|4[59]|5(?:[1-3]|5[0-69]|9[19])|62|7(?:[1-35]|8[0189])|8(?:[16]|3[0134]|9[0-5])|9(?:[028]|17))|4(?:2(?:[13-79]|8[014-6])|3[0-57]|[45]|6[248]|7[2-47]|8[1-9])|5(?:2|3[045]|4[0-369]|8[02389]|9[0-3])|7(?:2[02-46-9]|34|[58]|6[0249]|7[57]|9(?:[23]|4[0-59]|5[01569]|6[0167]))|8(?:2(?:[1258]|4[0-39]|9[0-2469])|49|51|6(?:[0-24]|36|5[0-3589]|72|9[01459])|7[0-468]|8[68])|9(?:[23][1-9]|4[15]|5[138]|6[1-3]|7[156]|8[189]|9(?:[1289]|3[34]|4[0178]))|(?:49|55|83)[29]|(?:264|837)[016-9]|2(?:57|93)[015-9]|(?:25[0468]|422|838)[01]|(?:47[59]|59[89]|8(?:6[68]|9))[019]","1(?:1|5(?:4[018]|5[017])|77|88|9[69])|2(?:2[127]|3[0-269]|4[59]|5(?:[1-3]|5[0-69]|9(?:17|99))|6(?:2|4[016-9])|7(?:[1-35]|8[0189])|8(?:[16]|3[0134]|9[0-5])|9(?:[028]|17))|4(?:2(?:[13-79]|8[014-6])|3[0-57]|[45]|6[248]|7[2-47]|9[29])|5(?:2|3[045]|4[0-369]|5[29]|8[02389]|9[0-3])|7(?:2[02-46-9]|34|[58]|6[0249]|7[57]|9(?:[23]|4[0-59]|5[01569]|6[0167]))|8(?:2(?:[1258]|4[0-39]|9[0169])|3(?:[29]|7(?:[017-9]|6[6-8]))|49|51|6(?:[0-24]|36[23]|5(?:[0-389]|5[23])|6(?:[01]|9[178])|72|9[0145])|7[0-468]|8[68])|9(?:4[15]|5[138]|7[156]|8[189]|9(?:[1289]|3(?:31|4[357])|4[0178]))|(?:8294|96)[1-3]|2(?:57|93)[015-9]|(?:223|8699)[014-9]|(?:25[0468]|422|838)[01]|(?:48|8292|9[23])[1-9]|(?:47[59]|59[89]|8(?:68|9))[019]","1(?:1|5(?:4[018]|5[017])|77|88|9[69])|2(?:2[127]|3[0-269]|4[59]|5(?:[1-3]|5[0-69]|7[015-9]|9(?:17|99))|6(?:2|4[016-9])|7(?:[1-35]|8[0189])|8(?:[16]|3[0134]|9[0-5])|9(?:[028]|17|3[015-9]))|4(?:2(?:[13-79]|8[014-6])|3[0-57]|[45]|6[248]|7[2-47]|9[29])|5(?:2|3[045]|4[0-369]|5[29]|8[02389]|9[0-3])|7(?:2[02-46-9]|34|[58]|6[0249]|7[57]|9(?:[23]|4[0-59]|5[01569]|6[0167]))|8(?:2(?:[1258]|4[0-39]|9(?:[019]|4[1-3]|6(?:[0-47-9]|5[01346-9])))|3(?:[29]|7(?:[017-9]|6[6-8]))|49|51|6(?:[0-24]|36[23]|5(?:[0-389]|5[23])|6(?:[01]|9[178])|72|9[0145])|7[0-468]|8[68])|9(?:4[15]|5[138]|6[1-3]|7[156]|8[189]|9(?:[1289]|3(?:31|4[357])|4[0178]))|(?:223|8699)[014-9]|(?:25[0468]|422|838)[01]|(?:48|829(?:2|66)|9[23])[1-9]|(?:47[59]|59[89]|8(?:68|9))[019]"],"0$1"],["(\\d{3})(\\d{2})(\\d{4})","$1-$2-$3",["[14]|[289][2-9]|5[3-9]|7[2-4679]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["800"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1-$2-$3",["[257-9]"],"0$1"]],"0"],"KE":["254","000","(?:[17]\\d\\d|900)\\d{6}|(?:2|80)0\\d{6,7}|[4-6]\\d{6,8}",[7,8,9,10],[["(\\d{2})(\\d{5,7})","$1 $2",["[24-6]"],"0$1"],["(\\d{3})(\\d{6})","$1 $2",["[17]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["[89]"],"0$1"]],"0"],"KG":["996","00","8\\d{9}|(?:[235-8]\\d|99)\\d{7}",[9,10],[["(\\d{4})(\\d{5})","$1 $2",["3(?:1[346]|[24-79])"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[235-79]|88"],"0$1"],["(\\d{3})(\\d{3})(\\d)(\\d{2,3})","$1 $2 $3 $4",["8"],"0$1"]],"0"],"KH":["855","00[14-9]","1\\d{9}|[1-9]\\d{7,8}",[8,9,10],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[1-9]"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1"]]],"0"],"KI":["686","00","(?:[37]\\d|6[0-79])\\d{6}|(?:[2-48]\\d|50)\\d{3}",[5,8],0,"0"],"KM":["269","00","[3478]\\d{6}",[7],[["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",["[3478]"]]]],"KN":["1","011","(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"1|([2-7]\\d{6})$","869$1",0,"869"],"KP":["850","00|99","85\\d{6}|(?:19\\d|[2-7])\\d{7}",[8,10],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["8"],"0$1"],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[2-7]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"]],"0"],"KR":["82","00(?:[125689]|3(?:[46]5|91)|7(?:00|27|3|55|6[126]))","00[1-9]\\d{8,11}|(?:[12]|5\\d{3})\\d{7}|[13-6]\\d{9}|(?:[1-6]\\d|80)\\d{7}|[3-6]\\d{4,5}|(?:00|7)0\\d{8}",[5,6,8,9,10,11,12,13,14],[["(\\d{2})(\\d{3,4})","$1-$2",["(?:3[1-3]|[46][1-4]|5[1-5])1"],"0$1"],["(\\d{4})(\\d{4})","$1-$2",["1"]],["(\\d)(\\d{3,4})(\\d{4})","$1-$2-$3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["60|8"],"0$1"],["(\\d{2})(\\d{3,4})(\\d{4})","$1-$2-$3",["[1346]|5[1-5]"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1-$2-$3",["[57]"],"0$1"],["(\\d{2})(\\d{5})(\\d{4})","$1-$2-$3",["5"],"0$1"]],"0",0,"0(8(?:[1-46-8]|5\\d\\d))?"],"KW":["965","00","18\\d{5}|(?:[2569]\\d|41)\\d{6}",[7,8],[["(\\d{4})(\\d{3,4})","$1 $2",["[169]|2(?:[235]|4[1-35-9])|52"]],["(\\d{3})(\\d{5})","$1 $2",["[245]"]]]],"KY":["1","011","(?:345|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"1|([2-9]\\d{6})$","345$1",0,"345"],"KZ":["7","810","(?:33622|8\\d{8})\\d{5}|[78]\\d{9}",[10,14],0,"8",0,0,0,0,"33|7",0,"8~10"],"LA":["856","00","[23]\\d{9}|3\\d{8}|(?:[235-8]\\d|41)\\d{6}",[8,9,10],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["2[13]|3[14]|[4-8]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3 $4",["30[013-9]"],"0$1"],["(\\d{2})(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3 $4",["[23]"],"0$1"]],"0"],"LB":["961","00","[27-9]\\d{7}|[13-9]\\d{6}",[7,8],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[13-69]|7(?:[2-57]|62|8[0-7]|9[04-9])|8[02-9]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[27-9]"]]],"0"],"LC":["1","011","(?:[58]\\d\\d|758|900)\\d{7}",[10],0,"1",0,"1|([2-8]\\d{6})$","758$1",0,"758"],"LI":["423","00","90\\d{5}|(?:[2378]|6\\d\\d)\\d{6}",[7,9],[["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",["[237-9]"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["69"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6"]]],"0",0,"0|(1001)"],"LK":["94","00","[1-9]\\d{8}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[1-689]"],"0$1"]],"0"],"LR":["231","00","(?:2|33|5\\d|77|88)\\d{7}|[4-6]\\d{6}",[7,8,9],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[4-6]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[3578]"],"0$1"]],"0"],"LS":["266","00","(?:[256]\\d\\d|800)\\d{5}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[2568]"]]]],"LT":["370","00","(?:[3469]\\d|52|[78]0)\\d{6}",[8],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["52[0-7]"],"(8-$1)",1],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["[7-9]"],"8 $1",1],["(\\d{2})(\\d{6})","$1 $2",["37|4(?:[15]|6[1-8])"],"(8-$1)",1],["(\\d{3})(\\d{5})","$1 $2",["[3-6]"],"(8-$1)",1]],"8",0,"[08]"],"LU":["352","00","35[013-9]\\d{4,8}|6\\d{8}|35\\d{2,4}|(?:[2457-9]\\d|3[0-46-9])\\d{2,9}",[4,5,6,7,8,9,10,11],[["(\\d{2})(\\d{3})","$1 $2",["2(?:0[2-689]|[2-9])|[3-57]|8(?:0[2-9]|[13-9])|9(?:0[89]|[2-579])"]],["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["2(?:0[2-689]|[2-9])|[3-57]|8(?:0[2-9]|[13-9])|9(?:0[89]|[2-579])"]],["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["20[2-689]"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{1,2})","$1 $2 $3 $4",["2(?:[0367]|4[3-8])"]],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["80[01]|90[015]"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3 $4",["20"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{1,2})","$1 $2 $3 $4 $5",["2(?:[0367]|4[3-8])"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{1,5})","$1 $2 $3 $4",["[3-57]|8[13-9]|9(?:0[89]|[2-579])|(?:2|80)[2-9]"]]],0,0,"(15(?:0[06]|1[12]|[35]5|4[04]|6[26]|77|88|99)\\d)"],"LV":["371","00","(?:[268]\\d|90)\\d{6}",[8],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[269]|8[01]"]]]],"LY":["218","00","[2-9]\\d{8}",[9],[["(\\d{2})(\\d{7})","$1-$2",["[2-9]"],"0$1"]],"0"],"MA":["212","00","[5-8]\\d{8}",[9],[["(\\d{5})(\\d{4})","$1-$2",["5(?:29|38)","5(?:29|38)[89]","5(?:29|38)[89]0"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["5[45]"],"0$1"],["(\\d{4})(\\d{5})","$1-$2",["5(?:2[2-489]|3[5-9]|9)|892","5(?:2(?:[2-49]|8[235-9])|3[5-9]|9)|892"],"0$1"],["(\\d{2})(\\d{7})","$1-$2",["8"],"0$1"],["(\\d{3})(\\d{6})","$1-$2",["[5-7]"],"0$1"]],"0",0,0,0,0,0,[["5(?:29(?:[189][05]|2[29]|3[01])|38[89][05])\\d{4}|5(?:2(?:[0-25-7]\\d|3[1-578]|4[02-46-8]|8[0235-7]|90)|3(?:[0-47]\\d|5[02-9]|6[02-8]|80|9[3-9])|(?:4[067]|5[03])\\d)\\d{5}"],["(?:6(?:[0-79]\\d|8[0-247-9])|7(?:0\\d|1[0-5]|6[1267]|7[0-57]))\\d{6}"],["80\\d{7}"],["89\\d{7}"],0,0,0,0,["592(?:4[0-2]|93)\\d{4}"]]],"MC":["377","00","(?:[3489]|6\\d)\\d{7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["4"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[389]"]],["(\\d)(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["6"],"0$1"]],"0"],"MD":["373","00","(?:[235-7]\\d|[89]0)\\d{6}",[8],[["(\\d{3})(\\d{5})","$1 $2",["[89]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["22|3"],"0$1"],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["[25-7]"],"0$1"]],"0"],"ME":["382","00","(?:20|[3-79]\\d)\\d{6}|80\\d{6,7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-9]"],"0$1"]],"0"],"MF":["590","00","(?:590|(?:69|80)\\d|976)\\d{6}",[9],0,"0",0,0,0,0,0,[["590(?:0[079]|[14]3|[27][79]|30|5[0-268]|87)\\d{4}"],["69(?:0\\d\\d|1(?:2[2-9]|3[0-5]))\\d{4}"],["80[0-5]\\d{6}"],0,0,0,0,0,["976[01]\\d{5}"]]],"MG":["261","00","[23]\\d{8}",[9],[["(\\d{2})(\\d{2})(\\d{3})(\\d{2})","$1 $2 $3 $4",["[23]"],"0$1"]],"0",0,"0|([24-9]\\d{6})$","20$1"],"MH":["692","011","329\\d{4}|(?:[256]\\d|45)\\d{5}",[7],[["(\\d{3})(\\d{4})","$1-$2",["[2-6]"]]],"1"],"MK":["389","00","[2-578]\\d{7}",[8],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[347]"],"0$1"],["(\\d{3})(\\d)(\\d{2})(\\d{2})","$1 $2 $3 $4",["[58]"],"0$1"]],"0"],"ML":["223","00","[24-9]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[24-9]"]]]],"MM":["95","00","1\\d{5,7}|95\\d{6}|(?:[4-7]|9[0-46-9])\\d{6,8}|(?:2|8\\d)\\d{5,8}",[6,7,8,9,10],[["(\\d)(\\d{2})(\\d{3})","$1 $2 $3",["16|2"],"0$1"],["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["[45]|6(?:0[23]|[1-689]|7[235-7])|7(?:[0-4]|5[2-7])|8[1-6]"],"0$1"],["(\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["[12]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[4-7]|8[1-35]"],"0$1"],["(\\d)(\\d{3})(\\d{4,6})","$1 $2 $3",["9(?:2[0-4]|[35-9]|4[137-9])"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["2"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"],"0$1"],["(\\d)(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["92"],"0$1"],["(\\d)(\\d{5})(\\d{4})","$1 $2 $3",["9"],"0$1"]],"0"],"MN":["976","001","[12]\\d{7,9}|[57-9]\\d{7}",[8,9,10],[["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["[12]1"],"0$1"],["(\\d{4})(\\d{4})","$1 $2",["[57-9]"]],["(\\d{3})(\\d{5,6})","$1 $2",["[12]2[1-3]"],"0$1"],["(\\d{4})(\\d{5,6})","$1 $2",["[12](?:27|3[2-8]|4[2-68]|5[1-4689])","[12](?:27|3[2-8]|4[2-68]|5[1-4689])[0-3]"],"0$1"],["(\\d{5})(\\d{4,5})","$1 $2",["[12]"],"0$1"]],"0"],"MO":["853","00","0800\\d{3}|(?:28|[68]\\d)\\d{6}",[7,8],[["(\\d{4})(\\d{3})","$1 $2",["0"]],["(\\d{4})(\\d{4})","$1 $2",["[268]"]]]],"MP":["1","011","[58]\\d{9}|(?:67|90)0\\d{7}",[10],0,"1",0,"1|([2-9]\\d{6})$","670$1",0,"670"],"MQ":["596","00","(?:69|80)\\d{7}|(?:59|97)6\\d{6}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[569]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0$1"]],"0"],"MR":["222","00","(?:[2-4]\\d\\d|800)\\d{5}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-48]"]]]],"MS":["1","011","(?:[58]\\d\\d|664|900)\\d{7}",[10],0,"1",0,"1|([34]\\d{6})$","664$1",0,"664"],"MT":["356","00","3550\\d{4}|(?:[2579]\\d\\d|800)\\d{5}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[2357-9]"]]]],"MU":["230","0(?:0|[24-7]0|3[03])","(?:5|8\\d\\d)\\d{7}|[2-468]\\d{6}",[7,8,10],[["(\\d{3})(\\d{4})","$1 $2",["[2-46]|8[013]"]],["(\\d{4})(\\d{4})","$1 $2",["5"]],["(\\d{5})(\\d{5})","$1 $2",["8"]]],0,0,0,0,0,0,0,"020"],"MV":["960","0(?:0|19)","(?:800|9[0-57-9]\\d)\\d{7}|[34679]\\d{6}",[7,10],[["(\\d{3})(\\d{4})","$1-$2",["[3467]|9[13-9]"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[89]"]]],0,0,0,0,0,0,0,"00"],"MW":["265","00","(?:[19]\\d|[23]1|77|88)\\d{7}|1\\d{6}",[7,9],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["1[2-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["2"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[137-9]"],"0$1"]],"0"],"MX":["52","0[09]","1(?:(?:44|99)[1-9]|65[0-689])\\d{7}|(?:1(?:[017]\\d|[235][1-9]|4[0-35-9]|6[0-46-9]|8[1-79]|9[1-8])|[2-9]\\d)\\d{8}",[10,11],[["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["33|5[56]|81"],0,1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[2-9]"],0,1],["(\\d)(\\d{2})(\\d{4})(\\d{4})","$2 $3 $4",["1(?:33|5[56]|81)"],0,1],["(\\d)(\\d{3})(\\d{3})(\\d{4})","$2 $3 $4",["1"],0,1]],"01",0,"0(?:[12]|4[45])|1",0,0,0,0,"00"],"MY":["60","00","1\\d{8,9}|(?:3\\d|[4-9])\\d{7}",[8,9,10],[["(\\d)(\\d{3})(\\d{4})","$1-$2 $3",["[4-79]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1-$2 $3",["1(?:[02469]|[378][1-9])|8"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1-$2 $3",["3"],"0$1"],["(\\d)(\\d{3})(\\d{2})(\\d{4})","$1-$2-$3-$4",["1[36-8]"]],["(\\d{3})(\\d{3})(\\d{4})","$1-$2 $3",["15"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1-$2 $3",["1"],"0$1"]],"0"],"MZ":["258","00","(?:2|8\\d)\\d{7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["2|8[2-79]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8"]]]],"NA":["264","00","[68]\\d{7,8}",[8,9],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["88"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["6"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["87"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["8"],"0$1"]],"0"],"NC":["687","00","[2-57-9]\\d{5}",[6],[["(\\d{2})(\\d{2})(\\d{2})","$1.$2.$3",["[2-57-9]"]]]],"NE":["227","00","[027-9]\\d{7}",[8],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["08"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[089]|2[013]|7[04]"]]]],"NF":["672","00","[13]\\d{5}",[6],[["(\\d{2})(\\d{4})","$1 $2",["1[0-3]"]],["(\\d)(\\d{5})","$1 $2",["[13]"]]],0,0,"([0-258]\\d{4})$","3$1"],"NG":["234","009","(?:[124-7]|9\\d{3})\\d{6}|[1-9]\\d{7}|[78]\\d{9,13}",[7,8,10,11,12,13,14],[["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["78"],"0$1"],["(\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["[12]|9(?:0[3-9]|[1-9])"],"0$1"],["(\\d{2})(\\d{3})(\\d{2,3})","$1 $2 $3",["[3-7]|8[2-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["[7-9]"],"0$1"],["(\\d{3})(\\d{4})(\\d{4,5})","$1 $2 $3",["[78]"],"0$1"],["(\\d{3})(\\d{5})(\\d{5,6})","$1 $2 $3",["[78]"],"0$1"]],"0"],"NI":["505","00","(?:1800|[25-8]\\d{3})\\d{4}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[125-8]"]]]],"NL":["31","00","(?:[124-7]\\d\\d|3(?:[02-9]\\d|1[0-8]))\\d{6}|[89]\\d{6,9}|1\\d{4,5}",[5,6,7,8,9,10],[["(\\d{3})(\\d{4,7})","$1 $2",["[89]0"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["66"],"0$1"],["(\\d)(\\d{8})","$1 $2",["6"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["1[16-8]|2[259]|3[124]|4[17-9]|5[124679]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[1-57-9]"],"0$1"]],"0"],"NO":["47","00","(?:0|[2-9]\\d{3})\\d{4}",[5,8],[["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["[489]|59"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[235-7]"]]],0,0,0,0,0,"[02-689]|7[0-8]"],"NP":["977","00","(?:1\\d|9)\\d{9}|[1-9]\\d{7}",[8,10,11],[["(\\d)(\\d{7})","$1-$2",["1[2-6]"],"0$1"],["(\\d{2})(\\d{6})","$1-$2",["1[01]|[2-8]|9(?:[1-579]|6[2-6])"],"0$1"],["(\\d{3})(\\d{7})","$1-$2",["9"]]],"0"],"NR":["674","00","(?:444|(?:55|8\\d)\\d|666)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[4-68]"]]]],"NU":["683","00","(?:[47]|888\\d)\\d{3}",[4,7],[["(\\d{3})(\\d{4})","$1 $2",["8"]]]],"NZ":["64","0(?:0|161)","[29]\\d{7,9}|50\\d{5}(?:\\d{2,3})?|6[0-35-9]\\d{6}|7\\d{7,8}|8\\d{4,9}|(?:11\\d|[34])\\d{7}",[5,6,7,8,9,10],[["(\\d{2})(\\d{3,8})","$1 $2",["8[1-579]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2,3})","$1 $2 $3",["50[036-8]|[89]0","50(?:[0367]|88)|[89]0"],"0$1"],["(\\d)(\\d{3})(\\d{4})","$1-$2 $3",["24|[346]|7[2-57-9]|9[2-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["2(?:10|74)|[59]|80"],"0$1"],["(\\d{2})(\\d{3,4})(\\d{4})","$1 $2 $3",["1|2[028]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,5})","$1 $2 $3",["2(?:[169]|7[0-35-9])|7|86"],"0$1"]],"0",0,0,0,0,0,0,"00"],"OM":["968","00","(?:1505|[279]\\d{3}|500)\\d{4}|800\\d{5,6}",[7,8,9],[["(\\d{3})(\\d{4,6})","$1 $2",["[58]"]],["(\\d{2})(\\d{6})","$1 $2",["2"]],["(\\d{4})(\\d{4})","$1 $2",["[179]"]]]],"PA":["507","00","(?:00800|8\\d{3})\\d{6}|[68]\\d{7}|[1-57-9]\\d{6}",[7,8,10,11],[["(\\d{3})(\\d{4})","$1-$2",["[1-57-9]"]],["(\\d{4})(\\d{4})","$1-$2",["[68]"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"]]]],"PE":["51","19(?:1[124]|77|90)00","(?:[14-8]|9\\d)\\d{7}",[8,9],[["(\\d{3})(\\d{5})","$1 $2",["80"],"(0$1)"],["(\\d)(\\d{7})","$1 $2",["1"],"(0$1)"],["(\\d{2})(\\d{6})","$1 $2",["[4-8]"],"(0$1)"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["9"]]],"0",0,0,0,0,0,0,0," Anexo "],"PF":["689","00","4\\d{5}(?:\\d{2})?|8\\d{7,8}",[6,8,9],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["44"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["4|8[7-9]"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"]]]],"PG":["675","00|140[1-3]","(?:180|[78]\\d{3})\\d{4}|(?:[2-589]\\d|64)\\d{5}",[7,8],[["(\\d{3})(\\d{4})","$1 $2",["18|[2-69]|85"]],["(\\d{4})(\\d{4})","$1 $2",["[78]"]]],0,0,0,0,0,0,0,"00"],"PH":["63","00","(?:[2-7]|9\\d)\\d{8}|2\\d{5}|(?:1800|8)\\d{7,9}",[6,8,9,10,11,12,13],[["(\\d)(\\d{5})","$1 $2",["2"],"(0$1)"],["(\\d{4})(\\d{4,6})","$1 $2",["3(?:23|39|46)|4(?:2[3-6]|[35]9|4[26]|76)|544|88[245]|(?:52|64|86)2","3(?:230|397|461)|4(?:2(?:35|[46]4|51)|396|4(?:22|63)|59[347]|76[15])|5(?:221|446)|642[23]|8(?:622|8(?:[24]2|5[13]))"],"(0$1)"],["(\\d{5})(\\d{4})","$1 $2",["346|4(?:27|9[35])|883","3469|4(?:279|9(?:30|56))|8834"],"(0$1)"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["2"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[3-7]|8[2-8]"],"(0$1)"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[89]"],"0$1"],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]],["(\\d{4})(\\d{1,2})(\\d{3})(\\d{4})","$1 $2 $3 $4",["1"]]],"0"],"PK":["92","00","122\\d{6}|[24-8]\\d{10,11}|9(?:[013-9]\\d{8,10}|2(?:[01]\\d\\d|2(?:[06-8]\\d|1[01]))\\d{7})|(?:[2-8]\\d{3}|92(?:[0-7]\\d|8[1-9]))\\d{6}|[24-9]\\d{8}|[89]\\d{7}",[8,9,10,11,12],[["(\\d{3})(\\d{3})(\\d{2,7})","$1 $2 $3",["[89]0"],"0$1"],["(\\d{4})(\\d{5})","$1 $2",["1"]],["(\\d{3})(\\d{6,7})","$1 $2",["2(?:3[2358]|4[2-4]|9[2-8])|45[3479]|54[2-467]|60[468]|72[236]|8(?:2[2-689]|3[23578]|4[3478]|5[2356])|9(?:2[2-8]|3[27-9]|4[2-6]|6[3569]|9[25-8])","9(?:2[3-8]|98)|(?:2(?:3[2358]|4[2-4]|9[2-8])|45[3479]|54[2-467]|60[468]|72[236]|8(?:2[2-689]|3[23578]|4[3478]|5[2356])|9(?:22|3[27-9]|4[2-6]|6[3569]|9[25-7]))[2-9]"],"(0$1)"],["(\\d{2})(\\d{7,8})","$1 $2",["(?:2[125]|4[0-246-9]|5[1-35-7]|6[1-8]|7[14]|8[16]|91)[2-9]"],"(0$1)"],["(\\d{5})(\\d{5})","$1 $2",["58"],"(0$1)"],["(\\d{3})(\\d{7})","$1 $2",["3"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["2[125]|4[0-246-9]|5[1-35-7]|6[1-8]|7[14]|8[16]|91"],"(0$1)"],["(\\d{3})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["[24-9]"],"(0$1)"]],"0"],"PL":["48","00","6\\d{5}(?:\\d{2})?|8\\d{9}|[1-9]\\d{6}(?:\\d{2})?",[6,7,8,9,10],[["(\\d{5})","$1",["19"]],["(\\d{3})(\\d{3})","$1 $2",["11|64"]],["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["(?:1[2-8]|2[2-69]|3[2-4]|4[1-468]|5[24-689]|6[1-3578]|7[14-7]|8[1-79]|9[145])1","(?:1[2-8]|2[2-69]|3[2-4]|4[1-468]|5[24-689]|6[1-3578]|7[14-7]|8[1-79]|9[145])19"]],["(\\d{3})(\\d{2})(\\d{2,3})","$1 $2 $3",["64"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["21|39|45|5[0137]|6[0469]|7[02389]|8(?:0[14]|8)"]],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1[2-8]|[2-7]|8[1-79]|9[145]"]],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["8"]]]],"PM":["508","00","(?:[45]|80\\d\\d)\\d{5}",[6,9],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["[45]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0$1"]],"0"],"PR":["1","011","(?:[589]\\d\\d|787)\\d{7}",[10],0,"1",0,0,0,0,"787|939"],"PS":["970","00","[2489]2\\d{6}|(?:1\\d|5)\\d{8}",[8,9,10],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[2489]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["5"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1"]]],"0"],"PT":["351","00","1693\\d{5}|(?:[26-9]\\d|30)\\d{7}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["2[12]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["16|[236-9]"]]]],"PW":["680","01[12]","(?:[24-8]\\d\\d|345|900)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-9]"]]]],"PY":["595","00","59\\d{4,6}|9\\d{5,10}|(?:[2-46-8]\\d|5[0-8])\\d{4,7}",[6,7,8,9,10,11],[["(\\d{3})(\\d{3,6})","$1 $2",["[2-9]0"],"0$1"],["(\\d{2})(\\d{5})","$1 $2",["[26]1|3[289]|4[1246-8]|7[1-3]|8[1-36]"],"(0$1)"],["(\\d{3})(\\d{4,5})","$1 $2",["2[279]|3[13-5]|4[359]|5|6(?:[34]|7[1-46-8])|7[46-8]|85"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["2[14-68]|3[26-9]|4[1246-8]|6(?:1|75)|7[1-35]|8[1-36]"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["87"]],["(\\d{3})(\\d{6})","$1 $2",["9(?:[5-79]|8[1-6])"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[2-8]"],"0$1"],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["9"]]],"0"],"QA":["974","00","[2-7]\\d{7}|800\\d{4}(?:\\d{2})?|2\\d{6}",[7,8,9],[["(\\d{3})(\\d{4})","$1 $2",["2[126]|8"]],["(\\d{4})(\\d{4})","$1 $2",["[2-7]"]]]],"RE":["262","00","9769\\d{5}|(?:26|[68]\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2689]"],"0$1"]],"0",0,0,0,0,"26[23]|69|[89]"],"RO":["40","00","(?:[2378]\\d|90)\\d{7}|[23]\\d{5}",[6,9],[["(\\d{3})(\\d{3})","$1 $2",["2[3-6]","2[3-6]\\d9"],"0$1"],["(\\d{2})(\\d{4})","$1 $2",["219|31"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[23]1"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[237-9]"],"0$1"]],"0",0,0,0,0,0,0,0," int "],"RS":["381","00","38[02-9]\\d{6,9}|6\\d{7,9}|90\\d{4,8}|38\\d{5,6}|(?:7\\d\\d|800)\\d{3,9}|(?:[12]\\d|3[0-79])\\d{5,10}",[6,7,8,9,10,11,12],[["(\\d{3})(\\d{3,9})","$1 $2",["(?:2[389]|39)0|[7-9]"],"0$1"],["(\\d{2})(\\d{5,10})","$1 $2",["[1-36]"],"0$1"]],"0"],"RU":["7","810","8\\d{13}|[347-9]\\d{9}",[10,14],[["(\\d{4})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["7(?:1[0-8]|2[1-9])","7(?:1(?:[0-6]2|7|8[27])|2(?:1[23]|[2-9]2))","7(?:1(?:[0-6]2|7|8[27])|2(?:13[03-69]|62[013-9]))|72[1-57-9]2"],"8 ($1)",1],["(\\d{5})(\\d)(\\d{2})(\\d{2})","$1 $2 $3 $4",["7(?:1[0-68]|2[1-9])","7(?:1(?:[06][3-6]|[18]|2[35]|[3-5][3-5])|2(?:[13][3-5]|[24-689]|7[457]))","7(?:1(?:0(?:[356]|4[023])|[18]|2(?:3[013-9]|5)|3[45]|43[013-79]|5(?:3[1-8]|4[1-7]|5)|6(?:3[0-35-9]|[4-6]))|2(?:1(?:3[178]|[45])|[24-689]|3[35]|7[457]))|7(?:14|23)4[0-8]|71(?:33|45)[1-79]"],"8 ($1)",1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"8 ($1)",1],["(\\d{3})(\\d{3})(\\d{2})(\\d{2})","$1 $2-$3-$4",["[349]|8(?:[02-7]|1[1-8])"],"8 ($1)",1],["(\\d{4})(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3 $4",["8"],"8 ($1)"]],"8",0,0,0,0,"3[04-689]|[489]",0,"8~10"],"RW":["250","00","(?:06|[27]\\d\\d|[89]00)\\d{6}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["0"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[7-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["2"]]],"0"],"SA":["966","00","92\\d{7}|(?:[15]|8\\d)\\d{8}",[9,10],[["(\\d{4})(\\d{5})","$1 $2",["9"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["5"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["81"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"]]],"0"],"SB":["677","0[01]","(?:[1-6]|[7-9]\\d\\d)\\d{4}",[5,7],[["(\\d{2})(\\d{5})","$1 $2",["7|8[4-9]|9(?:[1-8]|9[0-8])"]]]],"SC":["248","010|0[0-2]","8000\\d{3}|(?:[249]\\d|64)\\d{5}",[7],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[246]|9[57]"]]],0,0,0,0,0,0,0,"00"],"SD":["249","00","[19]\\d{8}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[19]"],"0$1"]],"0"],"SE":["46","00","(?:[26]\\d\\d|9)\\d{9}|[1-9]\\d{8}|[1-689]\\d{7}|[1-4689]\\d{6}|2\\d{5}",[6,7,8,9,10],[["(\\d{2})(\\d{2,3})(\\d{2})","$1-$2 $3",["20"],"0$1",0,"$1 $2 $3"],["(\\d{3})(\\d{4})","$1-$2",["9(?:00|39|44)"],"0$1",0,"$1 $2"],["(\\d{2})(\\d{3})(\\d{2})","$1-$2 $3",["[12][136]|3[356]|4[0246]|6[03]|90[1-9]"],"0$1",0,"$1 $2 $3"],["(\\d)(\\d{2,3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["8"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2,3})(\\d{2})","$1-$2 $3",["1[2457]|2(?:[247-9]|5[0138])|3[0247-9]|4[1357-9]|5[0-35-9]|6(?:[125689]|4[02-57]|7[0-2])|9(?:[125-8]|3[02-5]|4[0-3])"],"0$1",0,"$1 $2 $3"],["(\\d{3})(\\d{2,3})(\\d{3})","$1-$2 $3",["9(?:00|39|44)"],"0$1",0,"$1 $2 $3"],["(\\d{2})(\\d{2,3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["1[13689]|2[0136]|3[1356]|4[0246]|54|6[03]|90[1-9]"],"0$1",0,"$1 $2 $3 $4"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["10|7"],"0$1",0,"$1 $2 $3 $4"],["(\\d)(\\d{3})(\\d{3})(\\d{2})","$1-$2 $3 $4",["8"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1-$2 $3 $4",["[13-5]|2(?:[247-9]|5[0138])|6(?:[124-689]|7[0-2])|9(?:[125-8]|3[02-5]|4[0-3])"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2})(\\d{2})(\\d{3})","$1-$2 $3 $4",["9"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1-$2 $3 $4 $5",["[26]"],"0$1",0,"$1 $2 $3 $4 $5"]],"0"],"SG":["65","0[0-3]\\d","(?:(?:1\\d|8)\\d\\d|7000)\\d{7}|[3689]\\d{7}",[8,10,11],[["(\\d{4})(\\d{4})","$1 $2",["[369]|8(?:0[1-4]|[1-9])"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"]],["(\\d{4})(\\d{4})(\\d{3})","$1 $2 $3",["7"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]]]],"SH":["290","00","(?:[256]\\d|8)\\d{3}",[4,5],0,0,0,0,0,0,"[256]"],"SI":["386","00|10(?:22|66|88|99)","[1-7]\\d{7}|8\\d{4,7}|90\\d{4,6}",[5,6,7,8],[["(\\d{2})(\\d{3,6})","$1 $2",["8[09]|9"],"0$1"],["(\\d{3})(\\d{5})","$1 $2",["59|8"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[37][01]|4[0139]|51|6"],"0$1"],["(\\d)(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[1-57]"],"(0$1)"]],"0",0,0,0,0,0,0,"00"],"SJ":["47","00","0\\d{4}|(?:[489]\\d|[57]9)\\d{6}",[5,8],0,0,0,0,0,0,"79"],"SK":["421","00","[2-689]\\d{8}|[2-59]\\d{6}|[2-5]\\d{5}",[6,7,9],[["(\\d)(\\d{2})(\\d{3,4})","$1 $2 $3",["21"],"0$1"],["(\\d{2})(\\d{2})(\\d{2,3})","$1 $2 $3",["[3-5][1-8]1","[3-5][1-8]1[67]"],"0$1"],["(\\d)(\\d{3})(\\d{3})(\\d{2})","$1/$2 $3 $4",["2"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[689]"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1/$2 $3 $4",["[3-5]"],"0$1"]],"0"],"SL":["232","00","(?:[237-9]\\d|66)\\d{6}",[8],[["(\\d{2})(\\d{6})","$1 $2",["[236-9]"],"(0$1)"]],"0"],"SM":["378","00","(?:0549|[5-7]\\d)\\d{6}",[8,10],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-7]"]],["(\\d{4})(\\d{6})","$1 $2",["0"]]],0,0,"([89]\\d{5})$","0549$1"],"SN":["221","00","(?:[378]\\d|93)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"]],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[379]"]]]],"SO":["252","00","[346-9]\\d{8}|[12679]\\d{7}|[1-5]\\d{6}|[1348]\\d{5}",[6,7,8,9],[["(\\d{2})(\\d{4})","$1 $2",["8[125]"]],["(\\d{6})","$1",["[134]"]],["(\\d)(\\d{6})","$1 $2",["[15]|2[0-79]|3[0-46-8]|4[0-7]"]],["(\\d)(\\d{7})","$1 $2",["24|[67]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[3478]|64|90"]],["(\\d{2})(\\d{5,7})","$1 $2",["1|28|6(?:0[5-7]|[1-35-9])|9[2-9]"]]],"0"],"SR":["597","00","(?:[2-5]|68|[78]\\d)\\d{5}",[6,7],[["(\\d{2})(\\d{2})(\\d{2})","$1-$2-$3",["56"]],["(\\d{3})(\\d{3})","$1-$2",["[2-5]"]],["(\\d{3})(\\d{4})","$1-$2",["[6-8]"]]]],"SS":["211","00","[19]\\d{8}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[19]"],"0$1"]],"0"],"ST":["239","00","(?:22|9\\d)\\d{5}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[29]"]]]],"SV":["503","00","[267]\\d{7}|[89]00\\d{4}(?:\\d{4})?",[7,8,11],[["(\\d{3})(\\d{4})","$1 $2",["[89]"]],["(\\d{4})(\\d{4})","$1 $2",["[267]"]],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["[89]"]]]],"SX":["1","011","7215\\d{6}|(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"1|(5\\d{6})$","721$1",0,"721"],"SY":["963","00","[1-39]\\d{8}|[1-5]\\d{7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[1-5]"],"0$1",1],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["9"],"0$1",1]],"0"],"SZ":["268","00","0800\\d{4}|(?:[237]\\d|900)\\d{6}",[8,9],[["(\\d{4})(\\d{4})","$1 $2",["[0237]"]],["(\\d{5})(\\d{4})","$1 $2",["9"]]]],"TA":["290","00","8\\d{3}",[4],0,0,0,0,0,0,"8"],"TC":["1","011","(?:[58]\\d\\d|649|900)\\d{7}",[10],0,"1",0,"1|([2-479]\\d{6})$","649$1",0,"649"],"TD":["235","00|16","(?:22|[69]\\d|77)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2679]"]]],0,0,0,0,0,0,0,"00"],"TG":["228","00","[279]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[279]"]]]],"TH":["66","00[1-9]","(?:001800|[2-57]|[689]\\d)\\d{7}|1\\d{7,9}",[8,9,10,13],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[13-9]"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1"]]],"0"],"TJ":["992","810","(?:00|[1-57-9]\\d)\\d{7}",[9],[["(\\d{6})(\\d)(\\d{2})","$1 $2 $3",["331","3317"]],["(\\d{3})(\\d{2})(\\d{4})","$1 $2 $3",["[34]7|91[78]"]],["(\\d{4})(\\d)(\\d{4})","$1 $2 $3",["3[1-5]"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[0-57-9]"]]],0,0,0,0,0,0,0,"8~10"],"TK":["690","00","[2-47]\\d{3,6}",[4,5,6,7]],"TL":["670","00","7\\d{7}|(?:[2-47]\\d|[89]0)\\d{5}",[7,8],[["(\\d{3})(\\d{4})","$1 $2",["[2-489]|70"]],["(\\d{4})(\\d{4})","$1 $2",["7"]]]],"TM":["993","810","[1-6]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2-$3-$4",["12"],"(8 $1)"],["(\\d{3})(\\d)(\\d{2})(\\d{2})","$1 $2-$3-$4",["[1-5]"],"(8 $1)"],["(\\d{2})(\\d{6})","$1 $2",["6"],"8 $1"]],"8",0,0,0,0,0,0,"8~10"],"TN":["216","00","[2-57-9]\\d{7}",[8],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[2-57-9]"]]]],"TO":["676","00","(?:0800|(?:[5-8]\\d\\d|999)\\d)\\d{3}|[2-8]\\d{4}",[5,7],[["(\\d{2})(\\d{3})","$1-$2",["[2-4]|50|6[09]|7[0-24-69]|8[05]"]],["(\\d{4})(\\d{3})","$1 $2",["0"]],["(\\d{3})(\\d{4})","$1 $2",["[5-9]"]]]],"TR":["90","00","4\\d{6}|8\\d{11,12}|(?:[2-58]\\d\\d|900)\\d{7}",[7,10,12,13],[["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["512|8[01589]|90"],"0$1",1],["(\\d{3})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["5(?:[0-59]|61)","5(?:[0-59]|616)","5(?:[0-59]|6161)"],"0$1",1],["(\\d{3})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[24][1-8]|3[1-9]"],"(0$1)",1],["(\\d{3})(\\d{3})(\\d{6,7})","$1 $2 $3",["80"],"0$1",1]],"0"],"TT":["1","011","(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"1|([2-46-8]\\d{6})$","868$1",0,"868"],"TV":["688","00","(?:2|7\\d\\d|90)\\d{4}",[5,6,7],[["(\\d{2})(\\d{3})","$1 $2",["2"]],["(\\d{2})(\\d{4})","$1 $2",["90"]],["(\\d{2})(\\d{5})","$1 $2",["7"]]]],"TW":["886","0(?:0[25-79]|19)","[2-689]\\d{8}|7\\d{9,10}|[2-8]\\d{7}|2\\d{6}",[7,8,9,10,11],[["(\\d{2})(\\d)(\\d{4})","$1 $2 $3",["202"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[258]0"],"0$1"],["(\\d)(\\d{3,4})(\\d{4})","$1 $2 $3",["[23568]|4(?:0[02-48]|[1-47-9])|7[1-9]","[23568]|4(?:0[2-48]|[1-47-9])|(?:400|7)[1-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[49]"],"0$1"],["(\\d{2})(\\d{4})(\\d{4,5})","$1 $2 $3",["7"],"0$1"]],"0",0,0,0,0,0,0,0,"#"],"TZ":["255","00[056]","(?:[26-8]\\d|41|90)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{4})","$1 $2 $3",["[89]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[24]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[67]"],"0$1"]],"0"],"UA":["380","00","[89]\\d{9}|[3-9]\\d{8}",[9,10],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6[12][29]|(?:3[1-8]|4[136-8]|5[12457]|6[49])2|(?:56|65)[24]","6[12][29]|(?:35|4[1378]|5[12457]|6[49])2|(?:56|65)[24]|(?:3[1-46-8]|46)2[013-9]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["4[45][0-5]|5(?:0|6[37])|6(?:[12][018]|[36-8])|7|89|9[1-9]|(?:48|57)[0137-9]","4[45][0-5]|5(?:0|6(?:3[14-7]|7))|6(?:[12][018]|[36-8])|7|89|9[1-9]|(?:48|57)[0137-9]"],"0$1"],["(\\d{4})(\\d{5})","$1 $2",["[3-6]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["[89]"],"0$1"]],"0",0,0,0,0,0,0,"0~0"],"UG":["256","00[057]","800\\d{6}|(?:[29]0|[347]\\d)\\d{7}",[9],[["(\\d{4})(\\d{5})","$1 $2",["202","2024"],"0$1"],["(\\d{3})(\\d{6})","$1 $2",["[27-9]|4(?:6[45]|[7-9])"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["[34]"],"0$1"]],"0"],"US":["1","011","[2-9]\\d{9}",[10],[["(\\d{3})(\\d{3})(\\d{4})","($1) $2-$3",["[2-9]"],0,1,"$1-$2-$3"]],"1",0,0,0,0,0,[["5(?:05(?:[2-57-9]\\d\\d|6(?:[0-35-9]\\d|44))|82(?:2(?:0[0-3]|[268]2)|3(?:0[02]|33)|4(?:00|4[24]|65|82)|5(?:00|29|83)|6(?:00|66|82)|777|8(?:00|88)|9(?:00|9[89])))\\d{4}|(?:2(?:0[1-35-9]|1[02-9]|2[03-589]|3[149]|4[08]|5[1-46]|6[0279]|7[0269]|8[13])|3(?:0[1-57-9]|1[02-9]|2[01356]|3[0-24679]|4[167]|5[12]|6[014]|8[056])|4(?:0[124-9]|1[02-579]|2[3-5]|3[0245]|4[023578]|58|6[39]|7[0589]|8[04])|5(?:0[1-47-9]|1[0235-8]|20|3[0149]|4[01]|5[19]|6[1-47]|7[0-5]|8[056])|6(?:0[1-35-9]|1[024-9]|2[03689]|[34][016]|5[0179]|6[0-279]|78|8[0-29])|7(?:0[1-46-8]|1[2-9]|2[04-7]|3[1247]|4[037]|5[47]|6[02359]|7[0-59]|8[156])|8(?:0[1-68]|1[02-8]|2[08]|3[0-289]|4[03578]|5[046-9]|6[02-5]|7[028])|9(?:0[1346-9]|1[02-9]|2[0589]|3[0146-8]|4[01579]|5[12469]|7[0-389]|8[04-69]))[2-9]\\d{6}"],[""],["8(?:00|33|44|55|66|77|88)[2-9]\\d{6}"],["900[2-9]\\d{6}"],["52(?:3(?:[2-46-9][02-9]\\d|5(?:[02-46-9]\\d|5[0-46-9]))|4(?:[2-478][02-9]\\d|5(?:[034]\\d|2[024-9]|5[0-46-9])|6(?:0[1-9]|[2-9]\\d)|9(?:[05-9]\\d|2[0-5]|49)))\\d{4}|52[34][2-9]1[02-9]\\d{4}|5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}"]]],"UY":["598","0(?:0|1[3-9]\\d)","4\\d{9}|[1249]\\d{7}|(?:[49]\\d|80)\\d{5}",[7,8,10],[["(\\d{3})(\\d{4})","$1 $2",["405|8|90"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["9"],"0$1"],["(\\d{4})(\\d{4})","$1 $2",["[124]"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["4"],"0$1"]],"0",0,0,0,0,0,0,"00"," int. "],"UZ":["998","810","(?:33|55|[679]\\d|88)\\d{7}",[9],[["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[35-9]"],"8 $1"]],"8",0,0,0,0,0,0,"8~10"],"VA":["39","00","0\\d{5,10}|3[0-8]\\d{7,10}|55\\d{8}|8\\d{5}(?:\\d{2,4})?|(?:1\\d|39)\\d{7,8}",[6,7,8,9,10,11],0,0,0,0,0,0,"06698"],"VC":["1","011","(?:[58]\\d\\d|784|900)\\d{7}",[10],0,"1",0,"1|([2-7]\\d{6})$","784$1",0,"784"],"VE":["58","00","[68]00\\d{7}|(?:[24]\\d|[59]0)\\d{8}",[10],[["(\\d{3})(\\d{7})","$1-$2",["[24-689]"],"0$1"]],"0"],"VG":["1","011","(?:284|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"1|([2-578]\\d{6})$","284$1",0,"284"],"VI":["1","011","[58]\\d{9}|(?:34|90)0\\d{7}",[10],0,"1",0,"1|([2-9]\\d{6})$","340$1",0,"340"],"VN":["84","00","[12]\\d{9}|[135-9]\\d{8}|[16]\\d{7}|[16-8]\\d{6}",[7,8,9,10],[["(\\d{2})(\\d{5})","$1 $2",["80"],"0$1",1],["(\\d{4})(\\d{4,6})","$1 $2",["1"],0,1],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[69]"],"0$1",1],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[3578]"],"0$1",1],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["2[48]"],"0$1",1],["(\\d{3})(\\d{4})(\\d{3})","$1 $2 $3",["2"],"0$1",1]],"0"],"VU":["678","00","[57-9]\\d{6}|(?:[238]\\d|48)\\d{3}",[5,7],[["(\\d{3})(\\d{4})","$1 $2",["[57-9]"]]]],"WF":["681","00","(?:40|72)\\d{4}|8\\d{5}(?:\\d{3})?",[6,9],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["[478]"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"]]]],"WS":["685","0","(?:[2-6]|8\\d{5})\\d{4}|[78]\\d{6}|[68]\\d{5}",[5,6,7,10],[["(\\d{5})","$1",["[2-5]|6[1-9]"]],["(\\d{3})(\\d{3,7})","$1 $2",["[68]"]],["(\\d{2})(\\d{5})","$1 $2",["7"]]]],"XK":["383","00","[23]\\d{7,8}|(?:4\\d\\d|[89]00)\\d{5}",[8,9],[["(\\d{3})(\\d{5})","$1 $2",["[89]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[2-4]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[23]"],"0$1"]],"0"],"YE":["967","00","(?:1|7\\d)\\d{7}|[1-7]\\d{6}",[7,8,9],[["(\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["[1-6]|7[24-68]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["7"],"0$1"]],"0"],"YT":["262","00","80\\d{7}|(?:26|63)9\\d{6}",[9],0,"0",0,0,0,0,"269|63"],"ZA":["27","00","[1-79]\\d{8}|8\\d{4,9}",[5,6,7,8,9,10],[["(\\d{2})(\\d{3,4})","$1 $2",["8[1-4]"],"0$1"],["(\\d{2})(\\d{3})(\\d{2,3})","$1 $2 $3",["8[1-4]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["860"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[1-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"],"0$1"]],"0"],"ZM":["260","00","(?:63|80)0\\d{6}|(?:21|[79]\\d)\\d{7}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[28]"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["[79]"],"0$1"]],"0"],"ZW":["263","00","2(?:[0-57-9]\\d{6,8}|6[0-24-9]\\d{6,7})|[38]\\d{9}|[35-8]\\d{8}|[3-6]\\d{7}|[1-689]\\d{6}|[1-3569]\\d{5}|[1356]\\d{4}",[5,6,7,8,9,10],[["(\\d{3})(\\d{3,5})","$1 $2",["2(?:0[45]|2[278]|[49]8)|3(?:[09]8|17)|6(?:[29]8|37|75)|[23][78]|(?:33|5[15]|6[68])[78]"],"0$1"],["(\\d)(\\d{3})(\\d{2,4})","$1 $2 $3",["[49]"],"0$1"],["(\\d{3})(\\d{4})","$1 $2",["80"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["24|8[13-59]|(?:2[05-79]|39|5[45]|6[15-8])2","2(?:02[014]|4|[56]20|[79]2)|392|5(?:42|525)|6(?:[16-8]21|52[013])|8[13-59]"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["2(?:1[39]|2[0157]|[378]|[56][14])|3(?:12|29)","2(?:1[39]|2[0157]|[378]|[56][14])|3(?:123|29)"],"0$1"],["(\\d{4})(\\d{6})","$1 $2",["8"],"0$1"],["(\\d{2})(\\d{3,5})","$1 $2",["1|2(?:0[0-36-9]|12|29|[56])|3(?:1[0-689]|[24-6])|5(?:[0236-9]|1[2-4])|6(?:[013-59]|7[0-46-9])|(?:33|55|6[68])[0-69]|(?:29|3[09]|62)[0-79]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["29[013-9]|39|54"],"0$1"],["(\\d{4})(\\d{3,5})","$1 $2",["(?:25|54)8","258|5483"],"0$1"]],"0"]},"nonGeographic":{"800":["800",0,"(?:005|[1-9]\\d\\d)\\d{5}",[8],[["(\\d{4})(\\d{4})","$1 $2",["\\d"]]],0,0,0,0,0,0,[0,0,["(?:005|[1-9]\\d\\d)\\d{5}"]]],"808":["808",0,"[1-9]\\d{7}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[1-9]"]]],0,0,0,0,0,0,[0,0,0,0,0,0,0,0,0,["[1-9]\\d{7}"]]],"870":["870",0,"7\\d{11}|[35-7]\\d{8}",[9,12],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[35-7]"]]],0,0,0,0,0,0,[0,["(?:[356]|774[45])\\d{8}|7[6-8]\\d{7}"]]],"878":["878",0,"10\\d{10}",[12],[["(\\d{2})(\\d{5})(\\d{5})","$1 $2 $3",["1"]]],0,0,0,0,0,0,[0,0,0,0,0,0,0,0,["10\\d{10}"]]],"881":["881",0,"[0-36-9]\\d{8}",[9],[["(\\d)(\\d{3})(\\d{5})","$1 $2 $3",["[0-36-9]"]]],0,0,0,0,0,0,[0,["[0-36-9]\\d{8}"]]],"882":["882",0,"[13]\\d{6}(?:\\d{2,5})?|285\\d{9}|(?:[19]\\d|49)\\d{6}",[7,8,9,10,11,12],[["(\\d{2})(\\d{5})","$1 $2",["16|342"]],["(\\d{2})(\\d{6})","$1 $2",["4"]],["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["[19]"]],["(\\d{2})(\\d{4})(\\d{3})","$1 $2 $3",["3[23]"]],["(\\d{2})(\\d{3,4})(\\d{4})","$1 $2 $3",["1"]],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["34[57]"]],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["34"]],["(\\d{2})(\\d{4,5})(\\d{5})","$1 $2 $3",["[1-3]"]]],0,0,0,0,0,0,[0,["342\\d{4}|(?:337|49)\\d{6}|3(?:2|47|7\\d{3})\\d{7}",[7,8,9,10,12]],0,0,0,0,0,0,["1(?:3(?:0[0347]|[13][0139]|2[035]|4[013568]|6[0459]|7[06]|8[15-8]|9[0689])\\d{4}|6\\d{5,10})|(?:(?:285\\d\\d|3(?:45|[69]\\d{3}))\\d|9[89])\\d{6}"]]],"883":["883",0,"210\\d{7}|51\\d{7}(?:\\d{3})?",[9,10,12],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["510"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["2"]],["(\\d{3})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["510"]],["(\\d{4})(\\d{4})(\\d{4})","$1 $2 $3",["5"]]],0,0,0,0,0,0,[0,0,0,0,0,0,0,0,["(?:210|51[013]0\\d)\\d{7}|5100\\d{5}"]]],"888":["888",0,"\\d{11}",[11],[["(\\d{3})(\\d{3})(\\d{5})","$1 $2 $3"]],0,0,0,0,0,0,[0,0,0,0,0,0,["\\d{11}"]]],"979":["979",0,"[1359]\\d{8}",[9],[["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["[1359]"]]],0,0,0,0,0,0,[0,0,0,["[1359]\\d{8}"]]]}};
4866
4867 // Importing from `.json.js` a workaround for a bug in web browsers' "native"
4868
4869 function withMetadata(func, _arguments) {
4870 var args = Array.prototype.slice.call(_arguments);
4871 args.push(metadata);
4872 return func.apply(this, args)
4873 }
4874
4875 function _classCallCheck$2(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4876
4877 // https://stackoverflow.com/a/46971044/970769
4878 var ParseError = function ParseError(code) {
4879 _classCallCheck$2(this, ParseError);
4880
4881 this.name = this.constructor.name;
4882 this.message = code;
4883 this.stack = new Error(code).stack;
4884 };
4885 ParseError.prototype = Object.create(Error.prototype);
4886 ParseError.prototype.constructor = ParseError;
4887
4888 // The minimum length of the national significant number.
4889 var MIN_LENGTH_FOR_NSN = 2; // The ITU says the maximum length should be 15,
4890 // but one can find longer numbers in Germany.
4891
4892 var MAX_LENGTH_FOR_NSN = 17; // The maximum length of the country calling code.
4893
4894 var MAX_LENGTH_COUNTRY_CODE = 3; // Digits accepted in phone numbers
4895 // (ascii, fullwidth, arabic-indic, and eastern arabic digits).
4896
4897 var VALID_DIGITS = "0-9\uFF10-\uFF19\u0660-\u0669\u06F0-\u06F9"; // `DASHES` will be right after the opening square bracket of the "character class"
4898
4899 var DASHES = "-\u2010-\u2015\u2212\u30FC\uFF0D";
4900 var SLASHES = "\uFF0F/";
4901 var DOTS = "\uFF0E.";
4902 var WHITESPACE = " \xA0\xAD\u200B\u2060\u3000";
4903 var BRACKETS = "()\uFF08\uFF09\uFF3B\uFF3D\\[\\]"; // export const OPENING_BRACKETS = '(\uFF08\uFF3B\\\['
4904
4905 var TILDES = "~\u2053\u223C\uFF5E"; // Regular expression of acceptable punctuation found in phone numbers. This
4906 // excludes punctuation found as a leading character only. This consists of dash
4907 // characters, white space characters, full stops, slashes, square brackets,
4908 // parentheses and tildes. Full-width variants are also present.
4909
4910 var VALID_PUNCTUATION = "".concat(DASHES).concat(SLASHES).concat(DOTS).concat(WHITESPACE).concat(BRACKETS).concat(TILDES);
4911 var PLUS_CHARS = "+\uFF0B"; // const LEADING_PLUS_CHARS_PATTERN = new RegExp('^[' + PLUS_CHARS + ']+')
4912
4913 // Copy-pasted from:
4914 // https://github.com/substack/semver-compare/blob/master/index.js
4915 //
4916 // Inlining this function because some users reported issues with
4917 // importing from `semver-compare` in a browser with ES6 "native" modules.
4918 //
4919 // Fixes `semver-compare` not being able to compare versions with alpha/beta/etc "tags".
4920 // https://github.com/catamphetamine/libphonenumber-js/issues/381
4921 function compare (a, b) {
4922 a = a.split('-');
4923 b = b.split('-');
4924 var pa = a[0].split('.');
4925 var pb = b[0].split('.');
4926
4927 for (var i = 0; i < 3; i++) {
4928 var na = Number(pa[i]);
4929 var nb = Number(pb[i]);
4930 if (na > nb) return 1;
4931 if (nb > na) return -1;
4932 if (!isNaN(na) && isNaN(nb)) return 1;
4933 if (isNaN(na) && !isNaN(nb)) return -1;
4934 }
4935
4936 if (a[1] && b[1]) {
4937 return a[1] > b[1] ? 1 : a[1] < b[1] ? -1 : 0;
4938 }
4939
4940 return !a[1] && b[1] ? 1 : a[1] && !b[1] ? -1 : 0;
4941 }
4942
4943 function _typeof$1(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$1 = function _typeof(obj) { return typeof obj; }; } else { _typeof$1 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$1(obj); }
4944
4945 function _classCallCheck$1(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4946
4947 function _defineProperties$1(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
4948
4949 function _createClass$1(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$1(Constructor.prototype, protoProps); if (staticProps) _defineProperties$1(Constructor, staticProps); return Constructor; }
4950
4951 var V3 = '1.2.0'; // Moved `001` country code to "nonGeographic" section of metadata.
4952
4953 var V4 = '1.7.35';
4954 var DEFAULT_EXT_PREFIX = ' ext. ';
4955 var CALLING_CODE_REG_EXP = /^\d+$/;
4956 /**
4957 * See: https://gitlab.com/catamphetamine/libphonenumber-js/blob/master/METADATA.md
4958 */
4959
4960 var Metadata =
4961 /*#__PURE__*/
4962 function () {
4963 function Metadata(metadata) {
4964 _classCallCheck$1(this, Metadata);
4965
4966 validateMetadata(metadata);
4967 this.metadata = metadata;
4968 setVersion.call(this, metadata);
4969 }
4970
4971 _createClass$1(Metadata, [{
4972 key: "getCountries",
4973 value: function getCountries() {
4974 return Object.keys(this.metadata.countries).filter(function (_) {
4975 return _ !== '001';
4976 });
4977 }
4978 }, {
4979 key: "getCountryMetadata",
4980 value: function getCountryMetadata(countryCode) {
4981 return this.metadata.countries[countryCode];
4982 }
4983 }, {
4984 key: "nonGeographic",
4985 value: function nonGeographic() {
4986 if (this.v1 || this.v2 || this.v3) return; // `nonGeographical` was a typo.
4987 // It's present in metadata generated from `1.7.35` to `1.7.37`.
4988
4989 return this.metadata.nonGeographic || this.metadata.nonGeographical;
4990 }
4991 }, {
4992 key: "hasCountry",
4993 value: function hasCountry(country) {
4994 return this.getCountryMetadata(country) !== undefined;
4995 }
4996 }, {
4997 key: "hasCallingCode",
4998 value: function hasCallingCode(callingCode) {
4999 if (this.getCountryCodesForCallingCode(callingCode)) {
5000 return true;
5001 }
5002
5003 if (this.nonGeographic()) {
5004 if (this.nonGeographic()[callingCode]) {
5005 return true;
5006 }
5007 } else {
5008 // A hacky workaround for old custom metadata (generated before V4).
5009 var countryCodes = this.countryCallingCodes()[callingCode];
5010
5011 if (countryCodes && countryCodes.length === 1 && countryCodes[0] === '001') {
5012 return true;
5013 }
5014 }
5015 }
5016 }, {
5017 key: "isNonGeographicCallingCode",
5018 value: function isNonGeographicCallingCode(callingCode) {
5019 if (this.nonGeographic()) {
5020 return this.nonGeographic()[callingCode] ? true : false;
5021 } else {
5022 return this.getCountryCodesForCallingCode(callingCode) ? false : true;
5023 }
5024 } // Deprecated.
5025
5026 }, {
5027 key: "country",
5028 value: function country(countryCode) {
5029 return this.selectNumberingPlan(countryCode);
5030 }
5031 }, {
5032 key: "selectNumberingPlan",
5033 value: function selectNumberingPlan(countryCode, callingCode) {
5034 // Supports just passing `callingCode` as the first argument.
5035 if (countryCode && CALLING_CODE_REG_EXP.test(countryCode)) {
5036 callingCode = countryCode;
5037 countryCode = null;
5038 }
5039
5040 if (countryCode && countryCode !== '001') {
5041 if (!this.hasCountry(countryCode)) {
5042 throw new Error("Unknown country: ".concat(countryCode));
5043 }
5044
5045 this.numberingPlan = new NumberingPlan(this.getCountryMetadata(countryCode), this);
5046 } else if (callingCode) {
5047 if (!this.hasCallingCode(callingCode)) {
5048 throw new Error("Unknown calling code: ".concat(callingCode));
5049 }
5050
5051 this.numberingPlan = new NumberingPlan(this.getNumberingPlanMetadata(callingCode), this);
5052 } else {
5053 this.numberingPlan = undefined;
5054 }
5055
5056 return this;
5057 }
5058 }, {
5059 key: "getCountryCodesForCallingCode",
5060 value: function getCountryCodesForCallingCode(callingCode) {
5061 var countryCodes = this.countryCallingCodes()[callingCode];
5062
5063 if (countryCodes) {
5064 // Metadata before V4 included "non-geographic entity" calling codes
5065 // inside `country_calling_codes` (for example, `"881":["001"]`).
5066 // Now the semantics of `country_calling_codes` has changed:
5067 // it's specifically for "countries" now.
5068 // Older versions of custom metadata will simply skip parsing
5069 // "non-geographic entity" phone numbers with new versions
5070 // of this library: it's not considered a bug,
5071 // because such numbers are extremely rare,
5072 // and developers extremely rarely use custom metadata.
5073 if (countryCodes.length === 1 && countryCodes[0].length === 3) {
5074 return;
5075 }
5076
5077 return countryCodes;
5078 }
5079 }
5080 }, {
5081 key: "getCountryCodeForCallingCode",
5082 value: function getCountryCodeForCallingCode(callingCode) {
5083 var countryCodes = this.getCountryCodesForCallingCode(callingCode);
5084
5085 if (countryCodes) {
5086 return countryCodes[0];
5087 }
5088 }
5089 }, {
5090 key: "getNumberingPlanMetadata",
5091 value: function getNumberingPlanMetadata(callingCode) {
5092 var countryCode = this.getCountryCodeForCallingCode(callingCode);
5093
5094 if (countryCode) {
5095 return this.getCountryMetadata(countryCode);
5096 }
5097
5098 if (this.nonGeographic()) {
5099 var metadata = this.nonGeographic()[callingCode];
5100
5101 if (metadata) {
5102 return metadata;
5103 }
5104 } else {
5105 // A hacky workaround for old custom metadata (generated before V4).
5106 var countryCodes = this.countryCallingCodes()[callingCode];
5107
5108 if (countryCodes && countryCodes.length === 1 && countryCodes[0] === '001') {
5109 return this.metadata.countries['001'];
5110 }
5111 }
5112 } // Deprecated.
5113
5114 }, {
5115 key: "countryCallingCode",
5116 value: function countryCallingCode() {
5117 return this.numberingPlan.callingCode();
5118 } // Deprecated.
5119
5120 }, {
5121 key: "IDDPrefix",
5122 value: function IDDPrefix() {
5123 return this.numberingPlan.IDDPrefix();
5124 } // Deprecated.
5125
5126 }, {
5127 key: "defaultIDDPrefix",
5128 value: function defaultIDDPrefix() {
5129 return this.numberingPlan.defaultIDDPrefix();
5130 } // Deprecated.
5131
5132 }, {
5133 key: "nationalNumberPattern",
5134 value: function nationalNumberPattern() {
5135 return this.numberingPlan.nationalNumberPattern();
5136 } // Deprecated.
5137
5138 }, {
5139 key: "possibleLengths",
5140 value: function possibleLengths() {
5141 return this.numberingPlan.possibleLengths();
5142 } // Deprecated.
5143
5144 }, {
5145 key: "formats",
5146 value: function formats() {
5147 return this.numberingPlan.formats();
5148 } // Deprecated.
5149
5150 }, {
5151 key: "nationalPrefixForParsing",
5152 value: function nationalPrefixForParsing() {
5153 return this.numberingPlan.nationalPrefixForParsing();
5154 } // Deprecated.
5155
5156 }, {
5157 key: "nationalPrefixTransformRule",
5158 value: function nationalPrefixTransformRule() {
5159 return this.numberingPlan.nationalPrefixTransformRule();
5160 } // Deprecated.
5161
5162 }, {
5163 key: "leadingDigits",
5164 value: function leadingDigits() {
5165 return this.numberingPlan.leadingDigits();
5166 } // Deprecated.
5167
5168 }, {
5169 key: "hasTypes",
5170 value: function hasTypes() {
5171 return this.numberingPlan.hasTypes();
5172 } // Deprecated.
5173
5174 }, {
5175 key: "type",
5176 value: function type(_type) {
5177 return this.numberingPlan.type(_type);
5178 } // Deprecated.
5179
5180 }, {
5181 key: "ext",
5182 value: function ext() {
5183 return this.numberingPlan.ext();
5184 }
5185 }, {
5186 key: "countryCallingCodes",
5187 value: function countryCallingCodes() {
5188 if (this.v1) return this.metadata.country_phone_code_to_countries;
5189 return this.metadata.country_calling_codes;
5190 } // Deprecated.
5191
5192 }, {
5193 key: "chooseCountryByCountryCallingCode",
5194 value: function chooseCountryByCountryCallingCode(callingCode) {
5195 return this.selectNumberingPlan(callingCode);
5196 }
5197 }, {
5198 key: "hasSelectedNumberingPlan",
5199 value: function hasSelectedNumberingPlan() {
5200 return this.numberingPlan !== undefined;
5201 }
5202 }]);
5203
5204 return Metadata;
5205 }();
5206
5207 var NumberingPlan =
5208 /*#__PURE__*/
5209 function () {
5210 function NumberingPlan(metadata, globalMetadataObject) {
5211 _classCallCheck$1(this, NumberingPlan);
5212
5213 this.globalMetadataObject = globalMetadataObject;
5214 this.metadata = metadata;
5215 setVersion.call(this, globalMetadataObject.metadata);
5216 }
5217
5218 _createClass$1(NumberingPlan, [{
5219 key: "callingCode",
5220 value: function callingCode() {
5221 return this.metadata[0];
5222 } // Formatting information for regions which share
5223 // a country calling code is contained by only one region
5224 // for performance reasons. For example, for NANPA region
5225 // ("North American Numbering Plan Administration",
5226 // which includes USA, Canada, Cayman Islands, Bahamas, etc)
5227 // it will be contained in the metadata for `US`.
5228
5229 }, {
5230 key: "getDefaultCountryMetadataForRegion",
5231 value: function getDefaultCountryMetadataForRegion() {
5232 return this.globalMetadataObject.getNumberingPlanMetadata(this.callingCode());
5233 } // Is always present.
5234
5235 }, {
5236 key: "IDDPrefix",
5237 value: function IDDPrefix() {
5238 if (this.v1 || this.v2) return;
5239 return this.metadata[1];
5240 } // Is only present when a country supports multiple IDD prefixes.
5241
5242 }, {
5243 key: "defaultIDDPrefix",
5244 value: function defaultIDDPrefix() {
5245 if (this.v1 || this.v2) return;
5246 return this.metadata[12];
5247 }
5248 }, {
5249 key: "nationalNumberPattern",
5250 value: function nationalNumberPattern() {
5251 if (this.v1 || this.v2) return this.metadata[1];
5252 return this.metadata[2];
5253 } // Is always present.
5254
5255 }, {
5256 key: "possibleLengths",
5257 value: function possibleLengths() {
5258 if (this.v1) return;
5259 return this.metadata[this.v2 ? 2 : 3];
5260 }
5261 }, {
5262 key: "_getFormats",
5263 value: function _getFormats(metadata) {
5264 return metadata[this.v1 ? 2 : this.v2 ? 3 : 4];
5265 } // For countries of the same region (e.g. NANPA)
5266 // formats are all stored in the "main" country for that region.
5267 // E.g. "RU" and "KZ", "US" and "CA".
5268
5269 }, {
5270 key: "formats",
5271 value: function formats() {
5272 var _this = this;
5273
5274 var formats = this._getFormats(this.metadata) || this._getFormats(this.getDefaultCountryMetadataForRegion()) || [];
5275 return formats.map(function (_) {
5276 return new Format(_, _this);
5277 });
5278 }
5279 }, {
5280 key: "nationalPrefix",
5281 value: function nationalPrefix() {
5282 return this.metadata[this.v1 ? 3 : this.v2 ? 4 : 5];
5283 }
5284 }, {
5285 key: "_getNationalPrefixFormattingRule",
5286 value: function _getNationalPrefixFormattingRule(metadata) {
5287 return metadata[this.v1 ? 4 : this.v2 ? 5 : 6];
5288 } // For countries of the same region (e.g. NANPA)
5289 // national prefix formatting rule is stored in the "main" country for that region.
5290 // E.g. "RU" and "KZ", "US" and "CA".
5291
5292 }, {
5293 key: "nationalPrefixFormattingRule",
5294 value: function nationalPrefixFormattingRule() {
5295 return this._getNationalPrefixFormattingRule(this.metadata) || this._getNationalPrefixFormattingRule(this.getDefaultCountryMetadataForRegion());
5296 }
5297 }, {
5298 key: "_nationalPrefixForParsing",
5299 value: function _nationalPrefixForParsing() {
5300 return this.metadata[this.v1 ? 5 : this.v2 ? 6 : 7];
5301 }
5302 }, {
5303 key: "nationalPrefixForParsing",
5304 value: function nationalPrefixForParsing() {
5305 // If `national_prefix_for_parsing` is not set explicitly,
5306 // then infer it from `national_prefix` (if any)
5307 return this._nationalPrefixForParsing() || this.nationalPrefix();
5308 }
5309 }, {
5310 key: "nationalPrefixTransformRule",
5311 value: function nationalPrefixTransformRule() {
5312 return this.metadata[this.v1 ? 6 : this.v2 ? 7 : 8];
5313 }
5314 }, {
5315 key: "_getNationalPrefixIsOptionalWhenFormatting",
5316 value: function _getNationalPrefixIsOptionalWhenFormatting() {
5317 return !!this.metadata[this.v1 ? 7 : this.v2 ? 8 : 9];
5318 } // For countries of the same region (e.g. NANPA)
5319 // "national prefix is optional when formatting" flag is
5320 // stored in the "main" country for that region.
5321 // E.g. "RU" and "KZ", "US" and "CA".
5322
5323 }, {
5324 key: "nationalPrefixIsOptionalWhenFormattingInNationalFormat",
5325 value: function nationalPrefixIsOptionalWhenFormattingInNationalFormat() {
5326 return this._getNationalPrefixIsOptionalWhenFormatting(this.metadata) || this._getNationalPrefixIsOptionalWhenFormatting(this.getDefaultCountryMetadataForRegion());
5327 }
5328 }, {
5329 key: "leadingDigits",
5330 value: function leadingDigits() {
5331 return this.metadata[this.v1 ? 8 : this.v2 ? 9 : 10];
5332 }
5333 }, {
5334 key: "types",
5335 value: function types() {
5336 return this.metadata[this.v1 ? 9 : this.v2 ? 10 : 11];
5337 }
5338 }, {
5339 key: "hasTypes",
5340 value: function hasTypes() {
5341 // Versions 1.2.0 - 1.2.4: can be `[]`.
5342
5343 /* istanbul ignore next */
5344 if (this.types() && this.types().length === 0) {
5345 return false;
5346 } // Versions <= 1.2.4: can be `undefined`.
5347 // Version >= 1.2.5: can be `0`.
5348
5349
5350 return !!this.types();
5351 }
5352 }, {
5353 key: "type",
5354 value: function type(_type2) {
5355 if (this.hasTypes() && getType(this.types(), _type2)) {
5356 return new Type(getType(this.types(), _type2), this);
5357 }
5358 }
5359 }, {
5360 key: "ext",
5361 value: function ext() {
5362 if (this.v1 || this.v2) return DEFAULT_EXT_PREFIX;
5363 return this.metadata[13] || DEFAULT_EXT_PREFIX;
5364 }
5365 }]);
5366
5367 return NumberingPlan;
5368 }();
5369
5370 var Format =
5371 /*#__PURE__*/
5372 function () {
5373 function Format(format, metadata) {
5374 _classCallCheck$1(this, Format);
5375
5376 this._format = format;
5377 this.metadata = metadata;
5378 }
5379
5380 _createClass$1(Format, [{
5381 key: "pattern",
5382 value: function pattern() {
5383 return this._format[0];
5384 }
5385 }, {
5386 key: "format",
5387 value: function format() {
5388 return this._format[1];
5389 }
5390 }, {
5391 key: "leadingDigitsPatterns",
5392 value: function leadingDigitsPatterns() {
5393 return this._format[2] || [];
5394 }
5395 }, {
5396 key: "nationalPrefixFormattingRule",
5397 value: function nationalPrefixFormattingRule() {
5398 return this._format[3] || this.metadata.nationalPrefixFormattingRule();
5399 }
5400 }, {
5401 key: "nationalPrefixIsOptionalWhenFormattingInNationalFormat",
5402 value: function nationalPrefixIsOptionalWhenFormattingInNationalFormat() {
5403 return !!this._format[4] || this.metadata.nationalPrefixIsOptionalWhenFormattingInNationalFormat();
5404 }
5405 }, {
5406 key: "nationalPrefixIsMandatoryWhenFormattingInNationalFormat",
5407 value: function nationalPrefixIsMandatoryWhenFormattingInNationalFormat() {
5408 // National prefix is omitted if there's no national prefix formatting rule
5409 // set for this country, or when the national prefix formatting rule
5410 // contains no national prefix itself, or when this rule is set but
5411 // national prefix is optional for this phone number format
5412 // (and it is not enforced explicitly)
5413 return this.usesNationalPrefix() && !this.nationalPrefixIsOptionalWhenFormattingInNationalFormat();
5414 } // Checks whether national prefix formatting rule contains national prefix.
5415
5416 }, {
5417 key: "usesNationalPrefix",
5418 value: function usesNationalPrefix() {
5419 return this.nationalPrefixFormattingRule() && // Check that national prefix formatting rule is not a "dummy" one.
5420 !FIRST_GROUP_ONLY_PREFIX_PATTERN.test(this.nationalPrefixFormattingRule()) // In compressed metadata, `this.nationalPrefixFormattingRule()` is `0`
5421 // when `national_prefix_formatting_rule` is not present.
5422 // So, `true` or `false` are returned explicitly here, so that
5423 // `0` number isn't returned.
5424 ? true : false;
5425 }
5426 }, {
5427 key: "internationalFormat",
5428 value: function internationalFormat() {
5429 return this._format[5] || this.format();
5430 }
5431 }]);
5432
5433 return Format;
5434 }();
5435 /**
5436 * A pattern that is used to determine if the national prefix formatting rule
5437 * has the first group only, i.e., does not start with the national prefix.
5438 * Note that the pattern explicitly allows for unbalanced parentheses.
5439 */
5440
5441
5442 var FIRST_GROUP_ONLY_PREFIX_PATTERN = /^\(?\$1\)?$/;
5443
5444 var Type =
5445 /*#__PURE__*/
5446 function () {
5447 function Type(type, metadata) {
5448 _classCallCheck$1(this, Type);
5449
5450 this.type = type;
5451 this.metadata = metadata;
5452 }
5453
5454 _createClass$1(Type, [{
5455 key: "pattern",
5456 value: function pattern() {
5457 if (this.metadata.v1) return this.type;
5458 return this.type[0];
5459 }
5460 }, {
5461 key: "possibleLengths",
5462 value: function possibleLengths() {
5463 if (this.metadata.v1) return;
5464 return this.type[1] || this.metadata.possibleLengths();
5465 }
5466 }]);
5467
5468 return Type;
5469 }();
5470
5471 function getType(types, type) {
5472 switch (type) {
5473 case 'FIXED_LINE':
5474 return types[0];
5475
5476 case 'MOBILE':
5477 return types[1];
5478
5479 case 'TOLL_FREE':
5480 return types[2];
5481
5482 case 'PREMIUM_RATE':
5483 return types[3];
5484
5485 case 'PERSONAL_NUMBER':
5486 return types[4];
5487
5488 case 'VOICEMAIL':
5489 return types[5];
5490
5491 case 'UAN':
5492 return types[6];
5493
5494 case 'PAGER':
5495 return types[7];
5496
5497 case 'VOIP':
5498 return types[8];
5499
5500 case 'SHARED_COST':
5501 return types[9];
5502 }
5503 }
5504
5505 function validateMetadata(metadata) {
5506 if (!metadata) {
5507 throw new Error('[libphonenumber-js] `metadata` argument not passed. Check your arguments.');
5508 } // `country_phone_code_to_countries` was renamed to
5509 // `country_calling_codes` in `1.0.18`.
5510
5511
5512 if (!is_object(metadata) || !is_object(metadata.countries)) {
5513 throw new Error("[libphonenumber-js] `metadata` argument was passed but it's not a valid metadata. Must be an object having `.countries` child object property. Got ".concat(is_object(metadata) ? 'an object of shape: { ' + Object.keys(metadata).join(', ') + ' }' : 'a ' + type_of(metadata) + ': ' + metadata, "."));
5514 }
5515 } // Babel transforms `typeof` into some "branches"
5516 // so istanbul will show this as "branch not covered".
5517
5518 /* istanbul ignore next */
5519
5520 var is_object = function is_object(_) {
5521 return _typeof$1(_) === 'object';
5522 }; // Babel transforms `typeof` into some "branches"
5523 // so istanbul will show this as "branch not covered".
5524
5525 /* istanbul ignore next */
5526
5527
5528 var type_of = function type_of(_) {
5529 return _typeof$1(_);
5530 };
5531 /**
5532 * Returns "country calling code" for a country.
5533 * Throws an error if the country doesn't exist or isn't supported by this library.
5534 * @param {string} country
5535 * @param {object} metadata
5536 * @return {string}
5537 * @example
5538 * // Returns "44"
5539 * getCountryCallingCode("GB")
5540 */
5541
5542 function getCountryCallingCode(country, metadata) {
5543 metadata = new Metadata(metadata);
5544
5545 if (metadata.hasCountry(country)) {
5546 return metadata.country(country).countryCallingCode();
5547 }
5548
5549 throw new Error("Unknown country: ".concat(country));
5550 }
5551 function isSupportedCountry(country, metadata) {
5552 // metadata = new Metadata(metadata)
5553 // return metadata.hasCountry(country)
5554 return metadata.countries[country] !== undefined;
5555 }
5556
5557 function setVersion(metadata) {
5558 var version = metadata.version;
5559
5560 if (typeof version === 'number') {
5561 this.v1 = version === 1;
5562 this.v2 = version === 2;
5563 this.v3 = version === 3;
5564 this.v4 = version === 4;
5565 } else {
5566 if (!version) {
5567 this.v1 = true;
5568 } else if (compare(version, V3) === -1) {
5569 this.v2 = true;
5570 } else if (compare(version, V4) === -1) {
5571 this.v3 = true;
5572 } else {
5573 this.v4 = true;
5574 }
5575 }
5576 } // const ISO_COUNTRY_CODE = /^[A-Z]{2}$/
5577 // function isCountryCode(countryCode) {
5578 // return ISO_COUNTRY_CODE.test(countryCodeOrCountryCallingCode)
5579 // }
5580
5581 var RFC3966_EXTN_PREFIX = ';ext=';
5582 /**
5583 * Helper method for constructing regular expressions for parsing. Creates
5584 * an expression that captures up to max_length digits.
5585 * @return {string} RegEx pattern to capture extension digits.
5586 */
5587
5588 var getExtensionDigitsPattern = function getExtensionDigitsPattern(maxLength) {
5589 return "([".concat(VALID_DIGITS, "]{1,").concat(maxLength, "})");
5590 };
5591 /**
5592 * Helper initialiser method to create the regular-expression pattern to match
5593 * extensions.
5594 * Copy-pasted from Google's `libphonenumber`:
5595 * https://github.com/google/libphonenumber/blob/55b2646ec9393f4d3d6661b9c82ef9e258e8b829/javascript/i18n/phonenumbers/phonenumberutil.js#L759-L766
5596 * @return {string} RegEx pattern to capture extensions.
5597 */
5598
5599
5600 function createExtensionPattern(purpose) {
5601 // We cap the maximum length of an extension based on the ambiguity of the way
5602 // the extension is prefixed. As per ITU, the officially allowed length for
5603 // extensions is actually 40, but we don't support this since we haven't seen real
5604 // examples and this introduces many false interpretations as the extension labels
5605 // are not standardized.
5606
5607 /** @type {string} */
5608 var extLimitAfterExplicitLabel = '20';
5609 /** @type {string} */
5610
5611 var extLimitAfterLikelyLabel = '15';
5612 /** @type {string} */
5613
5614 var extLimitAfterAmbiguousChar = '9';
5615 /** @type {string} */
5616
5617 var extLimitWhenNotSure = '6';
5618 /** @type {string} */
5619
5620 var possibleSeparatorsBetweenNumberAndExtLabel = "[ \xA0\\t,]*"; // Optional full stop (.) or colon, followed by zero or more spaces/tabs/commas.
5621
5622 /** @type {string} */
5623
5624 var possibleCharsAfterExtLabel = "[:\\.\uFF0E]?[ \xA0\\t,-]*";
5625 /** @type {string} */
5626
5627 var optionalExtnSuffix = "#?"; // Here the extension is called out in more explicit way, i.e mentioning it obvious
5628 // patterns like "ext.".
5629
5630 /** @type {string} */
5631
5632 var explicitExtLabels = "(?:e?xt(?:ensi(?:o\u0301?|\xF3))?n?|\uFF45?\uFF58\uFF54\uFF4E?|\u0434\u043E\u0431|anexo)"; // One-character symbols that can be used to indicate an extension, and less
5633 // commonly used or more ambiguous extension labels.
5634
5635 /** @type {string} */
5636
5637 var ambiguousExtLabels = "(?:[x\uFF58#\uFF03~\uFF5E]|int|\uFF49\uFF4E\uFF54)"; // When extension is not separated clearly.
5638
5639 /** @type {string} */
5640
5641 var ambiguousSeparator = "[- ]+"; // This is the same as possibleSeparatorsBetweenNumberAndExtLabel, but not matching
5642 // comma as extension label may have it.
5643
5644 /** @type {string} */
5645
5646 var possibleSeparatorsNumberExtLabelNoComma = "[ \xA0\\t]*"; // ",," is commonly used for auto dialling the extension when connected. First
5647 // comma is matched through possibleSeparatorsBetweenNumberAndExtLabel, so we do
5648 // not repeat it here. Semi-colon works in Iphone and Android also to pop up a
5649 // button with the extension number following.
5650
5651 /** @type {string} */
5652
5653 var autoDiallingAndExtLabelsFound = "(?:,{2}|;)";
5654 /** @type {string} */
5655
5656 var rfcExtn = RFC3966_EXTN_PREFIX + getExtensionDigitsPattern(extLimitAfterExplicitLabel);
5657 /** @type {string} */
5658
5659 var explicitExtn = possibleSeparatorsBetweenNumberAndExtLabel + explicitExtLabels + possibleCharsAfterExtLabel + getExtensionDigitsPattern(extLimitAfterExplicitLabel) + optionalExtnSuffix;
5660 /** @type {string} */
5661
5662 var ambiguousExtn = possibleSeparatorsBetweenNumberAndExtLabel + ambiguousExtLabels + possibleCharsAfterExtLabel + getExtensionDigitsPattern(extLimitAfterAmbiguousChar) + optionalExtnSuffix;
5663 /** @type {string} */
5664
5665 var americanStyleExtnWithSuffix = ambiguousSeparator + getExtensionDigitsPattern(extLimitWhenNotSure) + "#";
5666 /** @type {string} */
5667
5668 var autoDiallingExtn = possibleSeparatorsNumberExtLabelNoComma + autoDiallingAndExtLabelsFound + possibleCharsAfterExtLabel + getExtensionDigitsPattern(extLimitAfterLikelyLabel) + optionalExtnSuffix;
5669 /** @type {string} */
5670
5671 var onlyCommasExtn = possibleSeparatorsNumberExtLabelNoComma + "(?:,)+" + possibleCharsAfterExtLabel + getExtensionDigitsPattern(extLimitAfterAmbiguousChar) + optionalExtnSuffix; // The first regular expression covers RFC 3966 format, where the extension is added
5672 // using ";ext=". The second more generic where extension is mentioned with explicit
5673 // labels like "ext:". In both the above cases we allow more numbers in extension than
5674 // any other extension labels. The third one captures when single character extension
5675 // labels or less commonly used labels are used. In such cases we capture fewer
5676 // extension digits in order to reduce the chance of falsely interpreting two
5677 // numbers beside each other as a number + extension. The fourth one covers the
5678 // special case of American numbers where the extension is written with a hash
5679 // at the end, such as "- 503#". The fifth one is exclusively for extension
5680 // autodialling formats which are used when dialling and in this case we accept longer
5681 // extensions. The last one is more liberal on the number of commas that acts as
5682 // extension labels, so we have a strict cap on the number of digits in such extensions.
5683
5684 return rfcExtn + "|" + explicitExtn + "|" + ambiguousExtn + "|" + americanStyleExtnWithSuffix + "|" + autoDiallingExtn + "|" + onlyCommasExtn;
5685 }
5686
5687 // Checks we have at least three leading digits, and only valid punctuation,
5688 // alpha characters and digits in the phone number. Does not include extension
5689 // data. The symbol 'x' is allowed here as valid punctuation since it is often
5690 // used as a placeholder for carrier codes, for example in Brazilian phone
5691 // numbers. We also allow multiple '+' characters at the start.
5692 //
5693 // Corresponds to the following:
5694 // [digits]{minLengthNsn}|
5695 // plus_sign*
5696 // (([punctuation]|[star])*[digits]){3,}([punctuation]|[star]|[digits]|[alpha])*
5697 //
5698 // The first reg-ex is to allow short numbers (two digits long) to be parsed if
5699 // they are entered as "15" etc, but only if there is no punctuation in them.
5700 // The second expression restricts the number of digits to three or more, but
5701 // then allows them to be in international form, and to have alpha-characters
5702 // and punctuation. We split up the two reg-exes here and combine them when
5703 // creating the reg-ex VALID_PHONE_NUMBER_PATTERN itself so we can prefix it
5704 // with ^ and append $ to each branch.
5705 //
5706 // "Note VALID_PUNCTUATION starts with a -,
5707 // so must be the first in the range" (c) Google devs.
5708 // (wtf did they mean by saying that; probably nothing)
5709 //
5710
5711 var MIN_LENGTH_PHONE_NUMBER_PATTERN = '[' + VALID_DIGITS + ']{' + MIN_LENGTH_FOR_NSN + '}'; //
5712 // And this is the second reg-exp:
5713 // (see MIN_LENGTH_PHONE_NUMBER_PATTERN for a full description of this reg-exp)
5714 //
5715
5716 var VALID_PHONE_NUMBER = '[' + PLUS_CHARS + ']{0,1}' + '(?:' + '[' + VALID_PUNCTUATION + ']*' + '[' + VALID_DIGITS + ']' + '){3,}' + '[' + VALID_PUNCTUATION + VALID_DIGITS + ']*'; // This regular expression isn't present in Google's `libphonenumber`
5717 // and is only used to determine whether the phone number being input
5718 // is too short for it to even consider it a "valid" number.
5719 // This is just a way to differentiate between a really invalid phone
5720 // number like "abcde" and a valid phone number that a user has just
5721 // started inputting, like "+1" or "1": both these cases would be
5722 // considered `NOT_A_NUMBER` by Google's `libphonenumber`, but this
5723 // library can provide a more detailed error message — whether it's
5724 // really "not a number", or is it just a start of a valid phone number.
5725
5726 var VALID_PHONE_NUMBER_START_REG_EXP = new RegExp('^' + '[' + PLUS_CHARS + ']{0,1}' + '(?:' + '[' + VALID_PUNCTUATION + ']*' + '[' + VALID_DIGITS + ']' + '){1,2}' + '$', 'i');
5727 var VALID_PHONE_NUMBER_WITH_EXTENSION = VALID_PHONE_NUMBER + // Phone number extensions
5728 '(?:' + createExtensionPattern() + ')?'; // The combined regular expression for valid phone numbers:
5729 //
5730
5731 var VALID_PHONE_NUMBER_PATTERN = new RegExp( // Either a short two-digit-only phone number
5732 '^' + MIN_LENGTH_PHONE_NUMBER_PATTERN + '$' + '|' + // Or a longer fully parsed phone number (min 3 characters)
5733 '^' + VALID_PHONE_NUMBER_WITH_EXTENSION + '$', 'i'); // Checks to see if the string of characters could possibly be a phone number at
5734 // all. At the moment, checks to see that the string begins with at least 2
5735 // digits, ignoring any punctuation commonly found in phone numbers. This method
5736 // does not require the number to be normalized in advance - but does assume
5737 // that leading non-number symbols have been removed, such as by the method
5738 // `extract_possible_number`.
5739 //
5740
5741 function isViablePhoneNumber(number) {
5742 return number.length >= MIN_LENGTH_FOR_NSN && VALID_PHONE_NUMBER_PATTERN.test(number);
5743 } // This is just a way to differentiate between a really invalid phone
5744 // number like "abcde" and a valid phone number that a user has just
5745 // started inputting, like "+1" or "1": both these cases would be
5746 // considered `NOT_A_NUMBER` by Google's `libphonenumber`, but this
5747 // library can provide a more detailed error message — whether it's
5748 // really "not a number", or is it just a start of a valid phone number.
5749
5750 function isViablePhoneNumberStart(number) {
5751 return VALID_PHONE_NUMBER_START_REG_EXP.test(number);
5752 }
5753
5754 // 1 or more valid digits, for use when parsing.
5755
5756 var EXTN_PATTERN = new RegExp('(?:' + createExtensionPattern() + ')$', 'i'); // Strips any extension (as in, the part of the number dialled after the call is
5757 // connected, usually indicated with extn, ext, x or similar) from the end of
5758 // the number, and returns it.
5759
5760 function extractExtension(number) {
5761 var start = number.search(EXTN_PATTERN);
5762
5763 if (start < 0) {
5764 return {};
5765 } // If we find a potential extension, and the number preceding this is a viable
5766 // number, we assume it is an extension.
5767
5768
5769 var numberWithoutExtension = number.slice(0, start);
5770 var matches = number.match(EXTN_PATTERN);
5771 var i = 1;
5772
5773 while (i < matches.length) {
5774 if (matches[i]) {
5775 return {
5776 number: numberWithoutExtension,
5777 ext: matches[i]
5778 };
5779 }
5780
5781 i++;
5782 }
5783 }
5784
5785 // These mappings map a character (key) to a specific digit that should
5786 // replace it for normalization purposes. Non-European digits that
5787 // may be used in phone numbers are mapped to a European equivalent.
5788 //
5789 // E.g. in Iraq they don't write `+442323234` but rather `+٤٤٢٣٢٣٢٣٤`.
5790 //
5791 var DIGITS = {
5792 '0': '0',
5793 '1': '1',
5794 '2': '2',
5795 '3': '3',
5796 '4': '4',
5797 '5': '5',
5798 '6': '6',
5799 '7': '7',
5800 '8': '8',
5801 '9': '9',
5802 "\uFF10": '0',
5803 // Fullwidth digit 0
5804 "\uFF11": '1',
5805 // Fullwidth digit 1
5806 "\uFF12": '2',
5807 // Fullwidth digit 2
5808 "\uFF13": '3',
5809 // Fullwidth digit 3
5810 "\uFF14": '4',
5811 // Fullwidth digit 4
5812 "\uFF15": '5',
5813 // Fullwidth digit 5
5814 "\uFF16": '6',
5815 // Fullwidth digit 6
5816 "\uFF17": '7',
5817 // Fullwidth digit 7
5818 "\uFF18": '8',
5819 // Fullwidth digit 8
5820 "\uFF19": '9',
5821 // Fullwidth digit 9
5822 "\u0660": '0',
5823 // Arabic-indic digit 0
5824 "\u0661": '1',
5825 // Arabic-indic digit 1
5826 "\u0662": '2',
5827 // Arabic-indic digit 2
5828 "\u0663": '3',
5829 // Arabic-indic digit 3
5830 "\u0664": '4',
5831 // Arabic-indic digit 4
5832 "\u0665": '5',
5833 // Arabic-indic digit 5
5834 "\u0666": '6',
5835 // Arabic-indic digit 6
5836 "\u0667": '7',
5837 // Arabic-indic digit 7
5838 "\u0668": '8',
5839 // Arabic-indic digit 8
5840 "\u0669": '9',
5841 // Arabic-indic digit 9
5842 "\u06F0": '0',
5843 // Eastern-Arabic digit 0
5844 "\u06F1": '1',
5845 // Eastern-Arabic digit 1
5846 "\u06F2": '2',
5847 // Eastern-Arabic digit 2
5848 "\u06F3": '3',
5849 // Eastern-Arabic digit 3
5850 "\u06F4": '4',
5851 // Eastern-Arabic digit 4
5852 "\u06F5": '5',
5853 // Eastern-Arabic digit 5
5854 "\u06F6": '6',
5855 // Eastern-Arabic digit 6
5856 "\u06F7": '7',
5857 // Eastern-Arabic digit 7
5858 "\u06F8": '8',
5859 // Eastern-Arabic digit 8
5860 "\u06F9": '9' // Eastern-Arabic digit 9
5861
5862 };
5863 function parseDigit(character) {
5864 return DIGITS[character];
5865 }
5866
5867 /**
5868 * Parses phone number characters from a string.
5869 * Drops all punctuation leaving only digits and the leading `+` sign (if any).
5870 * Also converts wide-ascii and arabic-indic numerals to conventional numerals.
5871 * E.g. in Iraq they don't write `+442323234` but rather `+٤٤٢٣٢٣٢٣٤`.
5872 * @param {string} string
5873 * @return {string}
5874 * @example
5875 * ```js
5876 * // Outputs '8800555'.
5877 * parseIncompletePhoneNumber('8 (800) 555')
5878 * // Outputs '+7800555'.
5879 * parseIncompletePhoneNumber('+7 800 555')
5880 * ```
5881 */
5882
5883 function parseIncompletePhoneNumber(string) {
5884 var result = ''; // Using `.split('')` here instead of normal `for ... of`
5885 // because the importing application doesn't neccessarily include an ES6 polyfill.
5886 // The `.split('')` approach discards "exotic" UTF-8 characters
5887 // (the ones consisting of four bytes) but digits
5888 // (including non-European ones) don't fall into that range
5889 // so such "exotic" characters would be discarded anyway.
5890
5891 for (var _iterator = string.split(''), _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
5892 var _ref;
5893
5894 if (_isArray) {
5895 if (_i >= _iterator.length) break;
5896 _ref = _iterator[_i++];
5897 } else {
5898 _i = _iterator.next();
5899 if (_i.done) break;
5900 _ref = _i.value;
5901 }
5902
5903 var character = _ref;
5904 result += parsePhoneNumberCharacter(character, result) || '';
5905 }
5906
5907 return result;
5908 }
5909 /**
5910 * Parses next character while parsing phone number digits (including a `+`)
5911 * from text: discards everything except `+` and digits, and `+` is only allowed
5912 * at the start of a phone number.
5913 * For example, is used in `react-phone-number-input` where it uses
5914 * [`input-format`](https://gitlab.com/catamphetamine/input-format).
5915 * @param {string} character - Yet another character from raw input string.
5916 * @param {string?} prevParsedCharacters - Previous parsed characters.
5917 * @param {object} meta - Optional custom use-case-specific metadata.
5918 * @return {string?} The parsed character.
5919 */
5920
5921 function parsePhoneNumberCharacter(character, prevParsedCharacters) {
5922 // Only allow a leading `+`.
5923 if (character === '+') {
5924 // If this `+` is not the first parsed character
5925 // then discard it.
5926 if (prevParsedCharacters) {
5927 return;
5928 }
5929
5930 return '+';
5931 } // Allow digits.
5932
5933
5934 return parseDigit(character);
5935 }
5936
5937 /**
5938 * Merges two arrays.
5939 * @param {*} a
5940 * @param {*} b
5941 * @return {*}
5942 */
5943 function mergeArrays(a, b) {
5944 var merged = a.slice();
5945
5946 for (var _iterator = b, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
5947 var _ref;
5948
5949 if (_isArray) {
5950 if (_i >= _iterator.length) break;
5951 _ref = _iterator[_i++];
5952 } else {
5953 _i = _iterator.next();
5954 if (_i.done) break;
5955 _ref = _i.value;
5956 }
5957
5958 var element = _ref;
5959
5960 if (a.indexOf(element) < 0) {
5961 merged.push(element);
5962 }
5963 }
5964
5965 return merged.sort(function (a, b) {
5966 return a - b;
5967 }); // ES6 version, requires Set polyfill.
5968 // let merged = new Set(a)
5969 // for (const element of b) {
5970 // merged.add(i)
5971 // }
5972 // return Array.from(merged).sort((a, b) => a - b)
5973 }
5974
5975 function checkNumberLength(nationalNumber, metadata) {
5976 return checkNumberLengthForType(nationalNumber, undefined, metadata);
5977 } // Checks whether a number is possible for the country based on its length.
5978 // Should only be called for the "new" metadata which has "possible lengths".
5979
5980 function checkNumberLengthForType(nationalNumber, type, metadata) {
5981 var type_info = metadata.type(type); // There should always be "<possiblePengths/>" set for every type element.
5982 // This is declared in the XML schema.
5983 // For size efficiency, where a sub-description (e.g. fixed-line)
5984 // has the same "<possiblePengths/>" as the "general description", this is missing,
5985 // so we fall back to the "general description". Where no numbers of the type
5986 // exist at all, there is one possible length (-1) which is guaranteed
5987 // not to match the length of any real phone number.
5988
5989 var possible_lengths = type_info && type_info.possibleLengths() || metadata.possibleLengths(); // let local_lengths = type_info && type.possibleLengthsLocal() || metadata.possibleLengthsLocal()
5990 // Metadata before version `1.0.18` didn't contain `possible_lengths`.
5991
5992 if (!possible_lengths) {
5993 return 'IS_POSSIBLE';
5994 }
5995
5996 if (type === 'FIXED_LINE_OR_MOBILE') {
5997 // No such country in metadata.
5998
5999 /* istanbul ignore next */
6000 if (!metadata.type('FIXED_LINE')) {
6001 // The rare case has been encountered where no fixedLine data is available
6002 // (true for some non-geographic entities), so we just check mobile.
6003 return checkNumberLengthForType(nationalNumber, 'MOBILE', metadata);
6004 }
6005
6006 var mobile_type = metadata.type('MOBILE');
6007
6008 if (mobile_type) {
6009 // Merge the mobile data in if there was any. "Concat" creates a new
6010 // array, it doesn't edit possible_lengths in place, so we don't need a copy.
6011 // Note that when adding the possible lengths from mobile, we have
6012 // to again check they aren't empty since if they are this indicates
6013 // they are the same as the general desc and should be obtained from there.
6014 possible_lengths = mergeArrays(possible_lengths, mobile_type.possibleLengths()); // The current list is sorted; we need to merge in the new list and
6015 // re-sort (duplicates are okay). Sorting isn't so expensive because
6016 // the lists are very small.
6017 // if (local_lengths) {
6018 // local_lengths = mergeArrays(local_lengths, mobile_type.possibleLengthsLocal())
6019 // } else {
6020 // local_lengths = mobile_type.possibleLengthsLocal()
6021 // }
6022 }
6023 } // If the type doesn't exist then return 'INVALID_LENGTH'.
6024 else if (type && !type_info) {
6025 return 'INVALID_LENGTH';
6026 }
6027
6028 var actual_length = nationalNumber.length; // In `libphonenumber-js` all "local-only" formats are dropped for simplicity.
6029 // // This is safe because there is never an overlap beween the possible lengths
6030 // // and the local-only lengths; this is checked at build time.
6031 // if (local_lengths && local_lengths.indexOf(nationalNumber.length) >= 0)
6032 // {
6033 // return 'IS_POSSIBLE_LOCAL_ONLY'
6034 // }
6035
6036 var minimum_length = possible_lengths[0];
6037
6038 if (minimum_length === actual_length) {
6039 return 'IS_POSSIBLE';
6040 }
6041
6042 if (minimum_length > actual_length) {
6043 return 'TOO_SHORT';
6044 }
6045
6046 if (possible_lengths[possible_lengths.length - 1] < actual_length) {
6047 return 'TOO_LONG';
6048 } // We skip the first element since we've already checked it.
6049
6050
6051 return possible_lengths.indexOf(actual_length, 1) >= 0 ? 'IS_POSSIBLE' : 'INVALID_LENGTH';
6052 }
6053
6054 function isPossiblePhoneNumber(input, options, metadata) {
6055 /* istanbul ignore if */
6056 if (options === undefined) {
6057 options = {};
6058 }
6059
6060 metadata = new Metadata(metadata);
6061
6062 if (options.v2) {
6063 if (!input.countryCallingCode) {
6064 throw new Error('Invalid phone number object passed');
6065 }
6066
6067 metadata.selectNumberingPlan(input.countryCallingCode);
6068 } else {
6069 if (!input.phone) {
6070 return false;
6071 }
6072
6073 if (input.country) {
6074 if (!metadata.hasCountry(input.country)) {
6075 throw new Error("Unknown country: ".concat(input.country));
6076 }
6077
6078 metadata.country(input.country);
6079 } else {
6080 if (!input.countryCallingCode) {
6081 throw new Error('Invalid phone number object passed');
6082 }
6083
6084 metadata.selectNumberingPlan(input.countryCallingCode);
6085 }
6086 }
6087
6088 if (metadata.possibleLengths()) {
6089 return isPossibleNumber(input.phone || input.nationalNumber, metadata);
6090 } else {
6091 // There was a bug between `1.7.35` and `1.7.37` where "possible_lengths"
6092 // were missing for "non-geographical" numbering plans.
6093 // Just assume the number is possible in such cases:
6094 // it's unlikely that anyone generated their custom metadata
6095 // in that short period of time (one day).
6096 // This code can be removed in some future major version update.
6097 if (input.countryCallingCode && metadata.isNonGeographicCallingCode(input.countryCallingCode)) {
6098 // "Non-geographic entities" did't have `possibleLengths`
6099 // due to a bug in metadata generation process.
6100 return true;
6101 } else {
6102 throw new Error('Missing "possibleLengths" in metadata. Perhaps the metadata has been generated before v1.0.18.');
6103 }
6104 }
6105 }
6106 function isPossibleNumber(nationalNumber, metadata) {
6107 //, isInternational) {
6108 switch (checkNumberLength(nationalNumber, metadata)) {
6109 case 'IS_POSSIBLE':
6110 return true;
6111 // This library ignores "local-only" phone numbers (for simplicity).
6112 // See the readme for more info on what are "local-only" phone numbers.
6113 // case 'IS_POSSIBLE_LOCAL_ONLY':
6114 // return !isInternational
6115
6116 default:
6117 return false;
6118 }
6119 }
6120
6121 function _slicedToArray$1(arr, i) { return _arrayWithHoles$1(arr) || _iterableToArrayLimit$1(arr, i) || _nonIterableRest$1(); }
6122
6123 function _nonIterableRest$1() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
6124
6125 function _iterableToArrayLimit$1(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
6126
6127 function _arrayWithHoles$1(arr) { if (Array.isArray(arr)) return arr; }
6128
6129 /**
6130 * @param {string} text - Phone URI (RFC 3966).
6131 * @return {object} `{ ?number, ?ext }`.
6132 */
6133
6134 function parseRFC3966(text) {
6135 var number;
6136 var ext; // Replace "tel:" with "tel=" for parsing convenience.
6137
6138 text = text.replace(/^tel:/, 'tel=');
6139
6140 for (var _iterator = text.split(';'), _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
6141 var _ref;
6142
6143 if (_isArray) {
6144 if (_i >= _iterator.length) break;
6145 _ref = _iterator[_i++];
6146 } else {
6147 _i = _iterator.next();
6148 if (_i.done) break;
6149 _ref = _i.value;
6150 }
6151
6152 var part = _ref;
6153
6154 var _part$split = part.split('='),
6155 _part$split2 = _slicedToArray$1(_part$split, 2),
6156 name = _part$split2[0],
6157 value = _part$split2[1];
6158
6159 switch (name) {
6160 case 'tel':
6161 number = value;
6162 break;
6163
6164 case 'ext':
6165 ext = value;
6166 break;
6167
6168 case 'phone-context':
6169 // Only "country contexts" are supported.
6170 // "Domain contexts" are ignored.
6171 if (value[0] === '+') {
6172 number = value + number;
6173 }
6174
6175 break;
6176 }
6177 } // If the phone number is not viable, then abort.
6178
6179
6180 if (!isViablePhoneNumber(number)) {
6181 return {};
6182 }
6183
6184 var result = {
6185 number: number
6186 };
6187
6188 if (ext) {
6189 result.ext = ext;
6190 }
6191
6192 return result;
6193 }
6194 /**
6195 * @param {object} - `{ ?number, ?extension }`.
6196 * @return {string} Phone URI (RFC 3966).
6197 */
6198
6199 function formatRFC3966(_ref2) {
6200 var number = _ref2.number,
6201 ext = _ref2.ext;
6202
6203 if (!number) {
6204 return '';
6205 }
6206
6207 if (number[0] !== '+') {
6208 throw new Error("\"formatRFC3966()\" expects \"number\" to be in E.164 format.");
6209 }
6210
6211 return "tel:".concat(number).concat(ext ? ';ext=' + ext : '');
6212 }
6213
6214 /**
6215 * Checks whether the entire input sequence can be matched
6216 * against the regular expression.
6217 * @return {boolean}
6218 */
6219 function matchesEntirely(text, regular_expression) {
6220 // If assigning the `''` default value is moved to the arguments above,
6221 // code coverage would decrease for some weird reason.
6222 text = text || '';
6223 return new RegExp('^(?:' + regular_expression + ')$').test(text);
6224 }
6225
6226 var NON_FIXED_LINE_PHONE_TYPES = ['MOBILE', 'PREMIUM_RATE', 'TOLL_FREE', 'SHARED_COST', 'VOIP', 'PERSONAL_NUMBER', 'PAGER', 'UAN', 'VOICEMAIL']; // Finds out national phone number type (fixed line, mobile, etc)
6227
6228 function getNumberType(input, options, metadata) {
6229 // If assigning the `{}` default value is moved to the arguments above,
6230 // code coverage would decrease for some weird reason.
6231 options = options || {}; // When `parse()` returned `{}`
6232 // meaning that the phone number is not a valid one.
6233
6234 if (!input.country) {
6235 return;
6236 }
6237
6238 metadata = new Metadata(metadata);
6239 metadata.selectNumberingPlan(input.country, input.countryCallingCode);
6240 var nationalNumber = options.v2 ? input.nationalNumber : input.phone; // The following is copy-pasted from the original function:
6241 // https://github.com/googlei18n/libphonenumber/blob/3ea547d4fbaa2d0b67588904dfa5d3f2557c27ff/javascript/i18n/phonenumbers/phonenumberutil.js#L2835
6242 // Is this national number even valid for this country
6243
6244 if (!matchesEntirely(nationalNumber, metadata.nationalNumberPattern())) {
6245 return;
6246 } // Is it fixed line number
6247
6248
6249 if (isNumberTypeEqualTo(nationalNumber, 'FIXED_LINE', metadata)) {
6250 // Because duplicate regular expressions are removed
6251 // to reduce metadata size, if "mobile" pattern is ""
6252 // then it means it was removed due to being a duplicate of the fixed-line pattern.
6253 //
6254 if (metadata.type('MOBILE') && metadata.type('MOBILE').pattern() === '') {
6255 return 'FIXED_LINE_OR_MOBILE';
6256 } // v1 metadata.
6257 // Legacy.
6258 // Deprecated.
6259
6260
6261 if (!metadata.type('MOBILE')) {
6262 return 'FIXED_LINE_OR_MOBILE';
6263 } // Check if the number happens to qualify as both fixed line and mobile.
6264 // (no such country in the minimal metadata set)
6265
6266 /* istanbul ignore if */
6267
6268
6269 if (isNumberTypeEqualTo(nationalNumber, 'MOBILE', metadata)) {
6270 return 'FIXED_LINE_OR_MOBILE';
6271 }
6272
6273 return 'FIXED_LINE';
6274 }
6275
6276 for (var _i = 0, _NON_FIXED_LINE_PHONE = NON_FIXED_LINE_PHONE_TYPES; _i < _NON_FIXED_LINE_PHONE.length; _i++) {
6277 var type = _NON_FIXED_LINE_PHONE[_i];
6278
6279 if (isNumberTypeEqualTo(nationalNumber, type, metadata)) {
6280 return type;
6281 }
6282 }
6283 }
6284 function isNumberTypeEqualTo(nationalNumber, type, metadata) {
6285 type = metadata.type(type);
6286
6287 if (!type || !type.pattern()) {
6288 return false;
6289 } // Check if any possible number lengths are present;
6290 // if so, we use them to avoid checking
6291 // the validation pattern if they don't match.
6292 // If they are absent, this means they match
6293 // the general description, which we have
6294 // already checked before a specific number type.
6295
6296
6297 if (type.possibleLengths() && type.possibleLengths().indexOf(nationalNumber.length) < 0) {
6298 return false;
6299 }
6300
6301 return matchesEntirely(nationalNumber, type.pattern());
6302 }
6303
6304 /**
6305 * Checks if a given phone number is valid.
6306 *
6307 * If the `number` is a string, it will be parsed to an object,
6308 * but only if it contains only valid phone number characters (including punctuation).
6309 * If the `number` is an object, it is used as is.
6310 *
6311 * The optional `defaultCountry` argument is the default country.
6312 * I.e. it does not restrict to just that country,
6313 * e.g. in those cases where several countries share
6314 * the same phone numbering rules (NANPA, Britain, etc).
6315 * For example, even though the number `07624 369230`
6316 * belongs to the Isle of Man ("IM" country code)
6317 * calling `isValidNumber('07624369230', 'GB', metadata)`
6318 * still returns `true` because the country is not restricted to `GB`,
6319 * it's just that `GB` is the default one for the phone numbering rules.
6320 * For restricting the country see `isValidNumberForRegion()`
6321 * though restricting a country might not be a good idea.
6322 * https://github.com/googlei18n/libphonenumber/blob/master/FAQ.md#when-should-i-use-isvalidnumberforregion
6323 *
6324 * Examples:
6325 *
6326 * ```js
6327 * isValidNumber('+78005553535', metadata)
6328 * isValidNumber('8005553535', 'RU', metadata)
6329 * isValidNumber('88005553535', 'RU', metadata)
6330 * isValidNumber({ phone: '8005553535', country: 'RU' }, metadata)
6331 * ```
6332 */
6333
6334 function isValidNumber(input, options, metadata) {
6335 // If assigning the `{}` default value is moved to the arguments above,
6336 // code coverage would decrease for some weird reason.
6337 options = options || {};
6338 metadata = new Metadata(metadata); // This is just to support `isValidNumber({})`
6339 // for cases when `parseNumber()` returns `{}`.
6340
6341 if (!input.country) {
6342 return false;
6343 }
6344
6345 metadata.selectNumberingPlan(input.country, input.countryCallingCode); // By default, countries only have type regexps when it's required for
6346 // distinguishing different countries having the same `countryCallingCode`.
6347
6348 if (metadata.hasTypes()) {
6349 return getNumberType(input, options, metadata.metadata) !== undefined;
6350 } // If there are no type regexps for this country in metadata then use
6351 // `nationalNumberPattern` as a "better than nothing" replacement.
6352
6353
6354 var national_number = options.v2 ? input.nationalNumber : input.phone;
6355 return matchesEntirely(national_number, metadata.nationalNumberPattern());
6356 }
6357
6358 //
6359 // E.g. "(999) 111-22-33" -> "999 111 22 33"
6360 //
6361 // For some reason Google's metadata contains `<intlFormat/>`s with brackets and dashes.
6362 // Meanwhile, there's no single opinion about using punctuation in international phone numbers.
6363 //
6364 // For example, Google's `<intlFormat/>` for USA is `+1 213-373-4253`.
6365 // And here's a quote from WikiPedia's "North American Numbering Plan" page:
6366 // https://en.wikipedia.org/wiki/North_American_Numbering_Plan
6367 //
6368 // "The country calling code for all countries participating in the NANP is 1.
6369 // In international format, an NANP number should be listed as +1 301 555 01 00,
6370 // where 301 is an area code (Maryland)."
6371 //
6372 // I personally prefer the international format without any punctuation.
6373 // For example, brackets are remnants of the old age, meaning that the
6374 // phone number part in brackets (so called "area code") can be omitted
6375 // if dialing within the same "area".
6376 // And hyphens were clearly introduced for splitting local numbers into memorizable groups.
6377 // For example, remembering "5553535" is difficult but "555-35-35" is much simpler.
6378 // Imagine a man taking a bus from home to work and seeing an ad with a phone number.
6379 // He has a couple of seconds to memorize that number until it passes by.
6380 // If it were spaces instead of hyphens the man wouldn't necessarily get it,
6381 // but with hyphens instead of spaces the grouping is more explicit.
6382 // I personally think that hyphens introduce visual clutter,
6383 // so I prefer replacing them with spaces in international numbers.
6384 // In the modern age all output is done on displays where spaces are clearly distinguishable
6385 // so hyphens can be safely replaced with spaces without losing any legibility.
6386 //
6387
6388 function applyInternationalSeparatorStyle(formattedNumber) {
6389 return formattedNumber.replace(new RegExp("[".concat(VALID_PUNCTUATION, "]+"), 'g'), ' ').trim();
6390 }
6391
6392 // first group is not used in the national pattern (e.g. Argentina) so the $1
6393 // group does not match correctly. Therefore, we use `\d`, so that the first
6394 // group actually used in the pattern will be matched.
6395
6396 var FIRST_GROUP_PATTERN = /(\$\d)/;
6397 function formatNationalNumberUsingFormat(number, format, _ref) {
6398 var useInternationalFormat = _ref.useInternationalFormat,
6399 withNationalPrefix = _ref.withNationalPrefix;
6400 _ref.carrierCode;
6401 _ref.metadata;
6402 var formattedNumber = number.replace(new RegExp(format.pattern()), useInternationalFormat ? format.internationalFormat() : // This library doesn't use `domestic_carrier_code_formatting_rule`,
6403 // because that one is only used when formatting phone numbers
6404 // for dialing from a mobile phone, and this is not a dialing library.
6405 // carrierCode && format.domesticCarrierCodeFormattingRule()
6406 // // First, replace the $CC in the formatting rule with the desired carrier code.
6407 // // Then, replace the $FG in the formatting rule with the first group
6408 // // and the carrier code combined in the appropriate way.
6409 // ? format.format().replace(FIRST_GROUP_PATTERN, format.domesticCarrierCodeFormattingRule().replace('$CC', carrierCode))
6410 // : (
6411 // withNationalPrefix && format.nationalPrefixFormattingRule()
6412 // ? format.format().replace(FIRST_GROUP_PATTERN, format.nationalPrefixFormattingRule())
6413 // : format.format()
6414 // )
6415 withNationalPrefix && format.nationalPrefixFormattingRule() ? format.format().replace(FIRST_GROUP_PATTERN, format.nationalPrefixFormattingRule()) : format.format());
6416
6417 if (useInternationalFormat) {
6418 return applyInternationalSeparatorStyle(formattedNumber);
6419 }
6420
6421 return formattedNumber;
6422 }
6423
6424 /**
6425 * Pattern that makes it easy to distinguish whether a region has a single
6426 * international dialing prefix or not. If a region has a single international
6427 * prefix (e.g. 011 in USA), it will be represented as a string that contains
6428 * a sequence of ASCII digits, and possibly a tilde, which signals waiting for
6429 * the tone. If there are multiple available international prefixes in a
6430 * region, they will be represented as a regex string that always contains one
6431 * or more characters that are not ASCII digits or a tilde.
6432 */
6433
6434 var SINGLE_IDD_PREFIX_REG_EXP = /^[\d]+(?:[~\u2053\u223C\uFF5E][\d]+)?$/; // For regions that have multiple IDD prefixes
6435 // a preferred IDD prefix is returned.
6436
6437 function getIddPrefix(country, callingCode, metadata) {
6438 var countryMetadata = new Metadata(metadata);
6439 countryMetadata.selectNumberingPlan(country, callingCode);
6440
6441 if (countryMetadata.defaultIDDPrefix()) {
6442 return countryMetadata.defaultIDDPrefix();
6443 }
6444
6445 if (SINGLE_IDD_PREFIX_REG_EXP.test(countryMetadata.IDDPrefix())) {
6446 return countryMetadata.IDDPrefix();
6447 }
6448 }
6449
6450 function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty$4(target, key, source[key]); }); } return target; }
6451
6452 function _defineProperty$4(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6453 var DEFAULT_OPTIONS = {
6454 formatExtension: function formatExtension(formattedNumber, extension, metadata) {
6455 return "".concat(formattedNumber).concat(metadata.ext()).concat(extension);
6456 } // Formats a phone number
6457 //
6458 // Example use cases:
6459 //
6460 // ```js
6461 // formatNumber('8005553535', 'RU', 'INTERNATIONAL')
6462 // formatNumber('8005553535', 'RU', 'INTERNATIONAL', metadata)
6463 // formatNumber({ phone: '8005553535', country: 'RU' }, 'INTERNATIONAL')
6464 // formatNumber({ phone: '8005553535', country: 'RU' }, 'INTERNATIONAL', metadata)
6465 // formatNumber('+78005553535', 'NATIONAL')
6466 // formatNumber('+78005553535', 'NATIONAL', metadata)
6467 // ```
6468 //
6469
6470 };
6471 function formatNumber(input, format, options, metadata) {
6472 // Apply default options.
6473 if (options) {
6474 options = _objectSpread$4({}, DEFAULT_OPTIONS, options);
6475 } else {
6476 options = DEFAULT_OPTIONS;
6477 }
6478
6479 metadata = new Metadata(metadata);
6480
6481 if (input.country && input.country !== '001') {
6482 // Validate `input.country`.
6483 if (!metadata.hasCountry(input.country)) {
6484 throw new Error("Unknown country: ".concat(input.country));
6485 }
6486
6487 metadata.country(input.country);
6488 } else if (input.countryCallingCode) {
6489 metadata.selectNumberingPlan(input.countryCallingCode);
6490 } else return input.phone || '';
6491
6492 var countryCallingCode = metadata.countryCallingCode();
6493 var nationalNumber = options.v2 ? input.nationalNumber : input.phone; // This variable should have been declared inside `case`s
6494 // but Babel has a bug and it says "duplicate variable declaration".
6495
6496 var number;
6497
6498 switch (format) {
6499 case 'NATIONAL':
6500 // Legacy argument support.
6501 // (`{ country: ..., phone: '' }`)
6502 if (!nationalNumber) {
6503 return '';
6504 }
6505
6506 number = formatNationalNumber(nationalNumber, input.carrierCode, 'NATIONAL', metadata, options);
6507 return addExtension(number, input.ext, metadata, options.formatExtension);
6508
6509 case 'INTERNATIONAL':
6510 // Legacy argument support.
6511 // (`{ country: ..., phone: '' }`)
6512 if (!nationalNumber) {
6513 return "+".concat(countryCallingCode);
6514 }
6515
6516 number = formatNationalNumber(nationalNumber, null, 'INTERNATIONAL', metadata, options);
6517 number = "+".concat(countryCallingCode, " ").concat(number);
6518 return addExtension(number, input.ext, metadata, options.formatExtension);
6519
6520 case 'E.164':
6521 // `E.164` doesn't define "phone number extensions".
6522 return "+".concat(countryCallingCode).concat(nationalNumber);
6523
6524 case 'RFC3966':
6525 return formatRFC3966({
6526 number: "+".concat(countryCallingCode).concat(nationalNumber),
6527 ext: input.ext
6528 });
6529 // For reference, here's Google's IDD formatter:
6530 // https://github.com/google/libphonenumber/blob/32719cf74e68796788d1ca45abc85dcdc63ba5b9/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java#L1546
6531 // Not saying that this IDD formatter replicates it 1:1, but it seems to work.
6532 // Who would even need to format phone numbers in IDD format anyway?
6533
6534 case 'IDD':
6535 if (!options.fromCountry) {
6536 return; // throw new Error('`fromCountry` option not passed for IDD-prefixed formatting.')
6537 }
6538
6539 var formattedNumber = formatIDD(nationalNumber, input.carrierCode, countryCallingCode, options.fromCountry, metadata);
6540 return addExtension(formattedNumber, input.ext, metadata, options.formatExtension);
6541
6542 default:
6543 throw new Error("Unknown \"format\" argument passed to \"formatNumber()\": \"".concat(format, "\""));
6544 }
6545 }
6546
6547 function formatNationalNumber(number, carrierCode, formatAs, metadata, options) {
6548 var format = chooseFormatForNumber(metadata.formats(), number);
6549
6550 if (!format) {
6551 return number;
6552 }
6553
6554 return formatNationalNumberUsingFormat(number, format, {
6555 useInternationalFormat: formatAs === 'INTERNATIONAL',
6556 withNationalPrefix: format.nationalPrefixIsOptionalWhenFormattingInNationalFormat() && options && options.nationalPrefix === false ? false : true,
6557 carrierCode: carrierCode,
6558 metadata: metadata
6559 });
6560 }
6561
6562 function chooseFormatForNumber(availableFormats, nationalNnumber) {
6563 for (var _iterator = availableFormats, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
6564 var _ref;
6565
6566 if (_isArray) {
6567 if (_i >= _iterator.length) break;
6568 _ref = _iterator[_i++];
6569 } else {
6570 _i = _iterator.next();
6571 if (_i.done) break;
6572 _ref = _i.value;
6573 }
6574
6575 var format = _ref;
6576
6577 // Validate leading digits
6578 if (format.leadingDigitsPatterns().length > 0) {
6579 // The last leading_digits_pattern is used here, as it is the most detailed
6580 var lastLeadingDigitsPattern = format.leadingDigitsPatterns()[format.leadingDigitsPatterns().length - 1]; // If leading digits don't match then move on to the next phone number format
6581
6582 if (nationalNnumber.search(lastLeadingDigitsPattern) !== 0) {
6583 continue;
6584 }
6585 } // Check that the national number matches the phone number format regular expression
6586
6587
6588 if (matchesEntirely(nationalNnumber, format.pattern())) {
6589 return format;
6590 }
6591 }
6592 }
6593
6594 function addExtension(formattedNumber, ext, metadata, formatExtension) {
6595 return ext ? formatExtension(formattedNumber, ext, metadata) : formattedNumber;
6596 }
6597
6598 function formatIDD(nationalNumber, carrierCode, countryCallingCode, fromCountry, metadata) {
6599 var fromCountryCallingCode = getCountryCallingCode(fromCountry, metadata.metadata); // When calling within the same country calling code.
6600
6601 if (fromCountryCallingCode === countryCallingCode) {
6602 var formattedNumber = formatNationalNumber(nationalNumber, carrierCode, 'NATIONAL', metadata); // For NANPA regions, return the national format for these regions
6603 // but prefix it with the country calling code.
6604
6605 if (countryCallingCode === '1') {
6606 return countryCallingCode + ' ' + formattedNumber;
6607 } // If regions share a country calling code, the country calling code need
6608 // not be dialled. This also applies when dialling within a region, so this
6609 // if clause covers both these cases. Technically this is the case for
6610 // dialling from La Reunion to other overseas departments of France (French
6611 // Guiana, Martinique, Guadeloupe), but not vice versa - so we don't cover
6612 // this edge case for now and for those cases return the version including
6613 // country calling code. Details here:
6614 // http://www.petitfute.com/voyage/225-info-pratiques-reunion
6615 //
6616
6617
6618 return formattedNumber;
6619 }
6620
6621 var iddPrefix = getIddPrefix(fromCountry, undefined, metadata.metadata);
6622
6623 if (iddPrefix) {
6624 return "".concat(iddPrefix, " ").concat(countryCallingCode, " ").concat(formatNationalNumber(nationalNumber, null, 'INTERNATIONAL', metadata));
6625 }
6626 }
6627
6628 function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty$3(target, key, source[key]); }); } return target; }
6629
6630 function _defineProperty$3(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6631
6632 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6633
6634 function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
6635
6636 function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
6637
6638 var PhoneNumber =
6639 /*#__PURE__*/
6640 function () {
6641 function PhoneNumber(countryCallingCode, nationalNumber, metadata) {
6642 _classCallCheck(this, PhoneNumber);
6643
6644 if (!countryCallingCode) {
6645 throw new TypeError('`country` or `countryCallingCode` not passed');
6646 }
6647
6648 if (!nationalNumber) {
6649 throw new TypeError('`nationalNumber` not passed');
6650 }
6651
6652 if (!metadata) {
6653 throw new TypeError('`metadata` not passed');
6654 }
6655
6656 var _metadata = new Metadata(metadata); // If country code is passed then derive `countryCallingCode` from it.
6657 // Also store the country code as `.country`.
6658
6659
6660 if (isCountryCode(countryCallingCode)) {
6661 this.country = countryCallingCode;
6662
6663 _metadata.country(countryCallingCode);
6664
6665 countryCallingCode = _metadata.countryCallingCode();
6666 }
6667
6668 this.countryCallingCode = countryCallingCode;
6669 this.nationalNumber = nationalNumber;
6670 this.number = '+' + this.countryCallingCode + this.nationalNumber;
6671 this.metadata = metadata;
6672 }
6673
6674 _createClass(PhoneNumber, [{
6675 key: "setExt",
6676 value: function setExt(ext) {
6677 this.ext = ext;
6678 }
6679 }, {
6680 key: "isPossible",
6681 value: function isPossible() {
6682 return isPossiblePhoneNumber(this, {
6683 v2: true
6684 }, this.metadata);
6685 }
6686 }, {
6687 key: "isValid",
6688 value: function isValid() {
6689 return isValidNumber(this, {
6690 v2: true
6691 }, this.metadata);
6692 }
6693 }, {
6694 key: "isNonGeographic",
6695 value: function isNonGeographic() {
6696 var metadata = new Metadata(this.metadata);
6697 return metadata.isNonGeographicCallingCode(this.countryCallingCode);
6698 }
6699 }, {
6700 key: "isEqual",
6701 value: function isEqual(phoneNumber) {
6702 return this.number === phoneNumber.number && this.ext === phoneNumber.ext;
6703 } // // Is just an alias for `this.isValid() && this.country === country`.
6704 // // https://github.com/googlei18n/libphonenumber/blob/master/FAQ.md#when-should-i-use-isvalidnumberforregion
6705 // isValidForRegion(country) {
6706 // return isValidNumberForRegion(this, country, { v2: true }, this.metadata)
6707 // }
6708
6709 }, {
6710 key: "getType",
6711 value: function getType() {
6712 return getNumberType(this, {
6713 v2: true
6714 }, this.metadata);
6715 }
6716 }, {
6717 key: "format",
6718 value: function format(_format, options) {
6719 return formatNumber(this, _format, options ? _objectSpread$3({}, options, {
6720 v2: true
6721 }) : {
6722 v2: true
6723 }, this.metadata);
6724 }
6725 }, {
6726 key: "formatNational",
6727 value: function formatNational(options) {
6728 return this.format('NATIONAL', options);
6729 }
6730 }, {
6731 key: "formatInternational",
6732 value: function formatInternational(options) {
6733 return this.format('INTERNATIONAL', options);
6734 }
6735 }, {
6736 key: "getURI",
6737 value: function getURI(options) {
6738 return this.format('RFC3966', options);
6739 }
6740 }]);
6741
6742 return PhoneNumber;
6743 }();
6744
6745 var isCountryCode = function isCountryCode(value) {
6746 return /^[A-Z]{2}$/.test(value);
6747 };
6748
6749 var CAPTURING_DIGIT_PATTERN = new RegExp('([' + VALID_DIGITS + '])');
6750 function stripIddPrefix(number, country, callingCode, metadata) {
6751 if (!country) {
6752 return;
6753 } // Check if the number is IDD-prefixed.
6754
6755
6756 var countryMetadata = new Metadata(metadata);
6757 countryMetadata.selectNumberingPlan(country, callingCode);
6758 var IDDPrefixPattern = new RegExp(countryMetadata.IDDPrefix());
6759
6760 if (number.search(IDDPrefixPattern) !== 0) {
6761 return;
6762 } // Strip IDD prefix.
6763
6764
6765 number = number.slice(number.match(IDDPrefixPattern)[0].length); // If there're any digits after an IDD prefix,
6766 // then those digits are a country calling code.
6767 // Since no country code starts with a `0`,
6768 // the code below validates that the next digit (if present) is not `0`.
6769
6770 var matchedGroups = number.match(CAPTURING_DIGIT_PATTERN);
6771
6772 if (matchedGroups && matchedGroups[1] != null && matchedGroups[1].length > 0) {
6773 if (matchedGroups[1] === '0') {
6774 return;
6775 }
6776 }
6777
6778 return number;
6779 }
6780
6781 /**
6782 * Strips any national prefix (such as 0, 1) present in a
6783 * (possibly incomplete) number provided.
6784 * "Carrier codes" are only used in Colombia and Brazil,
6785 * and only when dialing within those countries from a mobile phone to a fixed line number.
6786 * Sometimes it won't actually strip national prefix
6787 * and will instead prepend some digits to the `number`:
6788 * for example, when number `2345678` is passed with `VI` country selected,
6789 * it will return `{ number: "3402345678" }`, because `340` area code is prepended.
6790 * @param {string} number — National number digits.
6791 * @param {object} metadata — Metadata with country selected.
6792 * @return {object} `{ nationalNumber: string, nationalPrefix: string? carrierCode: string? }`.
6793 */
6794 function extractNationalNumberFromPossiblyIncompleteNumber(number, metadata) {
6795 if (number && metadata.numberingPlan.nationalPrefixForParsing()) {
6796 // See METADATA.md for the description of
6797 // `national_prefix_for_parsing` and `national_prefix_transform_rule`.
6798 // Attempt to parse the first digits as a national prefix.
6799 var prefixPattern = new RegExp('^(?:' + metadata.numberingPlan.nationalPrefixForParsing() + ')');
6800 var prefixMatch = prefixPattern.exec(number);
6801
6802 if (prefixMatch) {
6803 var nationalNumber;
6804 var carrierCode; // https://gitlab.com/catamphetamine/libphonenumber-js/-/blob/master/METADATA.md#national_prefix_for_parsing--national_prefix_transform_rule
6805 // If a `national_prefix_for_parsing` has any "capturing groups"
6806 // then it means that the national (significant) number is equal to
6807 // those "capturing groups" transformed via `national_prefix_transform_rule`,
6808 // and nothing could be said about the actual national prefix:
6809 // what is it and was it even there.
6810 // If a `national_prefix_for_parsing` doesn't have any "capturing groups",
6811 // then everything it matches is a national prefix.
6812 // To determine whether `national_prefix_for_parsing` matched any
6813 // "capturing groups", the value of the result of calling `.exec()`
6814 // is looked at, and if it has non-undefined values where there're
6815 // "capturing groups" in the regular expression, then it means
6816 // that "capturing groups" have been matched.
6817 // It's not possible to tell whether there'll be any "capturing gropus"
6818 // before the matching process, because a `national_prefix_for_parsing`
6819 // could exhibit both behaviors.
6820
6821 var capturedGroupsCount = prefixMatch.length - 1;
6822 var hasCapturedGroups = capturedGroupsCount > 0 && prefixMatch[capturedGroupsCount];
6823
6824 if (metadata.nationalPrefixTransformRule() && hasCapturedGroups) {
6825 nationalNumber = number.replace(prefixPattern, metadata.nationalPrefixTransformRule()); // If there's more than one captured group,
6826 // then carrier code is the second one.
6827
6828 if (capturedGroupsCount > 1) {
6829 carrierCode = prefixMatch[1];
6830 }
6831 } // If there're no "capturing groups",
6832 // or if there're "capturing groups" but no
6833 // `national_prefix_transform_rule`,
6834 // then just strip the national prefix from the number,
6835 // and possibly a carrier code.
6836 // Seems like there could be more.
6837 else {
6838 // `prefixBeforeNationalNumber` is the whole substring matched by
6839 // the `national_prefix_for_parsing` regular expression.
6840 // There seem to be no guarantees that it's just a national prefix.
6841 // For example, if there's a carrier code, it's gonna be a
6842 // part of `prefixBeforeNationalNumber` too.
6843 var prefixBeforeNationalNumber = prefixMatch[0];
6844 nationalNumber = number.slice(prefixBeforeNationalNumber.length); // If there's at least one captured group,
6845 // then carrier code is the first one.
6846
6847 if (hasCapturedGroups) {
6848 carrierCode = prefixMatch[1];
6849 }
6850 } // Tries to guess whether a national prefix was present in the input.
6851 // This is not something copy-pasted from Google's library:
6852 // they don't seem to have an equivalent for that.
6853 // So this isn't an "officially approved" way of doing something like that.
6854 // But since there seems no other existing method, this library uses it.
6855
6856
6857 var nationalPrefix;
6858
6859 if (hasCapturedGroups) {
6860 var possiblePositionOfTheFirstCapturedGroup = number.indexOf(prefixMatch[1]);
6861 var possibleNationalPrefix = number.slice(0, possiblePositionOfTheFirstCapturedGroup); // Example: an Argentinian (AR) phone number `0111523456789`.
6862 // `prefixMatch[0]` is `01115`, and `$1` is `11`,
6863 // and the rest of the phone number is `23456789`.
6864 // The national number is transformed via `9$1` to `91123456789`.
6865 // National prefix `0` is detected being present at the start.
6866 // if (possibleNationalPrefix.indexOf(metadata.numberingPlan.nationalPrefix()) === 0) {
6867
6868 if (possibleNationalPrefix === metadata.numberingPlan.nationalPrefix()) {
6869 nationalPrefix = metadata.numberingPlan.nationalPrefix();
6870 }
6871 } else {
6872 nationalPrefix = prefixMatch[0];
6873 }
6874
6875 return {
6876 nationalNumber: nationalNumber,
6877 nationalPrefix: nationalPrefix,
6878 carrierCode: carrierCode
6879 };
6880 }
6881 }
6882
6883 return {
6884 nationalNumber: number
6885 };
6886 }
6887
6888 /**
6889 * Strips national prefix and carrier code from a complete phone number.
6890 * The difference from the non-"FromCompleteNumber" function is that
6891 * it won't extract national prefix if the resultant number is too short
6892 * to be a complete number for the selected phone numbering plan.
6893 * @param {string} number — Complete phone number digits.
6894 * @param {Metadata} metadata — Metadata with a phone numbering plan selected.
6895 * @return {object} `{ nationalNumber: string, carrierCode: string? }`.
6896 */
6897
6898 function extractNationalNumber(number, metadata) {
6899 // Parsing national prefixes and carrier codes
6900 // is only required for local phone numbers
6901 // but some people don't understand that
6902 // and sometimes write international phone numbers
6903 // with national prefixes (or maybe even carrier codes).
6904 // http://ucken.blogspot.ru/2016/03/trunk-prefixes-in-skype4b.html
6905 // Google's original library forgives such mistakes
6906 // and so does this library, because it has been requested:
6907 // https://github.com/catamphetamine/libphonenumber-js/issues/127
6908 var _extractNationalNumbe = extractNationalNumberFromPossiblyIncompleteNumber(number, metadata),
6909 nationalNumber = _extractNationalNumbe.nationalNumber,
6910 carrierCode = _extractNationalNumbe.carrierCode;
6911
6912 if (!shouldExtractNationalPrefix(number, nationalNumber, metadata)) {
6913 // Don't strip the national prefix.
6914 return {
6915 nationalNumber: number
6916 };
6917 } // If a national prefix has been extracted, check to see
6918 // if the resultant number isn't too short.
6919 // Same code in Google's `libphonenumber`:
6920 // https://github.com/google/libphonenumber/blob/e326fa1fc4283bb05eb35cb3c15c18f98a31af33/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java#L3291-L3302
6921 // For some reason, they do this check right after the `national_number_pattern` check
6922 // this library does in `shouldExtractNationalPrefix()` function.
6923 // Why is there a second "resultant" number validity check?
6924 // They don't provide an explanation.
6925 // This library just copies the behavior.
6926
6927
6928 if (number.length !== nationalNumber.length + (carrierCode ? carrierCode.length : 0)) {
6929 // If not using legacy generated metadata (before version `1.0.18`)
6930 // then it has "possible lengths", so use those to validate the number length.
6931 if (metadata.possibleLengths()) {
6932 // "We require that the NSN remaining after stripping the national prefix and
6933 // carrier code be long enough to be a possible length for the region.
6934 // Otherwise, we don't do the stripping, since the original number could be
6935 // a valid short number."
6936 // https://github.com/google/libphonenumber/blob/876268eb1ad6cdc1b7b5bef17fc5e43052702d57/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java#L3236-L3250
6937 switch (checkNumberLength(nationalNumber, metadata)) {
6938 case 'TOO_SHORT':
6939 case 'INVALID_LENGTH':
6940 // case 'IS_POSSIBLE_LOCAL_ONLY':
6941 // Don't strip the national prefix.
6942 return {
6943 nationalNumber: number
6944 };
6945 }
6946 }
6947 }
6948
6949 return {
6950 nationalNumber: nationalNumber,
6951 carrierCode: carrierCode
6952 };
6953 } // In some countries, the same digit could be a national prefix
6954 // or a leading digit of a valid phone number.
6955 // For example, in Russia, national prefix is `8`,
6956 // and also `800 555 35 35` is a valid number
6957 // in which `8` is not a national prefix, but the first digit
6958 // of a national (significant) number.
6959 // Same's with Belarus:
6960 // `82004910060` is a valid national (significant) number,
6961 // but `2004910060` is not.
6962 // To support such cases (to prevent the code from always stripping
6963 // national prefix), a condition is imposed: a national prefix
6964 // is not extracted when the original number is "viable" and the
6965 // resultant number is not, a "viable" national number being the one
6966 // that matches `national_number_pattern`.
6967
6968 function shouldExtractNationalPrefix(number, nationalSignificantNumber, metadata) {
6969 // The equivalent in Google's code is:
6970 // https://github.com/google/libphonenumber/blob/e326fa1fc4283bb05eb35cb3c15c18f98a31af33/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java#L2969-L3004
6971 if (matchesEntirely(number, metadata.nationalNumberPattern()) && !matchesEntirely(nationalSignificantNumber, metadata.nationalNumberPattern())) {
6972 return false;
6973 } // Just "possible" number check would be more relaxed, so it's not used.
6974 // if (isPossibleNumber(number, metadata) &&
6975 // !isPossibleNumber(numberWithNationalPrefixExtracted, metadata)) {
6976 // return false
6977 // }
6978
6979
6980 return true;
6981 }
6982
6983 /**
6984 * Sometimes some people incorrectly input international phone numbers
6985 * without the leading `+`. This function corrects such input.
6986 * @param {string} number — Phone number digits.
6987 * @param {string?} country
6988 * @param {string?} callingCode
6989 * @param {object} metadata
6990 * @return {object} `{ countryCallingCode: string?, number: string }`.
6991 */
6992
6993 function extractCountryCallingCodeFromInternationalNumberWithoutPlusSign(number, country, callingCode, metadata) {
6994 var countryCallingCode = country ? getCountryCallingCode(country, metadata) : callingCode;
6995
6996 if (number.indexOf(countryCallingCode) === 0) {
6997 metadata = new Metadata(metadata);
6998 metadata.selectNumberingPlan(country, callingCode);
6999 var possibleShorterNumber = number.slice(countryCallingCode.length);
7000
7001 var _extractNationalNumbe = extractNationalNumber(possibleShorterNumber, metadata),
7002 possibleShorterNationalNumber = _extractNationalNumbe.nationalNumber;
7003
7004 var _extractNationalNumbe2 = extractNationalNumber(number, metadata),
7005 nationalNumber = _extractNationalNumbe2.nationalNumber; // If the number was not valid before but is valid now,
7006 // or if it was too long before, we consider the number
7007 // with the country calling code stripped to be a better result
7008 // and keep that instead.
7009 // For example, in Germany (+49), `49` is a valid area code,
7010 // so if a number starts with `49`, it could be both a valid
7011 // national German number or an international number without
7012 // a leading `+`.
7013
7014
7015 if (!matchesEntirely(nationalNumber, metadata.nationalNumberPattern()) && matchesEntirely(possibleShorterNationalNumber, metadata.nationalNumberPattern()) || checkNumberLength(nationalNumber, metadata) === 'TOO_LONG') {
7016 return {
7017 countryCallingCode: countryCallingCode,
7018 number: possibleShorterNumber
7019 };
7020 }
7021 }
7022
7023 return {
7024 number: number
7025 };
7026 }
7027
7028 /**
7029 * Converts a phone number digits (possibly with a `+`)
7030 * into a calling code and the rest phone number digits.
7031 * The "rest phone number digits" could include
7032 * a national prefix, carrier code, and national
7033 * (significant) number.
7034 * @param {string} number — Phone number digits (possibly with a `+`).
7035 * @param {string} [country] — Default country.
7036 * @param {string} [callingCode] — Default calling code (some phone numbering plans are non-geographic).
7037 * @param {object} metadata
7038 * @return {object} `{ countryCallingCode: string?, number: string }`
7039 * @example
7040 * // Returns `{ countryCallingCode: "1", number: "2133734253" }`.
7041 * extractCountryCallingCode('2133734253', 'US', null, metadata)
7042 * extractCountryCallingCode('2133734253', null, '1', metadata)
7043 * extractCountryCallingCode('+12133734253', null, null, metadata)
7044 * extractCountryCallingCode('+12133734253', 'RU', null, metadata)
7045 */
7046
7047 function extractCountryCallingCode(number, country, callingCode, metadata) {
7048 if (!number) {
7049 return {};
7050 } // If this is not an international phone number,
7051 // then either extract an "IDD" prefix, or extract a
7052 // country calling code from a number by autocorrecting it
7053 // by prepending a leading `+` in cases when it starts
7054 // with the country calling code.
7055 // https://wikitravel.org/en/International_dialling_prefix
7056 // https://github.com/catamphetamine/libphonenumber-js/issues/376
7057
7058
7059 if (number[0] !== '+') {
7060 // Convert an "out-of-country" dialing phone number
7061 // to a proper international phone number.
7062 var numberWithoutIDD = stripIddPrefix(number, country, callingCode, metadata); // If an IDD prefix was stripped then
7063 // convert the number to international one
7064 // for subsequent parsing.
7065
7066 if (numberWithoutIDD && numberWithoutIDD !== number) {
7067 number = '+' + numberWithoutIDD;
7068 } else {
7069 // Check to see if the number starts with the country calling code
7070 // for the default country. If so, we remove the country calling code,
7071 // and do some checks on the validity of the number before and after.
7072 // https://github.com/catamphetamine/libphonenumber-js/issues/376
7073 if (country || callingCode) {
7074 var _extractCountryCallin = extractCountryCallingCodeFromInternationalNumberWithoutPlusSign(number, country, callingCode, metadata),
7075 countryCallingCode = _extractCountryCallin.countryCallingCode,
7076 shorterNumber = _extractCountryCallin.number;
7077
7078 if (countryCallingCode) {
7079 return {
7080 countryCallingCode: countryCallingCode,
7081 number: shorterNumber
7082 };
7083 }
7084 }
7085
7086 return {
7087 number: number
7088 };
7089 }
7090 } // Fast abortion: country codes do not begin with a '0'
7091
7092
7093 if (number[1] === '0') {
7094 return {};
7095 }
7096
7097 metadata = new Metadata(metadata); // The thing with country phone codes
7098 // is that they are orthogonal to each other
7099 // i.e. there's no such country phone code A
7100 // for which country phone code B exists
7101 // where B starts with A.
7102 // Therefore, while scanning digits,
7103 // if a valid country code is found,
7104 // that means that it is the country code.
7105 //
7106
7107 var i = 2;
7108
7109 while (i - 1 <= MAX_LENGTH_COUNTRY_CODE && i <= number.length) {
7110 var _countryCallingCode = number.slice(1, i);
7111
7112 if (metadata.hasCallingCode(_countryCallingCode)) {
7113 metadata.selectNumberingPlan(_countryCallingCode);
7114 return {
7115 countryCallingCode: _countryCallingCode,
7116 number: number.slice(i)
7117 };
7118 }
7119
7120 i++;
7121 }
7122
7123 return {};
7124 }
7125
7126 var USE_NON_GEOGRAPHIC_COUNTRY_CODE = false;
7127 function getCountryByCallingCode(callingCode, nationalPhoneNumber, metadata) {
7128 /* istanbul ignore if */
7129 if (USE_NON_GEOGRAPHIC_COUNTRY_CODE) {
7130 if (metadata.isNonGeographicCallingCode(callingCode)) {
7131 return '001';
7132 }
7133 } // Is always non-empty, because `callingCode` is always valid
7134
7135
7136 var possibleCountries = metadata.getCountryCodesForCallingCode(callingCode);
7137
7138 if (!possibleCountries) {
7139 return;
7140 } // If there's just one country corresponding to the country code,
7141 // then just return it, without further phone number digits validation.
7142
7143
7144 if (possibleCountries.length === 1) {
7145 return possibleCountries[0];
7146 }
7147
7148 return selectCountryFromList(possibleCountries, nationalPhoneNumber, metadata.metadata);
7149 }
7150
7151 function selectCountryFromList(possibleCountries, nationalPhoneNumber, metadata) {
7152 // Re-create `metadata` because it will be selecting a `country`.
7153 metadata = new Metadata(metadata);
7154
7155 for (var _iterator = possibleCountries, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
7156 var _ref;
7157
7158 if (_isArray) {
7159 if (_i >= _iterator.length) break;
7160 _ref = _iterator[_i++];
7161 } else {
7162 _i = _iterator.next();
7163 if (_i.done) break;
7164 _ref = _i.value;
7165 }
7166
7167 var country = _ref;
7168 metadata.country(country); // Leading digits check would be the simplest and fastest one.
7169 // Leading digits patterns are only defined for about 20% of all countries.
7170 // https://gitlab.com/catamphetamine/libphonenumber-js/blob/master/METADATA.md#leading_digits
7171 // Matching "leading digits" is a sufficient but not necessary condition.
7172
7173 if (metadata.leadingDigits()) {
7174 if (nationalPhoneNumber && nationalPhoneNumber.search(metadata.leadingDigits()) === 0) {
7175 return country;
7176 }
7177 } // Else perform full validation with all of those
7178 // fixed-line/mobile/etc regular expressions.
7179 else if (getNumberType({
7180 phone: nationalPhoneNumber,
7181 country: country
7182 }, undefined, metadata.metadata)) {
7183 return country;
7184 }
7185 }
7186 }
7187
7188 // This is a port of Google Android `libphonenumber`'s
7189 // This prevents malicious input from consuming CPU.
7190
7191 var MAX_INPUT_STRING_LENGTH = 250; // This consists of the plus symbol, digits, and arabic-indic digits.
7192
7193 var PHONE_NUMBER_START_PATTERN = new RegExp('[' + PLUS_CHARS + VALID_DIGITS + ']'); // Regular expression of trailing characters that we want to remove.
7194 // A trailing `#` is sometimes used when writing phone numbers with extensions in US.
7195 // Example: "+1 (645) 123 1234-910#" number has extension "910".
7196
7197 var AFTER_PHONE_NUMBER_END_PATTERN = new RegExp('[^' + VALID_DIGITS + '#' + ']+$');
7198 //
7199 // ```js
7200 // parse('8 (800) 555-35-35', 'RU')
7201 // parse('8 (800) 555-35-35', 'RU', metadata)
7202 // parse('8 (800) 555-35-35', { country: { default: 'RU' } })
7203 // parse('8 (800) 555-35-35', { country: { default: 'RU' } }, metadata)
7204 // parse('+7 800 555 35 35')
7205 // parse('+7 800 555 35 35', metadata)
7206 // ```
7207 //
7208
7209 function parse(text, options, metadata) {
7210 // If assigning the `{}` default value is moved to the arguments above,
7211 // code coverage would decrease for some weird reason.
7212 options = options || {};
7213 metadata = new Metadata(metadata); // Validate `defaultCountry`.
7214
7215 if (options.defaultCountry && !metadata.hasCountry(options.defaultCountry)) {
7216 if (options.v2) {
7217 throw new ParseError('INVALID_COUNTRY');
7218 }
7219
7220 throw new Error("Unknown country: ".concat(options.defaultCountry));
7221 } // Parse the phone number.
7222
7223
7224 var _parseInput = parseInput(text, options.v2, options.extract),
7225 formattedPhoneNumber = _parseInput.number,
7226 ext = _parseInput.ext,
7227 error = _parseInput.error; // If the phone number is not viable then return nothing.
7228
7229
7230 if (!formattedPhoneNumber) {
7231 if (options.v2) {
7232 if (error === 'TOO_SHORT') {
7233 throw new ParseError('TOO_SHORT');
7234 }
7235
7236 throw new ParseError('NOT_A_NUMBER');
7237 }
7238
7239 return {};
7240 }
7241
7242 var _parsePhoneNumber = parsePhoneNumber$1(formattedPhoneNumber, options.defaultCountry, options.defaultCallingCode, metadata),
7243 country = _parsePhoneNumber.country,
7244 nationalNumber = _parsePhoneNumber.nationalNumber,
7245 countryCallingCode = _parsePhoneNumber.countryCallingCode,
7246 carrierCode = _parsePhoneNumber.carrierCode;
7247
7248 if (!metadata.hasSelectedNumberingPlan()) {
7249 if (options.v2) {
7250 throw new ParseError('INVALID_COUNTRY');
7251 }
7252
7253 return {};
7254 } // Validate national (significant) number length.
7255
7256
7257 if (!nationalNumber || nationalNumber.length < MIN_LENGTH_FOR_NSN) {
7258 // Won't throw here because the regexp already demands length > 1.
7259
7260 /* istanbul ignore if */
7261 if (options.v2) {
7262 throw new ParseError('TOO_SHORT');
7263 } // Google's demo just throws an error in this case.
7264
7265
7266 return {};
7267 } // Validate national (significant) number length.
7268 //
7269 // A sidenote:
7270 //
7271 // They say that sometimes national (significant) numbers
7272 // can be longer than `MAX_LENGTH_FOR_NSN` (e.g. in Germany).
7273 // https://github.com/googlei18n/libphonenumber/blob/7e1748645552da39c4e1ba731e47969d97bdb539/resources/phonenumber.proto#L36
7274 // Such numbers will just be discarded.
7275 //
7276
7277
7278 if (nationalNumber.length > MAX_LENGTH_FOR_NSN) {
7279 if (options.v2) {
7280 throw new ParseError('TOO_LONG');
7281 } // Google's demo just throws an error in this case.
7282
7283
7284 return {};
7285 }
7286
7287 if (options.v2) {
7288 var phoneNumber = new PhoneNumber(countryCallingCode, nationalNumber, metadata.metadata);
7289
7290 if (country) {
7291 phoneNumber.country = country;
7292 }
7293
7294 if (carrierCode) {
7295 phoneNumber.carrierCode = carrierCode;
7296 }
7297
7298 if (ext) {
7299 phoneNumber.ext = ext;
7300 }
7301
7302 return phoneNumber;
7303 } // Check if national phone number pattern matches the number.
7304 // National number pattern is different for each country,
7305 // even for those ones which are part of the "NANPA" group.
7306
7307
7308 var valid = (options.extended ? metadata.hasSelectedNumberingPlan() : country) ? matchesEntirely(nationalNumber, metadata.nationalNumberPattern()) : false;
7309
7310 if (!options.extended) {
7311 return valid ? result(country, nationalNumber, ext) : {};
7312 } // isInternational: countryCallingCode !== undefined
7313
7314
7315 return {
7316 country: country,
7317 countryCallingCode: countryCallingCode,
7318 carrierCode: carrierCode,
7319 valid: valid,
7320 possible: valid ? true : options.extended === true && metadata.possibleLengths() && isPossibleNumber(nationalNumber, metadata) ? true : false,
7321 phone: nationalNumber,
7322 ext: ext
7323 };
7324 }
7325 /**
7326 * Extracts a formatted phone number from text.
7327 * Doesn't guarantee that the extracted phone number
7328 * is a valid phone number (for example, doesn't validate its length).
7329 * @param {string} text
7330 * @param {boolean} [extract] — If `false`, then will parse the entire `text` as a phone number.
7331 * @param {boolean} [throwOnError] — By default, it won't throw if the text is too long.
7332 * @return {string}
7333 * @example
7334 * // Returns "(213) 373-4253".
7335 * extractFormattedPhoneNumber("Call (213) 373-4253 for assistance.")
7336 */
7337
7338 function extractFormattedPhoneNumber(text, extract, throwOnError) {
7339 if (!text) {
7340 return;
7341 }
7342
7343 if (text.length > MAX_INPUT_STRING_LENGTH) {
7344 if (throwOnError) {
7345 throw new ParseError('TOO_LONG');
7346 }
7347
7348 return;
7349 }
7350
7351 if (extract === false) {
7352 return text;
7353 } // Attempt to extract a possible number from the string passed in
7354
7355
7356 var startsAt = text.search(PHONE_NUMBER_START_PATTERN);
7357
7358 if (startsAt < 0) {
7359 return;
7360 }
7361
7362 return text // Trim everything to the left of the phone number
7363 .slice(startsAt) // Remove trailing non-numerical characters
7364 .replace(AFTER_PHONE_NUMBER_END_PATTERN, '');
7365 }
7366 /**
7367 * @param {string} text - Input.
7368 * @param {boolean} v2 - Legacy API functions don't pass `v2: true` flag.
7369 * @param {boolean} [extract] - Whether to extract a phone number from `text`, or attempt to parse the entire text as a phone number.
7370 * @return {object} `{ ?number, ?ext }`.
7371 */
7372
7373
7374 function parseInput(text, v2, extract) {
7375 // Parse RFC 3966 phone number URI.
7376 if (text && text.indexOf('tel:') === 0) {
7377 return parseRFC3966(text);
7378 }
7379
7380 var number = extractFormattedPhoneNumber(text, extract, v2); // If the phone number is not viable, then abort.
7381
7382 if (!number) {
7383 return {};
7384 }
7385
7386 if (!isViablePhoneNumber(number)) {
7387 if (isViablePhoneNumberStart(number)) {
7388 return {
7389 error: 'TOO_SHORT'
7390 };
7391 }
7392
7393 return {};
7394 } // Attempt to parse extension first, since it doesn't require region-specific
7395 // data and we want to have the non-normalised number here.
7396
7397
7398 var withExtensionStripped = extractExtension(number);
7399
7400 if (withExtensionStripped.ext) {
7401 return withExtensionStripped;
7402 }
7403
7404 return {
7405 number: number
7406 };
7407 }
7408 /**
7409 * Creates `parse()` result object.
7410 */
7411
7412
7413 function result(country, nationalNumber, ext) {
7414 var result = {
7415 country: country,
7416 phone: nationalNumber
7417 };
7418
7419 if (ext) {
7420 result.ext = ext;
7421 }
7422
7423 return result;
7424 }
7425 /**
7426 * Parses a viable phone number.
7427 * @param {string} formattedPhoneNumber — Example: "(213) 373-4253".
7428 * @param {string} [defaultCountry]
7429 * @param {string} [defaultCallingCode]
7430 * @param {Metadata} metadata
7431 * @return {object} Returns `{ country: string?, countryCallingCode: string?, nationalNumber: string? }`.
7432 */
7433
7434
7435 function parsePhoneNumber$1(formattedPhoneNumber, defaultCountry, defaultCallingCode, metadata) {
7436 // Extract calling code from phone number.
7437 var _extractCountryCallin = extractCountryCallingCode(parseIncompletePhoneNumber(formattedPhoneNumber), defaultCountry, defaultCallingCode, metadata.metadata),
7438 countryCallingCode = _extractCountryCallin.countryCallingCode,
7439 number = _extractCountryCallin.number; // Choose a country by `countryCallingCode`.
7440
7441
7442 var country;
7443
7444 if (countryCallingCode) {
7445 metadata.selectNumberingPlan(countryCallingCode);
7446 } // If `formattedPhoneNumber` is in "national" format
7447 // then `number` is defined and `countryCallingCode` isn't.
7448 else if (number && (defaultCountry || defaultCallingCode)) {
7449 metadata.selectNumberingPlan(defaultCountry, defaultCallingCode);
7450
7451 if (defaultCountry) {
7452 country = defaultCountry;
7453 }
7454
7455 countryCallingCode = defaultCallingCode || getCountryCallingCode(defaultCountry, metadata.metadata);
7456 } else return {};
7457
7458 if (!number) {
7459 return {
7460 countryCallingCode: countryCallingCode
7461 };
7462 }
7463
7464 var _extractNationalNumbe = extractNationalNumber(parseIncompletePhoneNumber(number), metadata),
7465 nationalNumber = _extractNationalNumbe.nationalNumber,
7466 carrierCode = _extractNationalNumbe.carrierCode; // Sometimes there are several countries
7467 // corresponding to the same country phone code
7468 // (e.g. NANPA countries all having `1` country phone code).
7469 // Therefore, to reliably determine the exact country,
7470 // national (significant) number should have been parsed first.
7471 //
7472 // When `metadata.json` is generated, all "ambiguous" country phone codes
7473 // get their countries populated with the full set of
7474 // "phone number type" regular expressions.
7475 //
7476
7477
7478 var exactCountry = getCountryByCallingCode(countryCallingCode, nationalNumber, metadata);
7479
7480 if (exactCountry) {
7481 country = exactCountry;
7482 /* istanbul ignore if */
7483
7484 if (exactCountry === '001') ; else {
7485 metadata.country(country);
7486 }
7487 }
7488
7489 return {
7490 country: country,
7491 countryCallingCode: countryCallingCode,
7492 nationalNumber: nationalNumber,
7493 carrierCode: carrierCode
7494 };
7495 }
7496
7497 function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty$2(target, key, source[key]); }); } return target; }
7498
7499 function _defineProperty$2(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
7500 function parsePhoneNumber(text, options, metadata) {
7501 return parse(text, _objectSpread$2({}, options, {
7502 v2: true
7503 }), metadata);
7504 }
7505
7506 function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
7507
7508 function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty$1(target, key, source[key]); }); } return target; }
7509
7510 function _defineProperty$1(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
7511
7512 function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
7513
7514 function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
7515
7516 function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
7517
7518 function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7519 function normalizeArguments(args) {
7520 var _Array$prototype$slic = Array.prototype.slice.call(args),
7521 _Array$prototype$slic2 = _slicedToArray(_Array$prototype$slic, 4),
7522 arg_1 = _Array$prototype$slic2[0],
7523 arg_2 = _Array$prototype$slic2[1],
7524 arg_3 = _Array$prototype$slic2[2],
7525 arg_4 = _Array$prototype$slic2[3];
7526
7527 var text;
7528 var options;
7529 var metadata; // If the phone number is passed as a string.
7530 // `parsePhoneNumber('88005553535', ...)`.
7531
7532 if (typeof arg_1 === 'string') {
7533 text = arg_1;
7534 } else throw new TypeError('A text for parsing must be a string.'); // If "default country" argument is being passed then move it to `options`.
7535 // `parsePhoneNumber('88005553535', 'RU', [options], metadata)`.
7536
7537
7538 if (!arg_2 || typeof arg_2 === 'string') {
7539 if (arg_4) {
7540 options = arg_3;
7541 metadata = arg_4;
7542 } else {
7543 options = undefined;
7544 metadata = arg_3;
7545 }
7546
7547 if (arg_2) {
7548 options = _objectSpread$1({
7549 defaultCountry: arg_2
7550 }, options);
7551 }
7552 } // `defaultCountry` is not passed.
7553 // Example: `parsePhoneNumber('+78005553535', [options], metadata)`.
7554 else if (isObject$1(arg_2)) {
7555 if (arg_3) {
7556 options = arg_2;
7557 metadata = arg_3;
7558 } else {
7559 metadata = arg_2;
7560 }
7561 } else throw new Error("Invalid second argument: ".concat(arg_2));
7562
7563 return {
7564 text: text,
7565 options: options,
7566 metadata: metadata
7567 };
7568 } // Otherwise istanbul would show this as "branch not covered".
7569
7570 /* istanbul ignore next */
7571
7572 var isObject$1 = function isObject(_) {
7573 return _typeof(_) === 'object';
7574 };
7575
7576 function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
7577
7578 function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
7579 function parsePhoneNumberFromString$2(text, options, metadata) {
7580 // Validate `defaultCountry`.
7581 if (options && options.defaultCountry && !isSupportedCountry(options.defaultCountry, metadata)) {
7582 options = _objectSpread({}, options, {
7583 defaultCountry: undefined
7584 });
7585 } // Parse phone number.
7586
7587
7588 try {
7589 return parsePhoneNumber(text, options, metadata);
7590 } catch (error) {
7591 /* istanbul ignore else */
7592 if (error instanceof ParseError) ; else {
7593 throw error;
7594 }
7595 }
7596 }
7597
7598 function parsePhoneNumberFromString$1() {
7599 var _normalizeArguments = normalizeArguments(arguments),
7600 text = _normalizeArguments.text,
7601 options = _normalizeArguments.options,
7602 metadata = _normalizeArguments.metadata;
7603
7604 return parsePhoneNumberFromString$2(text, options, metadata);
7605 }
7606
7607 function parsePhoneNumberFromString() {
7608 return withMetadata(parsePhoneNumberFromString$1, arguments)
7609 }
7610
7611 var IS_PHONE_NUMBER = 'isPhoneNumber';
7612 /**
7613 * Checks if the string is a valid phone number. To successfully validate any phone number the text must include
7614 * the intl. calling code, if the calling code wont be provided then the region must be set.
7615 *
7616 * @param value the potential phone number string to test
7617 * @param region 2 characters uppercase country code (e.g. DE, US, CH) for country specific validation.
7618 * If text doesn't start with the international calling code (e.g. +41), then you must set this parameter.
7619 */
7620 function isPhoneNumber(value, region) {
7621 try {
7622 var phoneNum = parsePhoneNumberFromString(value, region);
7623 var result = phoneNum === null || phoneNum === void 0 ? void 0 : phoneNum.isValid();
7624 return !!result;
7625 }
7626 catch (error) {
7627 // logging?
7628 return false;
7629 }
7630 }
7631 /**
7632 * Checks if the string is a valid phone number. To successfully validate any phone number the text must include
7633 * the intl. calling code, if the calling code wont be provided then the region must be set.
7634 *
7635 * @param region 2 characters uppercase country code (e.g. DE, US, CH) for country specific validation.
7636 * If text doesn't start with the international calling code (e.g. +41), then you must set this parameter.
7637 */
7638 function IsPhoneNumber(region, validationOptions) {
7639 return ValidateBy({
7640 name: IS_PHONE_NUMBER,
7641 constraints: [region],
7642 validator: {
7643 validate: function (value, args) { return isPhoneNumber(value, args.constraints[0]); },
7644 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be a valid phone number'); }, validationOptions),
7645 },
7646 }, validationOptions);
7647 }
7648
7649 var IS_MILITARY_TIME = 'isMilitaryTime';
7650 /**
7651 * Checks if the string represents a time without a given timezone in the format HH:MM (military)
7652 * If the given value does not match the pattern HH:MM, then it returns false.
7653 */
7654 function isMilitaryTime(value) {
7655 var militaryTimeRegex = /^([01]\d|2[0-3]):?([0-5]\d)$/;
7656 return typeof value === 'string' && matchesValidator(value, militaryTimeRegex);
7657 }
7658 /**
7659 * Checks if the string represents a time without a given timezone in the format HH:MM (military)
7660 * If the given value does not match the pattern HH:MM, then it returns false.
7661 */
7662 function IsMilitaryTime(validationOptions) {
7663 return ValidateBy({
7664 name: IS_MILITARY_TIME,
7665 validator: {
7666 validate: function (value, args) { return isMilitaryTime(value); },
7667 defaultMessage: buildMessage(function (eachPrefix) {
7668 return eachPrefix + getText('$property must be a valid representation of military time in the format HH:MM');
7669 }, validationOptions),
7670 },
7671 }, validationOptions);
7672 }
7673
7674 var isHash$1 = {exports: {}};
7675
7676 (function (module, exports) {
7677
7678 Object.defineProperty(exports, "__esModule", {
7679 value: true
7680 });
7681 exports.default = isHash;
7682
7683 var _assertString = _interopRequireDefault(assertString.exports);
7684
7685 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
7686
7687 var lengths = {
7688 md5: 32,
7689 md4: 32,
7690 sha1: 40,
7691 sha256: 64,
7692 sha384: 96,
7693 sha512: 128,
7694 ripemd128: 32,
7695 ripemd160: 40,
7696 tiger128: 32,
7697 tiger160: 40,
7698 tiger192: 48,
7699 crc32: 8,
7700 crc32b: 8
7701 };
7702
7703 function isHash(str, algorithm) {
7704 (0, _assertString.default)(str);
7705 var hash = new RegExp("^[a-fA-F0-9]{".concat(lengths[algorithm], "}$"));
7706 return hash.test(str);
7707 }
7708
7709 module.exports = exports.default;
7710 module.exports.default = exports.default;
7711 }(isHash$1, isHash$1.exports));
7712
7713 var isHashValidator = /*@__PURE__*/getDefaultExportFromCjs(isHash$1.exports);
7714
7715 var IS_HASH = 'isHash';
7716 /**
7717 * Check if the string is a hash of type algorithm.
7718 * Algorithm is one of ['md4', 'md5', 'sha1', 'sha256', 'sha384', 'sha512', 'ripemd128', 'ripemd160', 'tiger128',
7719 * 'tiger160', 'tiger192', 'crc32', 'crc32b']
7720 */
7721 function isHash(value, algorithm) {
7722 return typeof value === 'string' && isHashValidator(value, algorithm);
7723 }
7724 /**
7725 * Check if the string is a hash of type algorithm.
7726 * Algorithm is one of ['md4', 'md5', 'sha1', 'sha256', 'sha384', 'sha512', 'ripemd128', 'ripemd160', 'tiger128',
7727 * 'tiger160', 'tiger192', 'crc32', 'crc32b']
7728 */
7729 function IsHash(algorithm, validationOptions) {
7730 return ValidateBy({
7731 name: IS_HASH,
7732 constraints: [algorithm],
7733 validator: {
7734 validate: function (value, args) { return isHash(value, args.constraints[0]); },
7735 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be a hash of type $constraint1'); }, validationOptions),
7736 },
7737 }, validationOptions);
7738 }
7739
7740 var isISSN$1 = {exports: {}};
7741
7742 (function (module, exports) {
7743
7744 Object.defineProperty(exports, "__esModule", {
7745 value: true
7746 });
7747 exports.default = isISSN;
7748
7749 var _assertString = _interopRequireDefault(assertString.exports);
7750
7751 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
7752
7753 var issn = '^\\d{4}-?\\d{3}[\\dX]$';
7754
7755 function isISSN(str) {
7756 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
7757 (0, _assertString.default)(str);
7758 var testIssn = issn;
7759 testIssn = options.require_hyphen ? testIssn.replace('?', '') : testIssn;
7760 testIssn = options.case_sensitive ? new RegExp(testIssn) : new RegExp(testIssn, 'i');
7761
7762 if (!testIssn.test(str)) {
7763 return false;
7764 }
7765
7766 var digits = str.replace('-', '').toUpperCase();
7767 var checksum = 0;
7768
7769 for (var i = 0; i < digits.length; i++) {
7770 var digit = digits[i];
7771 checksum += (digit === 'X' ? 10 : +digit) * (8 - i);
7772 }
7773
7774 return checksum % 11 === 0;
7775 }
7776
7777 module.exports = exports.default;
7778 module.exports.default = exports.default;
7779 }(isISSN$1, isISSN$1.exports));
7780
7781 var isISSNValidator = /*@__PURE__*/getDefaultExportFromCjs(isISSN$1.exports);
7782
7783 var IS_ISSN = 'isISSN';
7784 /**
7785 * Checks if the string is a ISSN.
7786 * If given value is not a string, then it returns false.
7787 */
7788 function isISSN(value, options) {
7789 return typeof value === 'string' && isISSNValidator(value, options);
7790 }
7791 /**
7792 * Checks if the string is a ISSN.
7793 * If given value is not a string, then it returns false.
7794 */
7795 function IsISSN(options, validationOptions) {
7796 return ValidateBy({
7797 name: IS_ISSN,
7798 constraints: [options],
7799 validator: {
7800 validate: function (value, args) { return isISSN(value, args.constraints[0]); },
7801 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be a ISSN'); }, validationOptions),
7802 },
7803 }, validationOptions);
7804 }
7805
7806 var IS_DATE_STRING = 'isDateString';
7807 /**
7808 * Alias for IsISO8601 validator
7809 */
7810 function isDateString(value, options) {
7811 return isISO8601(value, options);
7812 }
7813 /**
7814 * Alias for IsISO8601 validator
7815 */
7816 function IsDateString(options, validationOptions) {
7817 return ValidateBy({
7818 name: IS_DATE_STRING,
7819 constraints: [options],
7820 validator: {
7821 validate: function (value, args) { return isDateString(value); },
7822 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be a valid ISO 8601 date string'); }, validationOptions),
7823 },
7824 }, validationOptions);
7825 }
7826
7827 var isBoolean$1 = {exports: {}};
7828
7829 (function (module, exports) {
7830
7831 Object.defineProperty(exports, "__esModule", {
7832 value: true
7833 });
7834 exports.default = isBoolean;
7835
7836 var _assertString = _interopRequireDefault(assertString.exports);
7837
7838 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
7839
7840 var defaultOptions = {
7841 loose: false
7842 };
7843 var strictBooleans = ['true', 'false', '1', '0'];
7844 var looseBooleans = [].concat(strictBooleans, ['yes', 'no']);
7845
7846 function isBoolean(str) {
7847 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultOptions;
7848 (0, _assertString.default)(str);
7849
7850 if (options.loose) {
7851 return looseBooleans.includes(str.toLowerCase());
7852 }
7853
7854 return strictBooleans.includes(str);
7855 }
7856
7857 module.exports = exports.default;
7858 module.exports.default = exports.default;
7859 }(isBoolean$1, isBoolean$1.exports));
7860
7861 var isBooleanValidator = /*@__PURE__*/getDefaultExportFromCjs(isBoolean$1.exports);
7862
7863 var IS_BOOLEAN_STRING = 'isBooleanString';
7864 /**
7865 * Checks if a string is a boolean.
7866 * If given value is not a string, then it returns false.
7867 */
7868 function isBooleanString(value) {
7869 return typeof value === 'string' && isBooleanValidator(value);
7870 }
7871 /**
7872 * Checks if a string is a boolean.
7873 * If given value is not a string, then it returns false.
7874 */
7875 function IsBooleanString(validationOptions) {
7876 return ValidateBy({
7877 name: IS_BOOLEAN_STRING,
7878 validator: {
7879 validate: function (value, args) { return isBooleanString(value); },
7880 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be a boolean string'); }, validationOptions),
7881 },
7882 }, validationOptions);
7883 }
7884
7885 var isNumeric = {exports: {}};
7886
7887 (function (module, exports) {
7888
7889 Object.defineProperty(exports, "__esModule", {
7890 value: true
7891 });
7892 exports.default = isNumeric;
7893
7894 var _assertString = _interopRequireDefault(assertString.exports);
7895
7896 var _alpha = alpha$1;
7897
7898 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
7899
7900 var numericNoSymbols = /^[0-9]+$/;
7901
7902 function isNumeric(str, options) {
7903 (0, _assertString.default)(str);
7904
7905 if (options && options.no_symbols) {
7906 return numericNoSymbols.test(str);
7907 }
7908
7909 return new RegExp("^[+-]?([0-9]*[".concat((options || {}).locale ? _alpha.decimal[options.locale] : '.', "])?[0-9]+$")).test(str);
7910 }
7911
7912 module.exports = exports.default;
7913 module.exports.default = exports.default;
7914 }(isNumeric, isNumeric.exports));
7915
7916 var isNumericValidator = /*@__PURE__*/getDefaultExportFromCjs(isNumeric.exports);
7917
7918 var IS_NUMBER_STRING = 'isNumberString';
7919 /**
7920 * Checks if the string is numeric.
7921 * If given value is not a string, then it returns false.
7922 */
7923 function isNumberString(value, options) {
7924 return typeof value === 'string' && isNumericValidator(value, options);
7925 }
7926 /**
7927 * Checks if the string is numeric.
7928 * If given value is not a string, then it returns false.
7929 */
7930 function IsNumberString(options, validationOptions) {
7931 return ValidateBy({
7932 name: IS_NUMBER_STRING,
7933 constraints: [options],
7934 validator: {
7935 validate: function (value, args) { return isNumberString(value, args.constraints[0]); },
7936 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be a number string'); }, validationOptions),
7937 },
7938 }, validationOptions);
7939 }
7940
7941 var isBase32$1 = {exports: {}};
7942
7943 (function (module, exports) {
7944
7945 Object.defineProperty(exports, "__esModule", {
7946 value: true
7947 });
7948 exports.default = isBase32;
7949
7950 var _assertString = _interopRequireDefault(assertString.exports);
7951
7952 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
7953
7954 var base32 = /^[A-Z2-7]+=*$/;
7955
7956 function isBase32(str) {
7957 (0, _assertString.default)(str);
7958 var len = str.length;
7959
7960 if (len % 8 === 0 && base32.test(str)) {
7961 return true;
7962 }
7963
7964 return false;
7965 }
7966
7967 module.exports = exports.default;
7968 module.exports.default = exports.default;
7969 }(isBase32$1, isBase32$1.exports));
7970
7971 var isBase32Validator = /*@__PURE__*/getDefaultExportFromCjs(isBase32$1.exports);
7972
7973 var IS_BASE32 = 'isBase32';
7974 /**
7975 * Checks if a string is base32 encoded.
7976 * If given value is not a string, then it returns false.
7977 */
7978 function isBase32(value) {
7979 return typeof value === 'string' && isBase32Validator(value);
7980 }
7981 /**
7982 * Check if a string is base32 encoded.
7983 * If given value is not a string, then it returns false.
7984 */
7985 function IsBase32(validationOptions) {
7986 return ValidateBy({
7987 name: IS_BASE32,
7988 validator: {
7989 validate: function (value, args) { return isBase32(value); },
7990 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be base32 encoded'); }, validationOptions),
7991 },
7992 }, validationOptions);
7993 }
7994
7995 var isBIC$1 = {exports: {}};
7996
7997 (function (module, exports) {
7998
7999 Object.defineProperty(exports, "__esModule", {
8000 value: true
8001 });
8002 exports.default = isBIC;
8003
8004 var _assertString = _interopRequireDefault(assertString.exports);
8005
8006 var _isISO31661Alpha = isISO31661Alpha2$2;
8007
8008 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8009
8010 // https://en.wikipedia.org/wiki/ISO_9362
8011 var isBICReg = /^[A-Za-z]{6}[A-Za-z0-9]{2}([A-Za-z0-9]{3})?$/;
8012
8013 function isBIC(str) {
8014 (0, _assertString.default)(str); // toUpperCase() should be removed when a new major version goes out that changes
8015 // the regex to [A-Z] (per the spec).
8016
8017 if (!_isISO31661Alpha.CountryCodes.has(str.slice(4, 6).toUpperCase())) {
8018 return false;
8019 }
8020
8021 return isBICReg.test(str);
8022 }
8023
8024 module.exports = exports.default;
8025 module.exports.default = exports.default;
8026 }(isBIC$1, isBIC$1.exports));
8027
8028 var isBICValidator = /*@__PURE__*/getDefaultExportFromCjs(isBIC$1.exports);
8029
8030 var IS_BIC = 'isBIC';
8031 /**
8032 * Check if a string is a BIC (Bank Identification Code) or SWIFT code.
8033 * If given value is not a string, then it returns false.
8034 */
8035 function isBIC(value) {
8036 return typeof value === 'string' && isBICValidator(value);
8037 }
8038 /**
8039 * Check if a string is a BIC (Bank Identification Code) or SWIFT code.
8040 * If given value is not a string, then it returns false.
8041 */
8042 function IsBIC(validationOptions) {
8043 return ValidateBy({
8044 name: IS_BIC,
8045 validator: {
8046 validate: function (value, args) { return isBIC(value); },
8047 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be a BIC or SWIFT code'); }, validationOptions),
8048 },
8049 }, validationOptions);
8050 }
8051
8052 var isBtcAddress$1 = {exports: {}};
8053
8054 (function (module, exports) {
8055
8056 Object.defineProperty(exports, "__esModule", {
8057 value: true
8058 });
8059 exports.default = isBtcAddress;
8060
8061 var _assertString = _interopRequireDefault(assertString.exports);
8062
8063 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8064
8065 // supports Bech32 addresses
8066 var bech32 = /^(bc1)[a-z0-9]{25,39}$/;
8067 var base58 = /^(1|3)[A-HJ-NP-Za-km-z1-9]{25,39}$/;
8068
8069 function isBtcAddress(str) {
8070 (0, _assertString.default)(str); // check for bech32
8071
8072 if (str.startsWith('bc1')) {
8073 return bech32.test(str);
8074 }
8075
8076 return base58.test(str);
8077 }
8078
8079 module.exports = exports.default;
8080 module.exports.default = exports.default;
8081 }(isBtcAddress$1, isBtcAddress$1.exports));
8082
8083 var isBtcAddressValidator = /*@__PURE__*/getDefaultExportFromCjs(isBtcAddress$1.exports);
8084
8085 var IS_BTC_ADDRESS = 'isBtcAddress';
8086 /**
8087 * Check if the string is a valid BTC address.
8088 * If given value is not a string, then it returns false.
8089 */
8090 function isBtcAddress(value) {
8091 return typeof value === 'string' && isBtcAddressValidator(value);
8092 }
8093 /**
8094 * Check if the string is a valid BTC address.
8095 * If given value is not a string, then it returns false.
8096 */
8097 function IsBtcAddress(validationOptions) {
8098 return ValidateBy({
8099 name: IS_BTC_ADDRESS,
8100 validator: {
8101 validate: function (value, args) { return isBtcAddress(value); },
8102 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be a BTC address'); }, validationOptions),
8103 },
8104 }, validationOptions);
8105 }
8106
8107 var isDataURI$1 = {exports: {}};
8108
8109 (function (module, exports) {
8110
8111 Object.defineProperty(exports, "__esModule", {
8112 value: true
8113 });
8114 exports.default = isDataURI;
8115
8116 var _assertString = _interopRequireDefault(assertString.exports);
8117
8118 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8119
8120 var validMediaType = /^[a-z]+\/[a-z0-9\-\+]+$/i;
8121 var validAttribute = /^[a-z\-]+=[a-z0-9\-]+$/i;
8122 var validData = /^[a-z0-9!\$&'\(\)\*\+,;=\-\._~:@\/\?%\s]*$/i;
8123
8124 function isDataURI(str) {
8125 (0, _assertString.default)(str);
8126 var data = str.split(',');
8127
8128 if (data.length < 2) {
8129 return false;
8130 }
8131
8132 var attributes = data.shift().trim().split(';');
8133 var schemeAndMediaType = attributes.shift();
8134
8135 if (schemeAndMediaType.substr(0, 5) !== 'data:') {
8136 return false;
8137 }
8138
8139 var mediaType = schemeAndMediaType.substr(5);
8140
8141 if (mediaType !== '' && !validMediaType.test(mediaType)) {
8142 return false;
8143 }
8144
8145 for (var i = 0; i < attributes.length; i++) {
8146 if (!(i === attributes.length - 1 && attributes[i].toLowerCase() === 'base64') && !validAttribute.test(attributes[i])) {
8147 return false;
8148 }
8149 }
8150
8151 for (var _i = 0; _i < data.length; _i++) {
8152 if (!validData.test(data[_i])) {
8153 return false;
8154 }
8155 }
8156
8157 return true;
8158 }
8159
8160 module.exports = exports.default;
8161 module.exports.default = exports.default;
8162 }(isDataURI$1, isDataURI$1.exports));
8163
8164 var isDataURIValidator = /*@__PURE__*/getDefaultExportFromCjs(isDataURI$1.exports);
8165
8166 var IS_DATA_URI = 'isDataURI';
8167 /**
8168 * Check if the string is a data uri format.
8169 * If given value is not a string, then it returns false.
8170 */
8171 function isDataURI(value) {
8172 return typeof value === 'string' && isDataURIValidator(value);
8173 }
8174 /**
8175 * Check if the string is a data uri format.
8176 * If given value is not a string, then it returns false.
8177 */
8178 function IsDataURI(validationOptions) {
8179 return ValidateBy({
8180 name: IS_DATA_URI,
8181 validator: {
8182 validate: function (value, args) { return isDataURI(value); },
8183 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be a data uri format'); }, validationOptions),
8184 },
8185 }, validationOptions);
8186 }
8187
8188 var isEAN$1 = {exports: {}};
8189
8190 (function (module, exports) {
8191
8192 Object.defineProperty(exports, "__esModule", {
8193 value: true
8194 });
8195 exports.default = isEAN;
8196
8197 var _assertString = _interopRequireDefault(assertString.exports);
8198
8199 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8200
8201 /**
8202 * The most commonly used EAN standard is
8203 * the thirteen-digit EAN-13, while the
8204 * less commonly used 8-digit EAN-8 barcode was
8205 * introduced for use on small packages.
8206 * Also EAN/UCC-14 is used for Grouping of individual
8207 * trade items above unit level(Intermediate, Carton or Pallet).
8208 * For more info about EAN-14 checkout: https://www.gtin.info/itf-14-barcodes/
8209 * EAN consists of:
8210 * GS1 prefix, manufacturer code, product code and check digit
8211 * Reference: https://en.wikipedia.org/wiki/International_Article_Number
8212 * Reference: https://www.gtin.info/
8213 */
8214
8215 /**
8216 * Define EAN Lenghts; 8 for EAN-8; 13 for EAN-13; 14 for EAN-14
8217 * and Regular Expression for valid EANs (EAN-8, EAN-13, EAN-14),
8218 * with exact numberic matching of 8 or 13 or 14 digits [0-9]
8219 */
8220 var LENGTH_EAN_8 = 8;
8221 var LENGTH_EAN_14 = 14;
8222 var validEanRegex = /^(\d{8}|\d{13}|\d{14})$/;
8223 /**
8224 * Get position weight given:
8225 * EAN length and digit index/position
8226 *
8227 * @param {number} length
8228 * @param {number} index
8229 * @return {number}
8230 */
8231
8232 function getPositionWeightThroughLengthAndIndex(length, index) {
8233 if (length === LENGTH_EAN_8 || length === LENGTH_EAN_14) {
8234 return index % 2 === 0 ? 3 : 1;
8235 }
8236
8237 return index % 2 === 0 ? 1 : 3;
8238 }
8239 /**
8240 * Calculate EAN Check Digit
8241 * Reference: https://en.wikipedia.org/wiki/International_Article_Number#Calculation_of_checksum_digit
8242 *
8243 * @param {string} ean
8244 * @return {number}
8245 */
8246
8247
8248 function calculateCheckDigit(ean) {
8249 var checksum = ean.slice(0, -1).split('').map(function (char, index) {
8250 return Number(char) * getPositionWeightThroughLengthAndIndex(ean.length, index);
8251 }).reduce(function (acc, partialSum) {
8252 return acc + partialSum;
8253 }, 0);
8254 var remainder = 10 - checksum % 10;
8255 return remainder < 10 ? remainder : 0;
8256 }
8257 /**
8258 * Check if string is valid EAN:
8259 * Matches EAN-8/EAN-13/EAN-14 regex
8260 * Has valid check digit.
8261 *
8262 * @param {string} str
8263 * @return {boolean}
8264 */
8265
8266
8267 function isEAN(str) {
8268 (0, _assertString.default)(str);
8269 var actualCheckDigit = Number(str.slice(-1));
8270 return validEanRegex.test(str) && actualCheckDigit === calculateCheckDigit(str);
8271 }
8272
8273 module.exports = exports.default;
8274 module.exports.default = exports.default;
8275 }(isEAN$1, isEAN$1.exports));
8276
8277 var isEANValidator = /*@__PURE__*/getDefaultExportFromCjs(isEAN$1.exports);
8278
8279 var IS_EAN = 'isEAN';
8280 /**
8281 * Check if the string is an EAN (European Article Number).
8282 * If given value is not a string, then it returns false.
8283 */
8284 function isEAN(value) {
8285 return typeof value === 'string' && isEANValidator(value);
8286 }
8287 /**
8288 * Check if the string is an EAN (European Article Number).
8289 * If given value is not a string, then it returns false.
8290 */
8291 function IsEAN(validationOptions) {
8292 return ValidateBy({
8293 name: IS_EAN,
8294 validator: {
8295 validate: function (value, args) { return isEAN(value); },
8296 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be an EAN (European Article Number)'); }, validationOptions),
8297 },
8298 }, validationOptions);
8299 }
8300
8301 var isEthereumAddress$1 = {exports: {}};
8302
8303 (function (module, exports) {
8304
8305 Object.defineProperty(exports, "__esModule", {
8306 value: true
8307 });
8308 exports.default = isEthereumAddress;
8309
8310 var _assertString = _interopRequireDefault(assertString.exports);
8311
8312 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8313
8314 var eth = /^(0x)[0-9a-f]{40}$/i;
8315
8316 function isEthereumAddress(str) {
8317 (0, _assertString.default)(str);
8318 return eth.test(str);
8319 }
8320
8321 module.exports = exports.default;
8322 module.exports.default = exports.default;
8323 }(isEthereumAddress$1, isEthereumAddress$1.exports));
8324
8325 var isEthereumAddressValidator = /*@__PURE__*/getDefaultExportFromCjs(isEthereumAddress$1.exports);
8326
8327 var IS_ETHEREUM_ADDRESS = 'isEthereumAddress';
8328 /**
8329 * Check if the string is an Ethereum address using basic regex. Does not validate address checksums.
8330 * If given value is not a string, then it returns false.
8331 */
8332 function isEthereumAddress(value) {
8333 return typeof value === 'string' && isEthereumAddressValidator(value);
8334 }
8335 /**
8336 * Check if the string is an Ethereum address using basic regex. Does not validate address checksums.
8337 * If given value is not a string, then it returns false.
8338 */
8339 function IsEthereumAddress(validationOptions) {
8340 return ValidateBy({
8341 name: IS_ETHEREUM_ADDRESS,
8342 validator: {
8343 validate: function (value, args) { return isEthereumAddress(value); },
8344 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be an Ethereum address'); }, validationOptions),
8345 },
8346 }, validationOptions);
8347 }
8348
8349 var isHSL$1 = {exports: {}};
8350
8351 (function (module, exports) {
8352
8353 Object.defineProperty(exports, "__esModule", {
8354 value: true
8355 });
8356 exports.default = isHSL;
8357
8358 var _assertString = _interopRequireDefault(assertString.exports);
8359
8360 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8361
8362 var hslComma = /^hsla?\(((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?))(deg|grad|rad|turn)?(,(\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%){2}(,((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%?))?\)$/i;
8363 var hslSpace = /^hsla?\(((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?))(deg|grad|rad|turn)?(\s(\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%){2}\s?(\/\s((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%?)\s?)?\)$/i;
8364
8365 function isHSL(str) {
8366 (0, _assertString.default)(str); // Strip duplicate spaces before calling the validation regex (See #1598 for more info)
8367
8368 var strippedStr = str.replace(/\s+/g, ' ').replace(/\s?(hsla?\(|\)|,)\s?/ig, '$1');
8369
8370 if (strippedStr.indexOf(',') !== -1) {
8371 return hslComma.test(strippedStr);
8372 }
8373
8374 return hslSpace.test(strippedStr);
8375 }
8376
8377 module.exports = exports.default;
8378 module.exports.default = exports.default;
8379 }(isHSL$1, isHSL$1.exports));
8380
8381 var isHSLValidator = /*@__PURE__*/getDefaultExportFromCjs(isHSL$1.exports);
8382
8383 var IS_HSL = 'isHSL';
8384 /**
8385 * Check if the string is an HSL (hue, saturation, lightness, optional alpha) color based on CSS Colors Level 4 specification.
8386 * Comma-separated format supported. Space-separated format supported with the exception of a few edge cases (ex: hsl(200grad+.1%62%/1)).
8387 * If given value is not a string, then it returns false.
8388 */
8389 function isHSL(value) {
8390 return typeof value === 'string' && isHSLValidator(value);
8391 }
8392 /**
8393 * Check if the string is an HSL (hue, saturation, lightness, optional alpha) color based on CSS Colors Level 4 specification.
8394 * Comma-separated format supported. Space-separated format supported with the exception of a few edge cases (ex: hsl(200grad+.1%62%/1)).
8395 * If given value is not a string, then it returns false.
8396 */
8397 function IsHSL(validationOptions) {
8398 return ValidateBy({
8399 name: IS_HSL,
8400 validator: {
8401 validate: function (value, args) { return isHSL(value); },
8402 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be a HSL color'); }, validationOptions),
8403 },
8404 }, validationOptions);
8405 }
8406
8407 var isIBAN$2 = {};
8408
8409 Object.defineProperty(isIBAN$2, "__esModule", {
8410 value: true
8411 });
8412 var _default$1 = isIBAN$2.default = isIBAN$1;
8413 isIBAN$2.locales = void 0;
8414
8415 var _assertString$1 = _interopRequireDefault$1(assertString.exports);
8416
8417 function _interopRequireDefault$1(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8418
8419 /**
8420 * List of country codes with
8421 * corresponding IBAN regular expression
8422 * Reference: https://en.wikipedia.org/wiki/International_Bank_Account_Number
8423 */
8424 var ibanRegexThroughCountryCode = {
8425 AD: /^(AD[0-9]{2})\d{8}[A-Z0-9]{12}$/,
8426 AE: /^(AE[0-9]{2})\d{3}\d{16}$/,
8427 AL: /^(AL[0-9]{2})\d{8}[A-Z0-9]{16}$/,
8428 AT: /^(AT[0-9]{2})\d{16}$/,
8429 AZ: /^(AZ[0-9]{2})[A-Z0-9]{4}\d{20}$/,
8430 BA: /^(BA[0-9]{2})\d{16}$/,
8431 BE: /^(BE[0-9]{2})\d{12}$/,
8432 BG: /^(BG[0-9]{2})[A-Z]{4}\d{6}[A-Z0-9]{8}$/,
8433 BH: /^(BH[0-9]{2})[A-Z]{4}[A-Z0-9]{14}$/,
8434 BR: /^(BR[0-9]{2})\d{23}[A-Z]{1}[A-Z0-9]{1}$/,
8435 BY: /^(BY[0-9]{2})[A-Z0-9]{4}\d{20}$/,
8436 CH: /^(CH[0-9]{2})\d{5}[A-Z0-9]{12}$/,
8437 CR: /^(CR[0-9]{2})\d{18}$/,
8438 CY: /^(CY[0-9]{2})\d{8}[A-Z0-9]{16}$/,
8439 CZ: /^(CZ[0-9]{2})\d{20}$/,
8440 DE: /^(DE[0-9]{2})\d{18}$/,
8441 DK: /^(DK[0-9]{2})\d{14}$/,
8442 DO: /^(DO[0-9]{2})[A-Z]{4}\d{20}$/,
8443 EE: /^(EE[0-9]{2})\d{16}$/,
8444 EG: /^(EG[0-9]{2})\d{25}$/,
8445 ES: /^(ES[0-9]{2})\d{20}$/,
8446 FI: /^(FI[0-9]{2})\d{14}$/,
8447 FO: /^(FO[0-9]{2})\d{14}$/,
8448 FR: /^(FR[0-9]{2})\d{10}[A-Z0-9]{11}\d{2}$/,
8449 GB: /^(GB[0-9]{2})[A-Z]{4}\d{14}$/,
8450 GE: /^(GE[0-9]{2})[A-Z0-9]{2}\d{16}$/,
8451 GI: /^(GI[0-9]{2})[A-Z]{4}[A-Z0-9]{15}$/,
8452 GL: /^(GL[0-9]{2})\d{14}$/,
8453 GR: /^(GR[0-9]{2})\d{7}[A-Z0-9]{16}$/,
8454 GT: /^(GT[0-9]{2})[A-Z0-9]{4}[A-Z0-9]{20}$/,
8455 HR: /^(HR[0-9]{2})\d{17}$/,
8456 HU: /^(HU[0-9]{2})\d{24}$/,
8457 IE: /^(IE[0-9]{2})[A-Z0-9]{4}\d{14}$/,
8458 IL: /^(IL[0-9]{2})\d{19}$/,
8459 IQ: /^(IQ[0-9]{2})[A-Z]{4}\d{15}$/,
8460 IR: /^(IR[0-9]{2})0\d{2}0\d{18}$/,
8461 IS: /^(IS[0-9]{2})\d{22}$/,
8462 IT: /^(IT[0-9]{2})[A-Z]{1}\d{10}[A-Z0-9]{12}$/,
8463 JO: /^(JO[0-9]{2})[A-Z]{4}\d{22}$/,
8464 KW: /^(KW[0-9]{2})[A-Z]{4}[A-Z0-9]{22}$/,
8465 KZ: /^(KZ[0-9]{2})\d{3}[A-Z0-9]{13}$/,
8466 LB: /^(LB[0-9]{2})\d{4}[A-Z0-9]{20}$/,
8467 LC: /^(LC[0-9]{2})[A-Z]{4}[A-Z0-9]{24}$/,
8468 LI: /^(LI[0-9]{2})\d{5}[A-Z0-9]{12}$/,
8469 LT: /^(LT[0-9]{2})\d{16}$/,
8470 LU: /^(LU[0-9]{2})\d{3}[A-Z0-9]{13}$/,
8471 LV: /^(LV[0-9]{2})[A-Z]{4}[A-Z0-9]{13}$/,
8472 MC: /^(MC[0-9]{2})\d{10}[A-Z0-9]{11}\d{2}$/,
8473 MD: /^(MD[0-9]{2})[A-Z0-9]{20}$/,
8474 ME: /^(ME[0-9]{2})\d{18}$/,
8475 MK: /^(MK[0-9]{2})\d{3}[A-Z0-9]{10}\d{2}$/,
8476 MR: /^(MR[0-9]{2})\d{23}$/,
8477 MT: /^(MT[0-9]{2})[A-Z]{4}\d{5}[A-Z0-9]{18}$/,
8478 MU: /^(MU[0-9]{2})[A-Z]{4}\d{19}[A-Z]{3}$/,
8479 MZ: /^(MZ[0-9]{2})\d{21}$/,
8480 NL: /^(NL[0-9]{2})[A-Z]{4}\d{10}$/,
8481 NO: /^(NO[0-9]{2})\d{11}$/,
8482 PK: /^(PK[0-9]{2})[A-Z0-9]{4}\d{16}$/,
8483 PL: /^(PL[0-9]{2})\d{24}$/,
8484 PS: /^(PS[0-9]{2})[A-Z0-9]{4}\d{21}$/,
8485 PT: /^(PT[0-9]{2})\d{21}$/,
8486 QA: /^(QA[0-9]{2})[A-Z]{4}[A-Z0-9]{21}$/,
8487 RO: /^(RO[0-9]{2})[A-Z]{4}[A-Z0-9]{16}$/,
8488 RS: /^(RS[0-9]{2})\d{18}$/,
8489 SA: /^(SA[0-9]{2})\d{2}[A-Z0-9]{18}$/,
8490 SC: /^(SC[0-9]{2})[A-Z]{4}\d{20}[A-Z]{3}$/,
8491 SE: /^(SE[0-9]{2})\d{20}$/,
8492 SI: /^(SI[0-9]{2})\d{15}$/,
8493 SK: /^(SK[0-9]{2})\d{20}$/,
8494 SM: /^(SM[0-9]{2})[A-Z]{1}\d{10}[A-Z0-9]{12}$/,
8495 SV: /^(SV[0-9]{2})[A-Z0-9]{4}\d{20}$/,
8496 TL: /^(TL[0-9]{2})\d{19}$/,
8497 TN: /^(TN[0-9]{2})\d{20}$/,
8498 TR: /^(TR[0-9]{2})\d{5}[A-Z0-9]{17}$/,
8499 UA: /^(UA[0-9]{2})\d{6}[A-Z0-9]{19}$/,
8500 VA: /^(VA[0-9]{2})\d{18}$/,
8501 VG: /^(VG[0-9]{2})[A-Z0-9]{4}\d{16}$/,
8502 XK: /^(XK[0-9]{2})\d{16}$/
8503 };
8504 /**
8505 * Check whether string has correct universal IBAN format
8506 * The IBAN consists of up to 34 alphanumeric characters, as follows:
8507 * Country Code using ISO 3166-1 alpha-2, two letters
8508 * check digits, two digits and
8509 * Basic Bank Account Number (BBAN), up to 30 alphanumeric characters.
8510 * NOTE: Permitted IBAN characters are: digits [0-9] and the 26 latin alphabetic [A-Z]
8511 *
8512 * @param {string} str - string under validation
8513 * @return {boolean}
8514 */
8515
8516 function hasValidIbanFormat(str) {
8517 // Strip white spaces and hyphens
8518 var strippedStr = str.replace(/[\s\-]+/gi, '').toUpperCase();
8519 var isoCountryCode = strippedStr.slice(0, 2).toUpperCase();
8520 return isoCountryCode in ibanRegexThroughCountryCode && ibanRegexThroughCountryCode[isoCountryCode].test(strippedStr);
8521 }
8522 /**
8523 * Check whether string has valid IBAN Checksum
8524 * by performing basic mod-97 operation and
8525 * the remainder should equal 1
8526 * -- Start by rearranging the IBAN by moving the four initial characters to the end of the string
8527 * -- Replace each letter in the string with two digits, A -> 10, B = 11, Z = 35
8528 * -- Interpret the string as a decimal integer and
8529 * -- compute the remainder on division by 97 (mod 97)
8530 * Reference: https://en.wikipedia.org/wiki/International_Bank_Account_Number
8531 *
8532 * @param {string} str
8533 * @return {boolean}
8534 */
8535
8536
8537 function hasValidIbanChecksum(str) {
8538 var strippedStr = str.replace(/[^A-Z0-9]+/gi, '').toUpperCase(); // Keep only digits and A-Z latin alphabetic
8539
8540 var rearranged = strippedStr.slice(4) + strippedStr.slice(0, 4);
8541 var alphaCapsReplacedWithDigits = rearranged.replace(/[A-Z]/g, function (char) {
8542 return char.charCodeAt(0) - 55;
8543 });
8544 var remainder = alphaCapsReplacedWithDigits.match(/\d{1,7}/g).reduce(function (acc, value) {
8545 return Number(acc + value) % 97;
8546 }, '');
8547 return remainder === 1;
8548 }
8549
8550 function isIBAN$1(str) {
8551 (0, _assertString$1.default)(str);
8552 return hasValidIbanFormat(str) && hasValidIbanChecksum(str);
8553 }
8554
8555 var locales$1 = Object.keys(ibanRegexThroughCountryCode);
8556 isIBAN$2.locales = locales$1;
8557
8558 var IS_IBAN = 'isIBAN';
8559 /**
8560 * Check if a string is a IBAN (International Bank Account Number).
8561 * If given value is not a string, then it returns false.
8562 */
8563 function isIBAN(value) {
8564 return typeof value === 'string' && _default$1(value);
8565 }
8566 /**
8567 * Check if a string is a IBAN (International Bank Account Number).
8568 * If given value is not a string, then it returns false.
8569 */
8570 function IsIBAN(validationOptions) {
8571 return ValidateBy({
8572 name: IS_IBAN,
8573 validator: {
8574 validate: function (value, args) { return isIBAN(value); },
8575 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be an IBAN'); }, validationOptions),
8576 },
8577 }, validationOptions);
8578 }
8579
8580 var isIdentityCard$1 = {exports: {}};
8581
8582 (function (module, exports) {
8583
8584 Object.defineProperty(exports, "__esModule", {
8585 value: true
8586 });
8587 exports.default = isIdentityCard;
8588
8589 var _assertString = _interopRequireDefault(assertString.exports);
8590
8591 var _isInt = _interopRequireDefault(isInt$1.exports);
8592
8593 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8594
8595 var validators = {
8596 PL: function PL(str) {
8597 (0, _assertString.default)(str);
8598 var weightOfDigits = {
8599 1: 1,
8600 2: 3,
8601 3: 7,
8602 4: 9,
8603 5: 1,
8604 6: 3,
8605 7: 7,
8606 8: 9,
8607 9: 1,
8608 10: 3,
8609 11: 0
8610 };
8611
8612 if (str != null && str.length === 11 && (0, _isInt.default)(str, {
8613 allow_leading_zeroes: true
8614 })) {
8615 var digits = str.split('').slice(0, -1);
8616 var sum = digits.reduce(function (acc, digit, index) {
8617 return acc + Number(digit) * weightOfDigits[index + 1];
8618 }, 0);
8619 var modulo = sum % 10;
8620 var lastDigit = Number(str.charAt(str.length - 1));
8621
8622 if (modulo === 0 && lastDigit === 0 || lastDigit === 10 - modulo) {
8623 return true;
8624 }
8625 }
8626
8627 return false;
8628 },
8629 ES: function ES(str) {
8630 (0, _assertString.default)(str);
8631 var DNI = /^[0-9X-Z][0-9]{7}[TRWAGMYFPDXBNJZSQVHLCKE]$/;
8632 var charsValue = {
8633 X: 0,
8634 Y: 1,
8635 Z: 2
8636 };
8637 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']; // sanitize user input
8638
8639 var sanitized = str.trim().toUpperCase(); // validate the data structure
8640
8641 if (!DNI.test(sanitized)) {
8642 return false;
8643 } // validate the control digit
8644
8645
8646 var number = sanitized.slice(0, -1).replace(/[X,Y,Z]/g, function (char) {
8647 return charsValue[char];
8648 });
8649 return sanitized.endsWith(controlDigits[number % 23]);
8650 },
8651 FI: function FI(str) {
8652 // https://dvv.fi/en/personal-identity-code#:~:text=control%20character%20for%20a-,personal,-identity%20code%20calculated
8653 (0, _assertString.default)(str);
8654
8655 if (str.length !== 11) {
8656 return false;
8657 }
8658
8659 if (!str.match(/^\d{6}[\-A\+]\d{3}[0-9ABCDEFHJKLMNPRSTUVWXY]{1}$/)) {
8660 return false;
8661 }
8662
8663 var checkDigits = '0123456789ABCDEFHJKLMNPRSTUVWXY';
8664 var idAsNumber = parseInt(str.slice(0, 6), 10) * 1000 + parseInt(str.slice(7, 10), 10);
8665 var remainder = idAsNumber % 31;
8666 var checkDigit = checkDigits[remainder];
8667 return checkDigit === str.slice(10, 11);
8668 },
8669 IN: function IN(str) {
8670 var DNI = /^[1-9]\d{3}\s?\d{4}\s?\d{4}$/; // multiplication table
8671
8672 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]]; // permutation table
8673
8674 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]]; // sanitize user input
8675
8676 var sanitized = str.trim(); // validate the data structure
8677
8678 if (!DNI.test(sanitized)) {
8679 return false;
8680 }
8681
8682 var c = 0;
8683 var invertedArray = sanitized.replace(/\s/g, '').split('').map(Number).reverse();
8684 invertedArray.forEach(function (val, i) {
8685 c = d[c][p[i % 8][val]];
8686 });
8687 return c === 0;
8688 },
8689 IR: function IR(str) {
8690 if (!str.match(/^\d{10}$/)) return false;
8691 str = "0000".concat(str).substr(str.length - 6);
8692 if (parseInt(str.substr(3, 6), 10) === 0) return false;
8693 var lastNumber = parseInt(str.substr(9, 1), 10);
8694 var sum = 0;
8695
8696 for (var i = 0; i < 9; i++) {
8697 sum += parseInt(str.substr(i, 1), 10) * (10 - i);
8698 }
8699
8700 sum %= 11;
8701 return sum < 2 && lastNumber === sum || sum >= 2 && lastNumber === 11 - sum;
8702 },
8703 IT: function IT(str) {
8704 if (str.length !== 9) return false;
8705 if (str === 'CA00000AA') return false; // https://it.wikipedia.org/wiki/Carta_d%27identit%C3%A0_elettronica_italiana
8706
8707 return str.search(/C[A-Z][0-9]{5}[A-Z]{2}/i) > -1;
8708 },
8709 NO: function NO(str) {
8710 var sanitized = str.trim();
8711 if (isNaN(Number(sanitized))) return false;
8712 if (sanitized.length !== 11) return false;
8713 if (sanitized === '00000000000') return false; // https://no.wikipedia.org/wiki/F%C3%B8dselsnummer
8714
8715 var f = sanitized.split('').map(Number);
8716 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;
8717 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;
8718 if (k1 !== f[9] || k2 !== f[10]) return false;
8719 return true;
8720 },
8721 TH: function TH(str) {
8722 if (!str.match(/^[1-8]\d{12}$/)) return false; // validate check digit
8723
8724 var sum = 0;
8725
8726 for (var i = 0; i < 12; i++) {
8727 sum += parseInt(str[i], 10) * (13 - i);
8728 }
8729
8730 return str[12] === ((11 - sum % 11) % 10).toString();
8731 },
8732 LK: function LK(str) {
8733 var old_nic = /^[1-9]\d{8}[vx]$/i;
8734 var new_nic = /^[1-9]\d{11}$/i;
8735 if (str.length === 10 && old_nic.test(str)) return true;else if (str.length === 12 && new_nic.test(str)) return true;
8736 return false;
8737 },
8738 'he-IL': function heIL(str) {
8739 var DNI = /^\d{9}$/; // sanitize user input
8740
8741 var sanitized = str.trim(); // validate the data structure
8742
8743 if (!DNI.test(sanitized)) {
8744 return false;
8745 }
8746
8747 var id = sanitized;
8748 var sum = 0,
8749 incNum;
8750
8751 for (var i = 0; i < id.length; i++) {
8752 incNum = Number(id[i]) * (i % 2 + 1); // Multiply number by 1 or 2
8753
8754 sum += incNum > 9 ? incNum - 9 : incNum; // Sum the digits up and add to total
8755 }
8756
8757 return sum % 10 === 0;
8758 },
8759 'ar-LY': function arLY(str) {
8760 // Libya National Identity Number NIN is 12 digits, the first digit is either 1 or 2
8761 var NIN = /^(1|2)\d{11}$/; // sanitize user input
8762
8763 var sanitized = str.trim(); // validate the data structure
8764
8765 if (!NIN.test(sanitized)) {
8766 return false;
8767 }
8768
8769 return true;
8770 },
8771 'ar-TN': function arTN(str) {
8772 var DNI = /^\d{8}$/; // sanitize user input
8773
8774 var sanitized = str.trim(); // validate the data structure
8775
8776 if (!DNI.test(sanitized)) {
8777 return false;
8778 }
8779
8780 return true;
8781 },
8782 'zh-CN': function zhCN(str) {
8783 var provincesAndCities = ['11', // 北京
8784 '12', // 天津
8785 '13', // 河北
8786 '14', // 山西
8787 '15', // 内蒙古
8788 '21', // 辽宁
8789 '22', // 吉林
8790 '23', // 黑龙江
8791 '31', // 上海
8792 '32', // 江苏
8793 '33', // 浙江
8794 '34', // 安徽
8795 '35', // 福建
8796 '36', // 江西
8797 '37', // 山东
8798 '41', // 河南
8799 '42', // 湖北
8800 '43', // 湖南
8801 '44', // 广东
8802 '45', // 广西
8803 '46', // 海南
8804 '50', // 重庆
8805 '51', // 四川
8806 '52', // 贵州
8807 '53', // 云南
8808 '54', // 西藏
8809 '61', // 陕西
8810 '62', // 甘肃
8811 '63', // 青海
8812 '64', // 宁夏
8813 '65', // 新疆
8814 '71', // 台湾
8815 '81', // 香港
8816 '82', // 澳门
8817 '91' // 国外
8818 ];
8819 var powers = ['7', '9', '10', '5', '8', '4', '2', '1', '6', '3', '7', '9', '10', '5', '8', '4', '2'];
8820 var parityBit = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'];
8821
8822 var checkAddressCode = function checkAddressCode(addressCode) {
8823 return provincesAndCities.includes(addressCode);
8824 };
8825
8826 var checkBirthDayCode = function checkBirthDayCode(birDayCode) {
8827 var yyyy = parseInt(birDayCode.substring(0, 4), 10);
8828 var mm = parseInt(birDayCode.substring(4, 6), 10);
8829 var dd = parseInt(birDayCode.substring(6), 10);
8830 var xdata = new Date(yyyy, mm - 1, dd);
8831
8832 if (xdata > new Date()) {
8833 return false; // eslint-disable-next-line max-len
8834 } else if (xdata.getFullYear() === yyyy && xdata.getMonth() === mm - 1 && xdata.getDate() === dd) {
8835 return true;
8836 }
8837
8838 return false;
8839 };
8840
8841 var getParityBit = function getParityBit(idCardNo) {
8842 var id17 = idCardNo.substring(0, 17);
8843 var power = 0;
8844
8845 for (var i = 0; i < 17; i++) {
8846 power += parseInt(id17.charAt(i), 10) * parseInt(powers[i], 10);
8847 }
8848
8849 var mod = power % 11;
8850 return parityBit[mod];
8851 };
8852
8853 var checkParityBit = function checkParityBit(idCardNo) {
8854 return getParityBit(idCardNo) === idCardNo.charAt(17).toUpperCase();
8855 };
8856
8857 var check15IdCardNo = function check15IdCardNo(idCardNo) {
8858 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);
8859 if (!check) return false;
8860 var addressCode = idCardNo.substring(0, 2);
8861 check = checkAddressCode(addressCode);
8862 if (!check) return false;
8863 var birDayCode = "19".concat(idCardNo.substring(6, 12));
8864 check = checkBirthDayCode(birDayCode);
8865 if (!check) return false;
8866 return true;
8867 };
8868
8869 var check18IdCardNo = function check18IdCardNo(idCardNo) {
8870 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);
8871 if (!check) return false;
8872 var addressCode = idCardNo.substring(0, 2);
8873 check = checkAddressCode(addressCode);
8874 if (!check) return false;
8875 var birDayCode = idCardNo.substring(6, 14);
8876 check = checkBirthDayCode(birDayCode);
8877 if (!check) return false;
8878 return checkParityBit(idCardNo);
8879 };
8880
8881 var checkIdCardNo = function checkIdCardNo(idCardNo) {
8882 var check = /^\d{15}|(\d{17}(\d|x|X))$/.test(idCardNo);
8883 if (!check) return false;
8884
8885 if (idCardNo.length === 15) {
8886 return check15IdCardNo(idCardNo);
8887 }
8888
8889 return check18IdCardNo(idCardNo);
8890 };
8891
8892 return checkIdCardNo(str);
8893 },
8894 'zh-TW': function zhTW(str) {
8895 var ALPHABET_CODES = {
8896 A: 10,
8897 B: 11,
8898 C: 12,
8899 D: 13,
8900 E: 14,
8901 F: 15,
8902 G: 16,
8903 H: 17,
8904 I: 34,
8905 J: 18,
8906 K: 19,
8907 L: 20,
8908 M: 21,
8909 N: 22,
8910 O: 35,
8911 P: 23,
8912 Q: 24,
8913 R: 25,
8914 S: 26,
8915 T: 27,
8916 U: 28,
8917 V: 29,
8918 W: 32,
8919 X: 30,
8920 Y: 31,
8921 Z: 33
8922 };
8923 var sanitized = str.trim().toUpperCase();
8924 if (!/^[A-Z][0-9]{9}$/.test(sanitized)) return false;
8925 return Array.from(sanitized).reduce(function (sum, number, index) {
8926 if (index === 0) {
8927 var code = ALPHABET_CODES[number];
8928 return code % 10 * 9 + Math.floor(code / 10);
8929 }
8930
8931 if (index === 9) {
8932 return (10 - sum % 10 - Number(number)) % 10 === 0;
8933 }
8934
8935 return sum + Number(number) * (9 - index);
8936 }, 0);
8937 }
8938 };
8939
8940 function isIdentityCard(str, locale) {
8941 (0, _assertString.default)(str);
8942
8943 if (locale in validators) {
8944 return validators[locale](str);
8945 } else if (locale === 'any') {
8946 for (var key in validators) {
8947 // https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md#ignoring-code-for-coverage-purposes
8948 // istanbul ignore else
8949 if (validators.hasOwnProperty(key)) {
8950 var validator = validators[key];
8951
8952 if (validator(str)) {
8953 return true;
8954 }
8955 }
8956 }
8957
8958 return false;
8959 }
8960
8961 throw new Error("Invalid locale '".concat(locale, "'"));
8962 }
8963
8964 module.exports = exports.default;
8965 module.exports.default = exports.default;
8966 }(isIdentityCard$1, isIdentityCard$1.exports));
8967
8968 var isIdentityCardValidator = /*@__PURE__*/getDefaultExportFromCjs(isIdentityCard$1.exports);
8969
8970 var IS_IDENTITY_CARD = 'isIdentityCard';
8971 /**
8972 * Check if the string is a valid identity card code.
8973 * locale is one of ['ES', 'zh-TW', 'he-IL', 'ar-TN'] OR 'any'. If 'any' is used, function will check if any of the locals match.
8974 * Defaults to 'any'.
8975 * If given value is not a string, then it returns false.
8976 */
8977 function isIdentityCard(value, locale) {
8978 return typeof value === 'string' && isIdentityCardValidator(value, locale);
8979 }
8980 /**
8981 * Check if the string is a valid identity card code.
8982 * locale is one of ['ES', 'zh-TW', 'he-IL', 'ar-TN'] OR 'any'. If 'any' is used, function will check if any of the locals match.
8983 * Defaults to 'any'.
8984 * If given value is not a string, then it returns false.
8985 */
8986 function IsIdentityCard(locale, validationOptions) {
8987 return ValidateBy({
8988 name: IS_IDENTITY_CARD,
8989 constraints: [locale],
8990 validator: {
8991 validate: function (value, args) { return isIdentityCard(value, args.constraints[0]); },
8992 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be a identity card number'); }, validationOptions),
8993 },
8994 }, validationOptions);
8995 }
8996
8997 var isISRC$1 = {exports: {}};
8998
8999 (function (module, exports) {
9000
9001 Object.defineProperty(exports, "__esModule", {
9002 value: true
9003 });
9004 exports.default = isISRC;
9005
9006 var _assertString = _interopRequireDefault(assertString.exports);
9007
9008 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9009
9010 // see http://isrc.ifpi.org/en/isrc-standard/code-syntax
9011 var isrc = /^[A-Z]{2}[0-9A-Z]{3}\d{2}\d{5}$/;
9012
9013 function isISRC(str) {
9014 (0, _assertString.default)(str);
9015 return isrc.test(str);
9016 }
9017
9018 module.exports = exports.default;
9019 module.exports.default = exports.default;
9020 }(isISRC$1, isISRC$1.exports));
9021
9022 var isISRCValidator = /*@__PURE__*/getDefaultExportFromCjs(isISRC$1.exports);
9023
9024 var IS_ISRC = 'isISRC';
9025 /**
9026 * Check if the string is a ISRC.
9027 * If given value is not a string, then it returns false.
9028 */
9029 function isISRC(value) {
9030 return typeof value === 'string' && isISRCValidator(value);
9031 }
9032 /**
9033 * Check if the string is a ISRC.
9034 * If given value is not a string, then it returns false.
9035 */
9036 function IsISRC(validationOptions) {
9037 return ValidateBy({
9038 name: IS_ISRC,
9039 validator: {
9040 validate: function (value, args) { return isISRC(value); },
9041 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be an ISRC'); }, validationOptions),
9042 },
9043 }, validationOptions);
9044 }
9045
9046 var isLocale$1 = {exports: {}};
9047
9048 (function (module, exports) {
9049
9050 Object.defineProperty(exports, "__esModule", {
9051 value: true
9052 });
9053 exports.default = isLocale;
9054
9055 var _assertString = _interopRequireDefault(assertString.exports);
9056
9057 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9058
9059 var localeReg = /^[A-Za-z]{2,4}([_-]([A-Za-z]{4}|[\d]{3}))?([_-]([A-Za-z]{2}|[\d]{3}))?$/;
9060
9061 function isLocale(str) {
9062 (0, _assertString.default)(str);
9063
9064 if (str === 'en_US_POSIX' || str === 'ca_ES_VALENCIA') {
9065 return true;
9066 }
9067
9068 return localeReg.test(str);
9069 }
9070
9071 module.exports = exports.default;
9072 module.exports.default = exports.default;
9073 }(isLocale$1, isLocale$1.exports));
9074
9075 var isLocaleValidator = /*@__PURE__*/getDefaultExportFromCjs(isLocale$1.exports);
9076
9077 var IS_LOCALE = 'isLocale';
9078 /**
9079 * Check if the string is a locale.
9080 * If given value is not a string, then it returns false.
9081 */
9082 function isLocale(value) {
9083 return typeof value === 'string' && isLocaleValidator(value);
9084 }
9085 /**
9086 * Check if the string is a locale.
9087 * If given value is not a string, then it returns false.
9088 */
9089 function IsLocale(validationOptions) {
9090 return ValidateBy({
9091 name: IS_LOCALE,
9092 validator: {
9093 validate: function (value, args) { return isLocale(value); },
9094 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be locale'); }, validationOptions),
9095 },
9096 }, validationOptions);
9097 }
9098
9099 var isMagnetURI$1 = {exports: {}};
9100
9101 (function (module, exports) {
9102
9103 Object.defineProperty(exports, "__esModule", {
9104 value: true
9105 });
9106 exports.default = isMagnetURI;
9107
9108 var _assertString = _interopRequireDefault(assertString.exports);
9109
9110 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9111
9112 var magnetURI = /^magnet:\?xt(?:\.1)?=urn:(?:aich|bitprint|btih|ed2k|ed2khash|kzhash|md5|sha1|tree:tiger):[a-z0-9]{32}(?:[a-z0-9]{8})?($|&)/i;
9113
9114 function isMagnetURI(url) {
9115 (0, _assertString.default)(url);
9116 return magnetURI.test(url.trim());
9117 }
9118
9119 module.exports = exports.default;
9120 module.exports.default = exports.default;
9121 }(isMagnetURI$1, isMagnetURI$1.exports));
9122
9123 var isMagnetURIValidator = /*@__PURE__*/getDefaultExportFromCjs(isMagnetURI$1.exports);
9124
9125 var IS_MAGNET_URI = 'isMagnetURI';
9126 /**
9127 * Check if the string is a magnet uri format.
9128 * If given value is not a string, then it returns false.
9129 */
9130 function isMagnetURI(value) {
9131 return typeof value === 'string' && isMagnetURIValidator(value);
9132 }
9133 /**
9134 * Check if the string is a magnet uri format.
9135 * If given value is not a string, then it returns false.
9136 */
9137 function IsMagnetURI(validationOptions) {
9138 return ValidateBy({
9139 name: IS_MAGNET_URI,
9140 validator: {
9141 validate: function (value, args) { return isMagnetURI(value); },
9142 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be magnet uri format'); }, validationOptions),
9143 },
9144 }, validationOptions);
9145 }
9146
9147 var isMimeType$1 = {exports: {}};
9148
9149 (function (module, exports) {
9150
9151 Object.defineProperty(exports, "__esModule", {
9152 value: true
9153 });
9154 exports.default = isMimeType;
9155
9156 var _assertString = _interopRequireDefault(assertString.exports);
9157
9158 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9159
9160 /*
9161 Checks if the provided string matches to a correct Media type format (MIME type)
9162
9163 This function only checks is the string format follows the
9164 etablished rules by the according RFC specifications.
9165 This function supports 'charset' in textual media types
9166 (https://tools.ietf.org/html/rfc6657).
9167
9168 This function does not check against all the media types listed
9169 by the IANA (https://www.iana.org/assignments/media-types/media-types.xhtml)
9170 because of lightness purposes : it would require to include
9171 all these MIME types in this librairy, which would weigh it
9172 significantly. This kind of effort maybe is not worth for the use that
9173 this function has in this entire librairy.
9174
9175 More informations in the RFC specifications :
9176 - https://tools.ietf.org/html/rfc2045
9177 - https://tools.ietf.org/html/rfc2046
9178 - https://tools.ietf.org/html/rfc7231#section-3.1.1.1
9179 - https://tools.ietf.org/html/rfc7231#section-3.1.1.5
9180 */
9181 // Match simple MIME types
9182 // NB :
9183 // Subtype length must not exceed 100 characters.
9184 // This rule does not comply to the RFC specs (what is the max length ?).
9185 var mimeTypeSimple = /^(application|audio|font|image|message|model|multipart|text|video)\/[a-zA-Z0-9\.\-\+]{1,100}$/i; // eslint-disable-line max-len
9186 // Handle "charset" in "text/*"
9187
9188 var mimeTypeText = /^text\/[a-zA-Z0-9\.\-\+]{1,100};\s?charset=("[a-zA-Z0-9\.\-\+\s]{0,70}"|[a-zA-Z0-9\.\-\+]{0,70})(\s?\([a-zA-Z0-9\.\-\+\s]{1,20}\))?$/i; // eslint-disable-line max-len
9189 // Handle "boundary" in "multipart/*"
9190
9191 var mimeTypeMultipart = /^multipart\/[a-zA-Z0-9\.\-\+]{1,100}(;\s?(boundary|charset)=("[a-zA-Z0-9\.\-\+\s]{0,70}"|[a-zA-Z0-9\.\-\+]{0,70})(\s?\([a-zA-Z0-9\.\-\+\s]{1,20}\))?){0,2}$/i; // eslint-disable-line max-len
9192
9193 function isMimeType(str) {
9194 (0, _assertString.default)(str);
9195 return mimeTypeSimple.test(str) || mimeTypeText.test(str) || mimeTypeMultipart.test(str);
9196 }
9197
9198 module.exports = exports.default;
9199 module.exports.default = exports.default;
9200 }(isMimeType$1, isMimeType$1.exports));
9201
9202 var isMimeTypeValidator = /*@__PURE__*/getDefaultExportFromCjs(isMimeType$1.exports);
9203
9204 var IS_MIME_TYPE = 'isMimeType';
9205 /**
9206 * Check if the string matches to a valid MIME type format
9207 * If given value is not a string, then it returns false.
9208 */
9209 function isMimeType(value) {
9210 return typeof value === 'string' && isMimeTypeValidator(value);
9211 }
9212 /**
9213 * Check if the string matches to a valid MIME type format
9214 * If given value is not a string, then it returns false.
9215 */
9216 function IsMimeType(validationOptions) {
9217 return ValidateBy({
9218 name: IS_MIME_TYPE,
9219 validator: {
9220 validate: function (value, args) { return isMimeType(value); },
9221 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be MIME type format'); }, validationOptions),
9222 },
9223 }, validationOptions);
9224 }
9225
9226 var isOctal$1 = {exports: {}};
9227
9228 (function (module, exports) {
9229
9230 Object.defineProperty(exports, "__esModule", {
9231 value: true
9232 });
9233 exports.default = isOctal;
9234
9235 var _assertString = _interopRequireDefault(assertString.exports);
9236
9237 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9238
9239 var octal = /^(0o)?[0-7]+$/i;
9240
9241 function isOctal(str) {
9242 (0, _assertString.default)(str);
9243 return octal.test(str);
9244 }
9245
9246 module.exports = exports.default;
9247 module.exports.default = exports.default;
9248 }(isOctal$1, isOctal$1.exports));
9249
9250 var isOctalValidator = /*@__PURE__*/getDefaultExportFromCjs(isOctal$1.exports);
9251
9252 var IS_OCTAL = 'isOctal';
9253 /**
9254 * Check if the string is a valid octal number.
9255 * If given value is not a string, then it returns false.
9256 */
9257 function isOctal(value) {
9258 return typeof value === 'string' && isOctalValidator(value);
9259 }
9260 /**
9261 * Check if the string is a valid octal number.
9262 * If given value is not a string, then it returns false.
9263 */
9264 function IsOctal(validationOptions) {
9265 return ValidateBy({
9266 name: IS_OCTAL,
9267 validator: {
9268 validate: function (value, args) { return isOctal(value); },
9269 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be valid octal number'); }, validationOptions),
9270 },
9271 }, validationOptions);
9272 }
9273
9274 var isPassportNumber$1 = {exports: {}};
9275
9276 (function (module, exports) {
9277
9278 Object.defineProperty(exports, "__esModule", {
9279 value: true
9280 });
9281 exports.default = isPassportNumber;
9282
9283 var _assertString = _interopRequireDefault(assertString.exports);
9284
9285 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9286
9287 /**
9288 * Reference:
9289 * https://en.wikipedia.org/ -- Wikipedia
9290 * https://docs.microsoft.com/en-us/microsoft-365/compliance/eu-passport-number -- EU Passport Number
9291 * https://countrycode.org/ -- Country Codes
9292 */
9293 var passportRegexByCountryCode = {
9294 AM: /^[A-Z]{2}\d{7}$/,
9295 // ARMENIA
9296 AR: /^[A-Z]{3}\d{6}$/,
9297 // ARGENTINA
9298 AT: /^[A-Z]\d{7}$/,
9299 // AUSTRIA
9300 AU: /^[A-Z]\d{7}$/,
9301 // AUSTRALIA
9302 BE: /^[A-Z]{2}\d{6}$/,
9303 // BELGIUM
9304 BG: /^\d{9}$/,
9305 // BULGARIA
9306 BR: /^[A-Z]{2}\d{6}$/,
9307 // BRAZIL
9308 BY: /^[A-Z]{2}\d{7}$/,
9309 // BELARUS
9310 CA: /^[A-Z]{2}\d{6}$/,
9311 // CANADA
9312 CH: /^[A-Z]\d{7}$/,
9313 // SWITZERLAND
9314 CN: /^G\d{8}$|^E(?![IO])[A-Z0-9]\d{7}$/,
9315 // CHINA [G=Ordinary, E=Electronic] followed by 8-digits, or E followed by any UPPERCASE letter (except I and O) followed by 7 digits
9316 CY: /^[A-Z](\d{6}|\d{8})$/,
9317 // CYPRUS
9318 CZ: /^\d{8}$/,
9319 // CZECH REPUBLIC
9320 DE: /^[CFGHJKLMNPRTVWXYZ0-9]{9}$/,
9321 // GERMANY
9322 DK: /^\d{9}$/,
9323 // DENMARK
9324 DZ: /^\d{9}$/,
9325 // ALGERIA
9326 EE: /^([A-Z]\d{7}|[A-Z]{2}\d{7})$/,
9327 // ESTONIA (K followed by 7-digits), e-passports have 2 UPPERCASE followed by 7 digits
9328 ES: /^[A-Z0-9]{2}([A-Z0-9]?)\d{6}$/,
9329 // SPAIN
9330 FI: /^[A-Z]{2}\d{7}$/,
9331 // FINLAND
9332 FR: /^\d{2}[A-Z]{2}\d{5}$/,
9333 // FRANCE
9334 GB: /^\d{9}$/,
9335 // UNITED KINGDOM
9336 GR: /^[A-Z]{2}\d{7}$/,
9337 // GREECE
9338 HR: /^\d{9}$/,
9339 // CROATIA
9340 HU: /^[A-Z]{2}(\d{6}|\d{7})$/,
9341 // HUNGARY
9342 IE: /^[A-Z0-9]{2}\d{7}$/,
9343 // IRELAND
9344 IN: /^[A-Z]{1}-?\d{7}$/,
9345 // INDIA
9346 ID: /^[A-C]\d{7}$/,
9347 // INDONESIA
9348 IR: /^[A-Z]\d{8}$/,
9349 // IRAN
9350 IS: /^(A)\d{7}$/,
9351 // ICELAND
9352 IT: /^[A-Z0-9]{2}\d{7}$/,
9353 // ITALY
9354 JP: /^[A-Z]{2}\d{7}$/,
9355 // JAPAN
9356 KR: /^[MS]\d{8}$/,
9357 // SOUTH KOREA, REPUBLIC OF KOREA, [S=PS Passports, M=PM Passports]
9358 LT: /^[A-Z0-9]{8}$/,
9359 // LITHUANIA
9360 LU: /^[A-Z0-9]{8}$/,
9361 // LUXEMBURG
9362 LV: /^[A-Z0-9]{2}\d{7}$/,
9363 // LATVIA
9364 LY: /^[A-Z0-9]{8}$/,
9365 // LIBYA
9366 MT: /^\d{7}$/,
9367 // MALTA
9368 MZ: /^([A-Z]{2}\d{7})|(\d{2}[A-Z]{2}\d{5})$/,
9369 // MOZAMBIQUE
9370 MY: /^[AHK]\d{8}$/,
9371 // MALAYSIA
9372 NL: /^[A-Z]{2}[A-Z0-9]{6}\d$/,
9373 // NETHERLANDS
9374 PL: /^[A-Z]{2}\d{7}$/,
9375 // POLAND
9376 PT: /^[A-Z]\d{6}$/,
9377 // PORTUGAL
9378 RO: /^\d{8,9}$/,
9379 // ROMANIA
9380 RU: /^\d{9}$/,
9381 // RUSSIAN FEDERATION
9382 SE: /^\d{8}$/,
9383 // SWEDEN
9384 SL: /^(P)[A-Z]\d{7}$/,
9385 // SLOVANIA
9386 SK: /^[0-9A-Z]\d{7}$/,
9387 // SLOVAKIA
9388 TR: /^[A-Z]\d{8}$/,
9389 // TURKEY
9390 UA: /^[A-Z]{2}\d{6}$/,
9391 // UKRAINE
9392 US: /^\d{9}$/ // UNITED STATES
9393
9394 };
9395 /**
9396 * Check if str is a valid passport number
9397 * relative to provided ISO Country Code.
9398 *
9399 * @param {string} str
9400 * @param {string} countryCode
9401 * @return {boolean}
9402 */
9403
9404 function isPassportNumber(str, countryCode) {
9405 (0, _assertString.default)(str);
9406 /** Remove All Whitespaces, Convert to UPPERCASE */
9407
9408 var normalizedStr = str.replace(/\s/g, '').toUpperCase();
9409 return countryCode.toUpperCase() in passportRegexByCountryCode && passportRegexByCountryCode[countryCode].test(normalizedStr);
9410 }
9411
9412 module.exports = exports.default;
9413 module.exports.default = exports.default;
9414 }(isPassportNumber$1, isPassportNumber$1.exports));
9415
9416 var isPassportNumberValidator = /*@__PURE__*/getDefaultExportFromCjs(isPassportNumber$1.exports);
9417
9418 var IS_PASSPORT_NUMBER = 'isPassportNumber';
9419 /**
9420 * Check if the string is a valid passport number relative to a specific country code.
9421 * If given value is not a string, then it returns false.
9422 */
9423 function isPassportNumber(value, countryCode) {
9424 return typeof value === 'string' && isPassportNumberValidator(value, countryCode);
9425 }
9426 /**
9427 * Check if the string is a valid passport number relative to a specific country code.
9428 * If given value is not a string, then it returns false.
9429 */
9430 function IsPassportNumber(countryCode, validationOptions) {
9431 return ValidateBy({
9432 name: IS_PASSPORT_NUMBER,
9433 constraints: [countryCode],
9434 validator: {
9435 validate: function (value, args) { return isPassportNumber(value, args.constraints[0]); },
9436 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be valid passport number'); }, validationOptions),
9437 },
9438 }, validationOptions);
9439 }
9440
9441 var isPostalCode$2 = {};
9442
9443 Object.defineProperty(isPostalCode$2, "__esModule", {
9444 value: true
9445 });
9446 var _default = isPostalCode$2.default = isPostalCode$1;
9447 isPostalCode$2.locales = void 0;
9448
9449 var _assertString = _interopRequireDefault(assertString.exports);
9450
9451 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9452
9453 // common patterns
9454 var threeDigit = /^\d{3}$/;
9455 var fourDigit = /^\d{4}$/;
9456 var fiveDigit = /^\d{5}$/;
9457 var sixDigit = /^\d{6}$/;
9458 var patterns = {
9459 AD: /^AD\d{3}$/,
9460 AT: fourDigit,
9461 AU: fourDigit,
9462 AZ: /^AZ\d{4}$/,
9463 BE: fourDigit,
9464 BG: fourDigit,
9465 BR: /^\d{5}-\d{3}$/,
9466 BY: /2[1-4]{1}\d{4}$/,
9467 CA: /^[ABCEGHJKLMNPRSTVXY]\d[ABCEGHJ-NPRSTV-Z][\s\-]?\d[ABCEGHJ-NPRSTV-Z]\d$/i,
9468 CH: fourDigit,
9469 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}$/,
9470 CZ: /^\d{3}\s?\d{2}$/,
9471 DE: fiveDigit,
9472 DK: fourDigit,
9473 DO: fiveDigit,
9474 DZ: fiveDigit,
9475 EE: fiveDigit,
9476 ES: /^(5[0-2]{1}|[0-4]{1}\d{1})\d{3}$/,
9477 FI: fiveDigit,
9478 FR: /^\d{2}\s?\d{3}$/,
9479 GB: /^(gir\s?0aa|[a-z]{1,2}\d[\da-z]?\s?(\d[a-z]{2})?)$/i,
9480 GR: /^\d{3}\s?\d{2}$/,
9481 HR: /^([1-5]\d{4}$)/,
9482 HT: /^HT\d{4}$/,
9483 HU: fourDigit,
9484 ID: fiveDigit,
9485 IE: /^(?!.*(?:o))[A-Za-z]\d[\dw]\s\w{4}$/i,
9486 IL: /^(\d{5}|\d{7})$/,
9487 IN: /^((?!10|29|35|54|55|65|66|86|87|88|89)[1-9][0-9]{5})$/,
9488 IR: /\b(?!(\d)\1{3})[13-9]{4}[1346-9][013-9]{5}\b/,
9489 IS: threeDigit,
9490 IT: fiveDigit,
9491 JP: /^\d{3}\-\d{4}$/,
9492 KE: fiveDigit,
9493 KR: /^(\d{5}|\d{6})$/,
9494 LI: /^(948[5-9]|949[0-7])$/,
9495 LT: /^LT\-\d{5}$/,
9496 LU: fourDigit,
9497 LV: /^LV\-\d{4}$/,
9498 LK: fiveDigit,
9499 MX: fiveDigit,
9500 MT: /^[A-Za-z]{3}\s{0,1}\d{4}$/,
9501 MY: fiveDigit,
9502 NL: /^\d{4}\s?[a-z]{2}$/i,
9503 NO: fourDigit,
9504 NP: /^(10|21|22|32|33|34|44|45|56|57)\d{3}$|^(977)$/i,
9505 NZ: fourDigit,
9506 PL: /^\d{2}\-\d{3}$/,
9507 PR: /^00[679]\d{2}([ -]\d{4})?$/,
9508 PT: /^\d{4}\-\d{3}?$/,
9509 RO: sixDigit,
9510 RU: sixDigit,
9511 SA: fiveDigit,
9512 SE: /^[1-9]\d{2}\s?\d{2}$/,
9513 SG: sixDigit,
9514 SI: fourDigit,
9515 SK: /^\d{3}\s?\d{2}$/,
9516 TH: fiveDigit,
9517 TN: fourDigit,
9518 TW: /^\d{3}(\d{2})?$/,
9519 UA: fiveDigit,
9520 US: /^\d{5}(-\d{4})?$/,
9521 ZA: fourDigit,
9522 ZM: fiveDigit
9523 };
9524 var locales = Object.keys(patterns);
9525 isPostalCode$2.locales = locales;
9526
9527 function isPostalCode$1(str, locale) {
9528 (0, _assertString.default)(str);
9529
9530 if (locale in patterns) {
9531 return patterns[locale].test(str);
9532 } else if (locale === 'any') {
9533 for (var key in patterns) {
9534 // https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md#ignoring-code-for-coverage-purposes
9535 // istanbul ignore else
9536 if (patterns.hasOwnProperty(key)) {
9537 var pattern = patterns[key];
9538
9539 if (pattern.test(str)) {
9540 return true;
9541 }
9542 }
9543 }
9544
9545 return false;
9546 }
9547
9548 throw new Error("Invalid locale '".concat(locale, "'"));
9549 }
9550
9551 var IS_POSTAL_CODE = 'isPostalCode';
9552 /**
9553 * Check if the string is a postal code,
9554 * (locale is one of [ 'AD', 'AT', 'AU', 'BE', 'BG', 'BR', 'CA', 'CH', 'CZ', 'DE', 'DK', 'DZ', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HU', 'ID', 'IE' 'IL', 'IN', 'IR', 'IS', 'IT', 'JP', 'KE', 'LI', 'LT', 'LU', 'LV', 'MT', 'MX', 'NL', 'NO', 'NZ', 'PL', 'PR', 'PT', 'RO', 'RU', 'SA', 'SE', 'SI', 'TN', 'TW', 'UA', 'US', 'ZA', 'ZM' ] OR 'any'. If 'any' is used, function will check if any of the locals match. Locale list is validator.isPostalCodeLocales.).
9555 * If given value is not a string, then it returns false.
9556 */
9557 function isPostalCode(value, locale) {
9558 return typeof value === 'string' && _default(value, locale);
9559 }
9560 /**
9561 * Check if the string is a postal code,
9562 * (locale is one of [ 'AD', 'AT', 'AU', 'BE', 'BG', 'BR', 'CA', 'CH', 'CZ', 'DE', 'DK', 'DZ', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HU', 'ID', 'IE' 'IL', 'IN', 'IR', 'IS', 'IT', 'JP', 'KE', 'LI', 'LT', 'LU', 'LV', 'MT', 'MX', 'NL', 'NO', 'NZ', 'PL', 'PR', 'PT', 'RO', 'RU', 'SA', 'SE', 'SI', 'TN', 'TW', 'UA', 'US', 'ZA', 'ZM' ] OR 'any'. If 'any' is used, function will check if any of the locals match. Locale list is validator.isPostalCodeLocales.).
9563 * If given value is not a string, then it returns false.
9564 */
9565 function IsPostalCode(locale, validationOptions) {
9566 return ValidateBy({
9567 name: IS_POSTAL_CODE,
9568 constraints: [locale],
9569 validator: {
9570 validate: function (value, args) { return isPostalCode(value, args.constraints[0]); },
9571 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be a postal code'); }, validationOptions),
9572 },
9573 }, validationOptions);
9574 }
9575
9576 var isRFC3339$1 = {exports: {}};
9577
9578 (function (module, exports) {
9579
9580 Object.defineProperty(exports, "__esModule", {
9581 value: true
9582 });
9583 exports.default = isRFC3339;
9584
9585 var _assertString = _interopRequireDefault(assertString.exports);
9586
9587 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9588
9589 /* Based on https://tools.ietf.org/html/rfc3339#section-5.6 */
9590 var dateFullYear = /[0-9]{4}/;
9591 var dateMonth = /(0[1-9]|1[0-2])/;
9592 var dateMDay = /([12]\d|0[1-9]|3[01])/;
9593 var timeHour = /([01][0-9]|2[0-3])/;
9594 var timeMinute = /[0-5][0-9]/;
9595 var timeSecond = /([0-5][0-9]|60)/;
9596 var timeSecFrac = /(\.[0-9]+)?/;
9597 var timeNumOffset = new RegExp("[-+]".concat(timeHour.source, ":").concat(timeMinute.source));
9598 var timeOffset = new RegExp("([zZ]|".concat(timeNumOffset.source, ")"));
9599 var partialTime = new RegExp("".concat(timeHour.source, ":").concat(timeMinute.source, ":").concat(timeSecond.source).concat(timeSecFrac.source));
9600 var fullDate = new RegExp("".concat(dateFullYear.source, "-").concat(dateMonth.source, "-").concat(dateMDay.source));
9601 var fullTime = new RegExp("".concat(partialTime.source).concat(timeOffset.source));
9602 var rfc3339 = new RegExp("^".concat(fullDate.source, "[ tT]").concat(fullTime.source, "$"));
9603
9604 function isRFC3339(str) {
9605 (0, _assertString.default)(str);
9606 return rfc3339.test(str);
9607 }
9608
9609 module.exports = exports.default;
9610 module.exports.default = exports.default;
9611 }(isRFC3339$1, isRFC3339$1.exports));
9612
9613 var isRFC3339Validator = /*@__PURE__*/getDefaultExportFromCjs(isRFC3339$1.exports);
9614
9615 var IS_RFC_3339 = 'isRFC3339';
9616 /**
9617 * Check if the string is a valid RFC 3339 date.
9618 * If given value is not a string, then it returns false.
9619 */
9620 function isRFC3339(value) {
9621 return typeof value === 'string' && isRFC3339Validator(value);
9622 }
9623 /**
9624 * Check if the string is a valid RFC 3339 date.
9625 * If given value is not a string, then it returns false.
9626 */
9627 function IsRFC3339(validationOptions) {
9628 return ValidateBy({
9629 name: IS_RFC_3339,
9630 validator: {
9631 validate: function (value, args) { return isRFC3339(value); },
9632 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be RFC 3339 date'); }, validationOptions),
9633 },
9634 }, validationOptions);
9635 }
9636
9637 var isRgbColor$1 = {exports: {}};
9638
9639 (function (module, exports) {
9640
9641 Object.defineProperty(exports, "__esModule", {
9642 value: true
9643 });
9644 exports.default = isRgbColor;
9645
9646 var _assertString = _interopRequireDefault(assertString.exports);
9647
9648 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9649
9650 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])\)$/;
9651 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)?)\)$/;
9652 var rgbColorPercent = /^rgb\((([0-9]%|[1-9][0-9]%|100%),){2}([0-9]%|[1-9][0-9]%|100%)\)/;
9653 var rgbaColorPercent = /^rgba\((([0-9]%|[1-9][0-9]%|100%),){3}(0?\.\d|1(\.0)?|0(\.0)?)\)/;
9654
9655 function isRgbColor(str) {
9656 var includePercentValues = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
9657 (0, _assertString.default)(str);
9658
9659 if (!includePercentValues) {
9660 return rgbColor.test(str) || rgbaColor.test(str);
9661 }
9662
9663 return rgbColor.test(str) || rgbaColor.test(str) || rgbColorPercent.test(str) || rgbaColorPercent.test(str);
9664 }
9665
9666 module.exports = exports.default;
9667 module.exports.default = exports.default;
9668 }(isRgbColor$1, isRgbColor$1.exports));
9669
9670 var isRgbColorValidator = /*@__PURE__*/getDefaultExportFromCjs(isRgbColor$1.exports);
9671
9672 var IS_RGB_COLOR = 'isRgbColor';
9673 /**
9674 * Check if the string is a rgb or rgba color.
9675 * `includePercentValues` defaults to true. If you don't want to allow to set rgb or rgba values with percents, like rgb(5%,5%,5%), or rgba(90%,90%,90%,.3), then set it to false.
9676 * If given value is not a string, then it returns false.
9677 */
9678 function isRgbColor(value, includePercentValues) {
9679 return typeof value === 'string' && isRgbColorValidator(value, includePercentValues);
9680 }
9681 /**
9682 * Check if the string is a rgb or rgba color.
9683 * `includePercentValues` defaults to true. If you don't want to allow to set rgb or rgba values with percents, like rgb(5%,5%,5%), or rgba(90%,90%,90%,.3), then set it to false.
9684 * If given value is not a string, then it returns false.
9685 */
9686 function IsRgbColor(includePercentValues, validationOptions) {
9687 return ValidateBy({
9688 name: IS_RGB_COLOR,
9689 constraints: [includePercentValues],
9690 validator: {
9691 validate: function (value, args) { return isRgbColor(value, args.constraints[0]); },
9692 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be RGB color'); }, validationOptions),
9693 },
9694 }, validationOptions);
9695 }
9696
9697 var isSemVer$1 = {exports: {}};
9698
9699 var multilineRegex = {exports: {}};
9700
9701 (function (module, exports) {
9702
9703 Object.defineProperty(exports, "__esModule", {
9704 value: true
9705 });
9706 exports.default = multilineRegexp;
9707
9708 /**
9709 * Build RegExp object from an array
9710 * of multiple/multi-line regexp parts
9711 *
9712 * @param {string[]} parts
9713 * @param {string} flags
9714 * @return {object} - RegExp object
9715 */
9716 function multilineRegexp(parts, flags) {
9717 var regexpAsStringLiteral = parts.join('');
9718 return new RegExp(regexpAsStringLiteral, flags);
9719 }
9720
9721 module.exports = exports.default;
9722 module.exports.default = exports.default;
9723 }(multilineRegex, multilineRegex.exports));
9724
9725 (function (module, exports) {
9726
9727 Object.defineProperty(exports, "__esModule", {
9728 value: true
9729 });
9730 exports.default = isSemVer;
9731
9732 var _assertString = _interopRequireDefault(assertString.exports);
9733
9734 var _multilineRegex = _interopRequireDefault(multilineRegex.exports);
9735
9736 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9737
9738 /**
9739 * Regular Expression to match
9740 * semantic versioning (SemVer)
9741 * built from multi-line, multi-parts regexp
9742 * Reference: https://semver.org/
9743 */
9744 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');
9745
9746 function isSemVer(str) {
9747 (0, _assertString.default)(str);
9748 return semanticVersioningRegex.test(str);
9749 }
9750
9751 module.exports = exports.default;
9752 module.exports.default = exports.default;
9753 }(isSemVer$1, isSemVer$1.exports));
9754
9755 var isSemVerValidator = /*@__PURE__*/getDefaultExportFromCjs(isSemVer$1.exports);
9756
9757 var IS_SEM_VER = 'isSemVer';
9758 /**
9759 * Check if the string is a Semantic Versioning Specification (SemVer).
9760 * If given value is not a string, then it returns false.
9761 */
9762 function isSemVer(value) {
9763 return typeof value === 'string' && isSemVerValidator(value);
9764 }
9765 /**
9766 * Check if the string is a Semantic Versioning Specification (SemVer).
9767 * If given value is not a string, then it returns false.
9768 */
9769 function IsSemVer(validationOptions) {
9770 return ValidateBy({
9771 name: IS_SEM_VER,
9772 validator: {
9773 validate: function (value, args) { return isSemVer(value); },
9774 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be a Semantic Versioning Specification'); }, validationOptions),
9775 },
9776 }, validationOptions);
9777 }
9778
9779 var IS_BOOLEAN = 'isBoolean';
9780 /**
9781 * Checks if a given value is a boolean.
9782 */
9783 function isBoolean(value) {
9784 return value instanceof Boolean || typeof value === 'boolean';
9785 }
9786 /**
9787 * Checks if a value is a boolean.
9788 */
9789 function IsBoolean(validationOptions) {
9790 return ValidateBy({
9791 name: IS_BOOLEAN,
9792 validator: {
9793 validate: function (value, args) { return isBoolean(value); },
9794 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be a boolean value'); }, validationOptions),
9795 },
9796 }, validationOptions);
9797 }
9798
9799 var IS_DATE = 'isDate';
9800 /**
9801 * Checks if a given value is a date.
9802 */
9803 function isDate(value) {
9804 return value instanceof Date && !isNaN(value.getTime());
9805 }
9806 /**
9807 * Checks if a value is a date.
9808 */
9809 function IsDate(validationOptions) {
9810 return ValidateBy({
9811 name: IS_DATE,
9812 validator: {
9813 validate: function (value, args) { return isDate(value); },
9814 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be a Date instance'); }, validationOptions),
9815 },
9816 }, validationOptions);
9817 }
9818
9819 var IS_NUMBER = 'isNumber';
9820 /**
9821 * Checks if a given value is a number.
9822 */
9823 function isNumber(value, options) {
9824 if (options === void 0) { options = {}; }
9825 if (typeof value !== 'number') {
9826 return false;
9827 }
9828 if (value === Infinity || value === -Infinity) {
9829 return options.allowInfinity;
9830 }
9831 if (Number.isNaN(value)) {
9832 return options.allowNaN;
9833 }
9834 if (options.maxDecimalPlaces !== undefined) {
9835 var decimalPlaces = 0;
9836 if (value % 1 !== 0) {
9837 decimalPlaces = value.toString().split('.')[1].length;
9838 }
9839 if (decimalPlaces > options.maxDecimalPlaces) {
9840 return false;
9841 }
9842 }
9843 return Number.isFinite(value);
9844 }
9845 /**
9846 * Checks if a value is a number.
9847 */
9848 function IsNumber(options, validationOptions) {
9849 if (options === void 0) { options = {}; }
9850 return ValidateBy({
9851 name: IS_NUMBER,
9852 constraints: [options],
9853 validator: {
9854 validate: function (value, args) { return isNumber(value, args.constraints[0]); },
9855 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be a number conforming to the specified constraints'); }, validationOptions),
9856 },
9857 }, validationOptions);
9858 }
9859
9860 var IS_ENUM = 'isEnum';
9861 /**
9862 * Checks if a given value is an enum
9863 */
9864 function isEnum(value, entity) {
9865 var enumValues = Object.keys(entity).map(function (k) { return entity[k]; });
9866 return enumValues.indexOf(value) >= 0;
9867 }
9868 /**
9869 * Checks if a given value is an enum
9870 */
9871 function IsEnum(entity, validationOptions) {
9872 return ValidateBy({
9873 name: IS_ENUM,
9874 constraints: [entity],
9875 validator: {
9876 validate: function (value, args) { return isEnum(value, args.constraints[0]); },
9877 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be a valid enum value'); }, validationOptions),
9878 },
9879 }, validationOptions);
9880 }
9881
9882 var IS_INT = 'isInt';
9883 /**
9884 * Checks if value is an integer.
9885 */
9886 function isInt(val) {
9887 return typeof val === 'number' && Number.isInteger(val);
9888 }
9889 /**
9890 * Checks if value is an integer.
9891 */
9892 function IsInt(validationOptions) {
9893 return ValidateBy({
9894 name: IS_INT,
9895 validator: {
9896 validate: function (value, args) { return isInt(value); },
9897 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be an integer number'); }, validationOptions),
9898 },
9899 }, validationOptions);
9900 }
9901
9902 var IS_STRING = 'isString';
9903 /**
9904 * Checks if a given value is a real string.
9905 */
9906 function isString(value) {
9907 return value instanceof String || typeof value === 'string';
9908 }
9909 /**
9910 * Checks if a given value is a real string.
9911 */
9912 function IsString(validationOptions) {
9913 return ValidateBy({
9914 name: IS_STRING,
9915 validator: {
9916 validate: function (value, args) { return isString(value); },
9917 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be a string'); }, validationOptions),
9918 },
9919 }, validationOptions);
9920 }
9921
9922 var IS_ARRAY = 'isArray';
9923 /**
9924 * Checks if a given value is an array
9925 */
9926 function isArray(value) {
9927 return Array.isArray(value);
9928 }
9929 /**
9930 * Checks if a given value is an array
9931 */
9932 function IsArray(validationOptions) {
9933 return ValidateBy({
9934 name: IS_ARRAY,
9935 validator: {
9936 validate: function (value, args) { return isArray(value); },
9937 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be an array'); }, validationOptions),
9938 },
9939 }, validationOptions);
9940 }
9941
9942 var IS_OBJECT = 'isObject';
9943 /**
9944 * Checks if the value is valid Object.
9945 * Returns false if the value is not an object.
9946 */
9947 function isObject(value) {
9948 return value != null && (typeof value === 'object' || typeof value === 'function') && !Array.isArray(value);
9949 }
9950 /**
9951 * Checks if the value is valid Object.
9952 * Returns false if the value is not an object.
9953 */
9954 function IsObject(validationOptions) {
9955 return ValidateBy({
9956 name: IS_OBJECT,
9957 validator: {
9958 validate: function (value, args) { return isObject(value); },
9959 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be an object'); }, validationOptions),
9960 },
9961 }, validationOptions);
9962 }
9963
9964 var ARRAY_CONTAINS = 'arrayContains';
9965 /**
9966 * Checks if array contains all values from the given array of values.
9967 * If null or undefined is given then this function returns false.
9968 */
9969 function arrayContains(array, values) {
9970 if (!Array.isArray(array))
9971 return false;
9972 return values.every(function (value) { return array.indexOf(value) !== -1; });
9973 }
9974 /**
9975 * Checks if array contains all values from the given array of values.
9976 * If null or undefined is given then this function returns false.
9977 */
9978 function ArrayContains(values, validationOptions) {
9979 return ValidateBy({
9980 name: ARRAY_CONTAINS,
9981 constraints: [values],
9982 validator: {
9983 validate: function (value, args) { return arrayContains(value, args.constraints[0]); },
9984 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must contain $constraint1 values'); }, validationOptions),
9985 },
9986 }, validationOptions);
9987 }
9988
9989 var ARRAY_NOT_CONTAINS = 'arrayNotContains';
9990 /**
9991 * Checks if array does not contain any of the given values.
9992 * If null or undefined is given then this function returns false.
9993 */
9994 function arrayNotContains(array, values) {
9995 if (!Array.isArray(array))
9996 return false;
9997 return values.every(function (value) { return array.indexOf(value) === -1; });
9998 }
9999 /**
10000 * Checks if array does not contain any of the given values.
10001 * If null or undefined is given then this function returns false.
10002 */
10003 function ArrayNotContains(values, validationOptions) {
10004 return ValidateBy({
10005 name: ARRAY_NOT_CONTAINS,
10006 constraints: [values],
10007 validator: {
10008 validate: function (value, args) { return arrayNotContains(value, args.constraints[0]); },
10009 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property should not contain $constraint1 values'); }, validationOptions),
10010 },
10011 }, validationOptions);
10012 }
10013
10014 var ARRAY_NOT_EMPTY = 'arrayNotEmpty';
10015 /**
10016 * Checks if given array is not empty.
10017 * If null or undefined is given then this function returns false.
10018 */
10019 function arrayNotEmpty(array) {
10020 return Array.isArray(array) && array.length > 0;
10021 }
10022 /**
10023 * Checks if given array is not empty.
10024 * If null or undefined is given then this function returns false.
10025 */
10026 function ArrayNotEmpty(validationOptions) {
10027 return ValidateBy({
10028 name: ARRAY_NOT_EMPTY,
10029 validator: {
10030 validate: function (value, args) { return arrayNotEmpty(value); },
10031 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property should not be empty'); }, validationOptions),
10032 },
10033 }, validationOptions);
10034 }
10035
10036 var ARRAY_MIN_SIZE = 'arrayMinSize';
10037 /**
10038 * Checks if the array's length is greater than or equal to the specified number.
10039 * If null or undefined is given then this function returns false.
10040 */
10041 function arrayMinSize(array, min) {
10042 return Array.isArray(array) && array.length >= min;
10043 }
10044 /**
10045 * Checks if the array's length is greater than or equal to the specified number.
10046 * If null or undefined is given then this function returns false.
10047 */
10048 function ArrayMinSize(min, validationOptions) {
10049 return ValidateBy({
10050 name: ARRAY_MIN_SIZE,
10051 constraints: [min],
10052 validator: {
10053 validate: function (value, args) { return arrayMinSize(value, args.constraints[0]); },
10054 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must contain at least $constraint1 elements'); }, validationOptions),
10055 },
10056 }, validationOptions);
10057 }
10058
10059 var ARRAY_MAX_SIZE = 'arrayMaxSize';
10060 /**
10061 * Checks if the array's length is less or equal to the specified number.
10062 * If null or undefined is given then this function returns false.
10063 */
10064 function arrayMaxSize(array, max) {
10065 return Array.isArray(array) && array.length <= max;
10066 }
10067 /**
10068 * Checks if the array's length is less or equal to the specified number.
10069 * If null or undefined is given then this function returns false.
10070 */
10071 function ArrayMaxSize(max, validationOptions) {
10072 return ValidateBy({
10073 name: ARRAY_MAX_SIZE,
10074 constraints: [max],
10075 validator: {
10076 validate: function (value, args) { return arrayMaxSize(value, args.constraints[0]); },
10077 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must contain not more than $constraint1 elements'); }, validationOptions),
10078 },
10079 }, validationOptions);
10080 }
10081
10082 var ARRAY_UNIQUE = 'arrayUnique';
10083 /**
10084 * Checks if all array's values are unique. Comparison for objects is reference-based.
10085 * If null or undefined is given then this function returns false.
10086 */
10087 function arrayUnique(array, identifier) {
10088 if (!Array.isArray(array))
10089 return false;
10090 if (identifier) {
10091 array = array.map(function (o) { return (o != null ? identifier(o) : o); });
10092 }
10093 if (identifier) {
10094 array = array.map(function (o) { return (o != null ? identifier(o) : o); });
10095 }
10096 var uniqueItems = array.filter(function (a, b, c) { return c.indexOf(a) === b; });
10097 return array.length === uniqueItems.length;
10098 }
10099 /**
10100 * Checks if all array's values are unique. Comparison for objects is reference-based.
10101 * If null or undefined is given then this function returns false.
10102 */
10103 function ArrayUnique(identifierOrOptions, validationOptions) {
10104 var identifier = typeof identifierOrOptions === 'function' ? identifierOrOptions : undefined;
10105 var options = typeof identifierOrOptions !== 'function' ? identifierOrOptions : validationOptions;
10106 return ValidateBy({
10107 name: ARRAY_UNIQUE,
10108 validator: {
10109 validate: function (value, args) { return arrayUnique(value, identifier); },
10110 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText("All $property's elements must be unique"); }, options),
10111 },
10112 }, options);
10113 }
10114
10115 var IS_NOT_EMPTY_OBJECT = 'isNotEmptyObject';
10116 /**
10117 * Checks if the value is valid Object & not empty.
10118 * Returns false if the value is not an object or an empty valid object.
10119 */
10120 function isNotEmptyObject(value, options) {
10121 if (!isObject(value)) {
10122 return false;
10123 }
10124 if ((options === null || options === void 0 ? void 0 : options.nullable) === true) {
10125 return !Object.values(value).every(function (propertyValue) { return propertyValue === null || propertyValue === undefined; });
10126 }
10127 for (var key in value) {
10128 if (value.hasOwnProperty(key)) {
10129 return true;
10130 }
10131 }
10132 return false;
10133 }
10134 /**
10135 * Checks if the value is valid Object & not empty.
10136 * Returns false if the value is not an object or an empty valid object.
10137 */
10138 function IsNotEmptyObject(options, validationOptions) {
10139 return ValidateBy({
10140 name: IS_NOT_EMPTY_OBJECT,
10141 constraints: [options],
10142 validator: {
10143 validate: function (value, args) { return isNotEmptyObject(value, args.constraints[0]); },
10144 defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be a non-empty object'); }, validationOptions),
10145 },
10146 }, validationOptions);
10147 }
10148
10149 var IS_INSTANCE = 'isInstance';
10150 /**
10151 * Checks if the value is an instance of the specified object.
10152 */
10153 function isInstance(object, targetTypeConstructor) {
10154 return (targetTypeConstructor && typeof targetTypeConstructor === 'function' && object instanceof targetTypeConstructor);
10155 }
10156 /**
10157 * Checks if the value is an instance of the specified object.
10158 */
10159 function IsInstance(targetType, validationOptions) {
10160 return ValidateBy({
10161 name: IS_INSTANCE,
10162 constraints: [targetType],
10163 validator: {
10164 validate: function (value, args) { return isInstance(value, args.constraints[0]); },
10165 defaultMessage: buildMessage(function (eachPrefix, args) {
10166 if (args.constraints[0]) {
10167 return (eachPrefix +
10168 getText("$property must be an instance of $constraint1name").replace('$constraint1name', (args && args.constraints && args.constraints[0].name)));
10169 }
10170 else {
10171 return (eachPrefix +
10172 getText("$IS_INSTANCE decorator expects and object as value, but got falsy value.").replace('$IS_INSTANCE', IS_INSTANCE));
10173 }
10174 }, validationOptions),
10175 },
10176 }, validationOptions);
10177 }
10178
10179 /**
10180 * Validates given object by object's decorators or given validation schema.
10181 */
10182 function validate(schemaNameOrObject, objectOrValidationOptions, maybeValidatorOptions) {
10183 if (typeof schemaNameOrObject === 'string') {
10184 return getFromContainer(Validator).validate(schemaNameOrObject, objectOrValidationOptions, maybeValidatorOptions);
10185 }
10186 else {
10187 return getFromContainer(Validator).validate(schemaNameOrObject, objectOrValidationOptions);
10188 }
10189 }
10190 /**
10191 * Validates given object by object's decorators or given validation schema and reject on error.
10192 */
10193 function validateOrReject(schemaNameOrObject, objectOrValidationOptions, maybeValidatorOptions) {
10194 if (typeof schemaNameOrObject === 'string') {
10195 return getFromContainer(Validator).validateOrReject(schemaNameOrObject, objectOrValidationOptions, maybeValidatorOptions);
10196 }
10197 else {
10198 return getFromContainer(Validator).validateOrReject(schemaNameOrObject, objectOrValidationOptions);
10199 }
10200 }
10201 /**
10202 * Validates given object by object's decorators or given validation schema.
10203 * Note that this method completely ignores async validations.
10204 * If you want to properly perform validation you need to call validate method instead.
10205 */
10206 function validateSync(schemaNameOrObject, objectOrValidationOptions, maybeValidatorOptions) {
10207 if (typeof schemaNameOrObject === 'string') {
10208 return getFromContainer(Validator).validateSync(schemaNameOrObject, objectOrValidationOptions, maybeValidatorOptions);
10209 }
10210 else {
10211 return getFromContainer(Validator).validateSync(schemaNameOrObject, objectOrValidationOptions);
10212 }
10213 }
10214 /**
10215 * Registers a new validation schema.
10216 */
10217 function registerSchema(schema) {
10218 getMetadataStorage().addValidationSchema(schema);
10219 }
10220
10221 exports.ARRAY_CONTAINS = ARRAY_CONTAINS;
10222 exports.ARRAY_MAX_SIZE = ARRAY_MAX_SIZE;
10223 exports.ARRAY_MIN_SIZE = ARRAY_MIN_SIZE;
10224 exports.ARRAY_NOT_CONTAINS = ARRAY_NOT_CONTAINS;
10225 exports.ARRAY_NOT_EMPTY = ARRAY_NOT_EMPTY;
10226 exports.ARRAY_UNIQUE = ARRAY_UNIQUE;
10227 exports.Allow = Allow;
10228 exports.ArrayContains = ArrayContains;
10229 exports.ArrayMaxSize = ArrayMaxSize;
10230 exports.ArrayMinSize = ArrayMinSize;
10231 exports.ArrayNotContains = ArrayNotContains;
10232 exports.ArrayNotEmpty = ArrayNotEmpty;
10233 exports.ArrayUnique = ArrayUnique;
10234 exports.CONTAINS = CONTAINS;
10235 exports.ClassPropertyTitle = ClassPropertyTitle;
10236 exports.ClassTitle = ClassTitle;
10237 exports.ConstraintMetadata = ConstraintMetadata;
10238 exports.Contains = Contains;
10239 exports.EQUALS = EQUALS;
10240 exports.Equals = Equals;
10241 exports.IS_ALPHA = IS_ALPHA;
10242 exports.IS_ALPHANUMERIC = IS_ALPHANUMERIC;
10243 exports.IS_ARRAY = IS_ARRAY;
10244 exports.IS_ASCII = IS_ASCII;
10245 exports.IS_BASE32 = IS_BASE32;
10246 exports.IS_BASE64 = IS_BASE64;
10247 exports.IS_BIC = IS_BIC;
10248 exports.IS_BOOLEAN = IS_BOOLEAN;
10249 exports.IS_BOOLEAN_STRING = IS_BOOLEAN_STRING;
10250 exports.IS_BTC_ADDRESS = IS_BTC_ADDRESS;
10251 exports.IS_BYTE_LENGTH = IS_BYTE_LENGTH;
10252 exports.IS_CREDIT_CARD = IS_CREDIT_CARD;
10253 exports.IS_CURRENCY = IS_CURRENCY;
10254 exports.IS_DATA_URI = IS_DATA_URI;
10255 exports.IS_DATE = IS_DATE;
10256 exports.IS_DATE_STRING = IS_DATE_STRING;
10257 exports.IS_DECIMAL = IS_DECIMAL;
10258 exports.IS_DEFINED = IS_DEFINED;
10259 exports.IS_DIVISIBLE_BY = IS_DIVISIBLE_BY;
10260 exports.IS_EAN = IS_EAN;
10261 exports.IS_EMAIL = IS_EMAIL;
10262 exports.IS_EMPTY = IS_EMPTY;
10263 exports.IS_ENUM = IS_ENUM;
10264 exports.IS_ETHEREUM_ADDRESS = IS_ETHEREUM_ADDRESS;
10265 exports.IS_FIREBASE_PUSH_ID = IS_FIREBASE_PUSH_ID;
10266 exports.IS_FQDN = IS_FQDN;
10267 exports.IS_FULL_WIDTH = IS_FULL_WIDTH;
10268 exports.IS_HALF_WIDTH = IS_HALF_WIDTH;
10269 exports.IS_HASH = IS_HASH;
10270 exports.IS_HEXADECIMAL = IS_HEXADECIMAL;
10271 exports.IS_HEX_COLOR = IS_HEX_COLOR;
10272 exports.IS_HSL = IS_HSL;
10273 exports.IS_IBAN = IS_IBAN;
10274 exports.IS_IDENTITY_CARD = IS_IDENTITY_CARD;
10275 exports.IS_IN = IS_IN;
10276 exports.IS_INSTANCE = IS_INSTANCE;
10277 exports.IS_INT = IS_INT;
10278 exports.IS_IP = IS_IP;
10279 exports.IS_ISBN = IS_ISBN;
10280 exports.IS_ISIN = IS_ISIN;
10281 exports.IS_ISO31661_ALPHA_2 = IS_ISO31661_ALPHA_2;
10282 exports.IS_ISO31661_ALPHA_3 = IS_ISO31661_ALPHA_3;
10283 exports.IS_ISO8601 = IS_ISO8601;
10284 exports.IS_ISRC = IS_ISRC;
10285 exports.IS_ISSN = IS_ISSN;
10286 exports.IS_JSON = IS_JSON;
10287 exports.IS_JWT = IS_JWT;
10288 exports.IS_LATITUDE = IS_LATITUDE;
10289 exports.IS_LATLONG = IS_LATLONG;
10290 exports.IS_LENGTH = IS_LENGTH;
10291 exports.IS_LOCALE = IS_LOCALE;
10292 exports.IS_LONGITUDE = IS_LONGITUDE;
10293 exports.IS_LOWERCASE = IS_LOWERCASE;
10294 exports.IS_MAC_ADDRESS = IS_MAC_ADDRESS;
10295 exports.IS_MAGNET_URI = IS_MAGNET_URI;
10296 exports.IS_MILITARY_TIME = IS_MILITARY_TIME;
10297 exports.IS_MIME_TYPE = IS_MIME_TYPE;
10298 exports.IS_MOBILE_PHONE = IS_MOBILE_PHONE;
10299 exports.IS_MONGO_ID = IS_MONGO_ID;
10300 exports.IS_MULTIBYTE = IS_MULTIBYTE;
10301 exports.IS_NEGATIVE = IS_NEGATIVE;
10302 exports.IS_NOT_EMPTY = IS_NOT_EMPTY;
10303 exports.IS_NOT_EMPTY_OBJECT = IS_NOT_EMPTY_OBJECT;
10304 exports.IS_NOT_IN = IS_NOT_IN;
10305 exports.IS_NUMBER = IS_NUMBER;
10306 exports.IS_NUMBER_STRING = IS_NUMBER_STRING;
10307 exports.IS_OBJECT = IS_OBJECT;
10308 exports.IS_OCTAL = IS_OCTAL;
10309 exports.IS_PASSPORT_NUMBER = IS_PASSPORT_NUMBER;
10310 exports.IS_PHONE_NUMBER = IS_PHONE_NUMBER;
10311 exports.IS_PORT = IS_PORT;
10312 exports.IS_POSITIVE = IS_POSITIVE;
10313 exports.IS_POSTAL_CODE = IS_POSTAL_CODE;
10314 exports.IS_RFC_3339 = IS_RFC_3339;
10315 exports.IS_RGB_COLOR = IS_RGB_COLOR;
10316 exports.IS_SEM_VER = IS_SEM_VER;
10317 exports.IS_STRING = IS_STRING;
10318 exports.IS_SURROGATE_PAIR = IS_SURROGATE_PAIR;
10319 exports.IS_UPPERCASE = IS_UPPERCASE;
10320 exports.IS_URL = IS_URL;
10321 exports.IS_UUID = IS_UUID;
10322 exports.IS_VARIABLE_WIDTH = IS_VARIABLE_WIDTH;
10323 exports.IsAlpha = IsAlpha;
10324 exports.IsAlphanumeric = IsAlphanumeric;
10325 exports.IsArray = IsArray;
10326 exports.IsAscii = IsAscii;
10327 exports.IsBIC = IsBIC;
10328 exports.IsBase32 = IsBase32;
10329 exports.IsBase64 = IsBase64;
10330 exports.IsBoolean = IsBoolean;
10331 exports.IsBooleanString = IsBooleanString;
10332 exports.IsBtcAddress = IsBtcAddress;
10333 exports.IsByteLength = IsByteLength;
10334 exports.IsCreditCard = IsCreditCard;
10335 exports.IsCurrency = IsCurrency;
10336 exports.IsDataURI = IsDataURI;
10337 exports.IsDate = IsDate;
10338 exports.IsDateString = IsDateString;
10339 exports.IsDecimal = IsDecimal;
10340 exports.IsDefined = IsDefined;
10341 exports.IsDivisibleBy = IsDivisibleBy;
10342 exports.IsEAN = IsEAN;
10343 exports.IsEmail = IsEmail;
10344 exports.IsEmpty = IsEmpty;
10345 exports.IsEnum = IsEnum;
10346 exports.IsEthereumAddress = IsEthereumAddress;
10347 exports.IsFQDN = IsFQDN;
10348 exports.IsFirebasePushId = IsFirebasePushId;
10349 exports.IsFullWidth = IsFullWidth;
10350 exports.IsHSL = IsHSL;
10351 exports.IsHalfWidth = IsHalfWidth;
10352 exports.IsHash = IsHash;
10353 exports.IsHexColor = IsHexColor;
10354 exports.IsHexadecimal = IsHexadecimal;
10355 exports.IsIBAN = IsIBAN;
10356 exports.IsIP = IsIP;
10357 exports.IsISBN = IsISBN;
10358 exports.IsISIN = IsISIN;
10359 exports.IsISO31661Alpha2 = IsISO31661Alpha2;
10360 exports.IsISO31661Alpha3 = IsISO31661Alpha3;
10361 exports.IsISO8601 = IsISO8601;
10362 exports.IsISRC = IsISRC;
10363 exports.IsISSN = IsISSN;
10364 exports.IsIdentityCard = IsIdentityCard;
10365 exports.IsIn = IsIn;
10366 exports.IsInstance = IsInstance;
10367 exports.IsInt = IsInt;
10368 exports.IsJSON = IsJSON;
10369 exports.IsJWT = IsJWT;
10370 exports.IsLatLong = IsLatLong;
10371 exports.IsLatitude = IsLatitude;
10372 exports.IsLocale = IsLocale;
10373 exports.IsLongitude = IsLongitude;
10374 exports.IsLowercase = IsLowercase;
10375 exports.IsMACAddress = IsMACAddress;
10376 exports.IsMagnetURI = IsMagnetURI;
10377 exports.IsMilitaryTime = IsMilitaryTime;
10378 exports.IsMimeType = IsMimeType;
10379 exports.IsMobilePhone = IsMobilePhone;
10380 exports.IsMongoId = IsMongoId;
10381 exports.IsMultibyte = IsMultibyte;
10382 exports.IsNegative = IsNegative;
10383 exports.IsNotEmpty = IsNotEmpty;
10384 exports.IsNotEmptyObject = IsNotEmptyObject;
10385 exports.IsNotIn = IsNotIn;
10386 exports.IsNumber = IsNumber;
10387 exports.IsNumberString = IsNumberString;
10388 exports.IsObject = IsObject;
10389 exports.IsOctal = IsOctal;
10390 exports.IsOptional = IsOptional;
10391 exports.IsPassportNumber = IsPassportNumber;
10392 exports.IsPhoneNumber = IsPhoneNumber;
10393 exports.IsPort = IsPort;
10394 exports.IsPositive = IsPositive;
10395 exports.IsPostalCode = IsPostalCode;
10396 exports.IsRFC3339 = IsRFC3339;
10397 exports.IsRgbColor = IsRgbColor;
10398 exports.IsSemVer = IsSemVer;
10399 exports.IsString = IsString;
10400 exports.IsSurrogatePair = IsSurrogatePair;
10401 exports.IsUUID = IsUUID;
10402 exports.IsUppercase = IsUppercase;
10403 exports.IsUrl = IsUrl;
10404 exports.IsVariableWidth = IsVariableWidth;
10405 exports.Length = Length;
10406 exports.MATCHES = MATCHES;
10407 exports.MAX = MAX;
10408 exports.MAX_DATE = MAX_DATE;
10409 exports.MAX_LENGTH = MAX_LENGTH;
10410 exports.MIN = MIN;
10411 exports.MIN_DATE = MIN_DATE;
10412 exports.MIN_LENGTH = MIN_LENGTH;
10413 exports.Matches = Matches;
10414 exports.Max = Max;
10415 exports.MaxDate = MaxDate;
10416 exports.MaxLength = MaxLength;
10417 exports.MetadataStorage = MetadataStorage;
10418 exports.Min = Min;
10419 exports.MinDate = MinDate;
10420 exports.MinLength = MinLength;
10421 exports.NOT_CONTAINS = NOT_CONTAINS;
10422 exports.NOT_EQUALS = NOT_EQUALS;
10423 exports.NotContains = NotContains;
10424 exports.NotEquals = NotEquals;
10425 exports.Validate = Validate;
10426 exports.ValidateBy = ValidateBy;
10427 exports.ValidateIf = ValidateIf;
10428 exports.ValidateNested = ValidateNested;
10429 exports.ValidatePromise = ValidatePromise;
10430 exports.ValidationError = ValidationError;
10431 exports.ValidationMetadata = ValidationMetadata;
10432 exports.ValidationTypes = ValidationTypes;
10433 exports.Validator = Validator;
10434 exports.ValidatorConstraint = ValidatorConstraint;
10435 exports.arrayContains = arrayContains;
10436 exports.arrayMaxSize = arrayMaxSize;
10437 exports.arrayMinSize = arrayMinSize;
10438 exports.arrayNotContains = arrayNotContains;
10439 exports.arrayNotEmpty = arrayNotEmpty;
10440 exports.arrayUnique = arrayUnique;
10441 exports.buildMessage = buildMessage;
10442 exports.contains = contains;
10443 exports.equals = equals;
10444 exports.getClassValidatorMessage = getClassValidatorMessage;
10445 exports.getClassValidatorMessages = getClassValidatorMessages;
10446 exports.getClassValidatorMessagesStorage = getClassValidatorMessagesStorage;
10447 exports.getClassValidatorPropertyTitle = getClassValidatorPropertyTitle;
10448 exports.getClassValidatorPropertyTitles = getClassValidatorPropertyTitles;
10449 exports.getClassValidatorPropertyTitlesStorage = getClassValidatorPropertyTitlesStorage;
10450 exports.getClassValidatorTitle = getClassValidatorTitle;
10451 exports.getClassValidatorTitles = getClassValidatorTitles;
10452 exports.getClassValidatorTitlesStorage = getClassValidatorTitlesStorage;
10453 exports.getFromContainer = getFromContainer;
10454 exports.getMetadataStorage = getMetadataStorage;
10455 exports.getText = getText;
10456 exports.isAlpha = isAlpha;
10457 exports.isAlphanumeric = isAlphanumeric;
10458 exports.isArray = isArray;
10459 exports.isAscii = isAscii;
10460 exports.isBIC = isBIC;
10461 exports.isBase32 = isBase32;
10462 exports.isBase64 = isBase64;
10463 exports.isBoolean = isBoolean;
10464 exports.isBooleanString = isBooleanString;
10465 exports.isBtcAddress = isBtcAddress;
10466 exports.isByteLength = isByteLength;
10467 exports.isCreditCard = isCreditCard;
10468 exports.isCurrency = isCurrency;
10469 exports.isDataURI = isDataURI;
10470 exports.isDate = isDate;
10471 exports.isDateString = isDateString;
10472 exports.isDecimal = isDecimal;
10473 exports.isDefined = isDefined;
10474 exports.isDivisibleBy = isDivisibleBy;
10475 exports.isEAN = isEAN;
10476 exports.isEmail = isEmail;
10477 exports.isEmpty = isEmpty;
10478 exports.isEnum = isEnum;
10479 exports.isEthereumAddress = isEthereumAddress;
10480 exports.isFQDN = isFQDN;
10481 exports.isFirebasePushId = isFirebasePushId;
10482 exports.isFullWidth = isFullWidth;
10483 exports.isHSL = isHSL;
10484 exports.isHalfWidth = isHalfWidth;
10485 exports.isHash = isHash;
10486 exports.isHexColor = isHexColor;
10487 exports.isHexadecimal = isHexadecimal;
10488 exports.isIBAN = isIBAN;
10489 exports.isIP = isIP;
10490 exports.isISBN = isISBN;
10491 exports.isISIN = isISIN;
10492 exports.isISO31661Alpha2 = isISO31661Alpha2;
10493 exports.isISO31661Alpha3 = isISO31661Alpha3;
10494 exports.isISO8601 = isISO8601;
10495 exports.isISRC = isISRC;
10496 exports.isISSN = isISSN;
10497 exports.isIdentityCard = isIdentityCard;
10498 exports.isIn = isIn;
10499 exports.isInstance = isInstance;
10500 exports.isInt = isInt;
10501 exports.isJSON = isJSON;
10502 exports.isJWT = isJWT;
10503 exports.isLatLong = isLatLong;
10504 exports.isLatitude = isLatitude;
10505 exports.isLocale = isLocale;
10506 exports.isLongitude = isLongitude;
10507 exports.isLowercase = isLowercase;
10508 exports.isMACAddress = isMACAddress;
10509 exports.isMagnetURI = isMagnetURI;
10510 exports.isMilitaryTime = isMilitaryTime;
10511 exports.isMimeType = isMimeType;
10512 exports.isMobilePhone = isMobilePhone;
10513 exports.isMongoId = isMongoId;
10514 exports.isMultibyte = isMultibyte;
10515 exports.isNegative = isNegative;
10516 exports.isNotEmpty = isNotEmpty;
10517 exports.isNotEmptyObject = isNotEmptyObject;
10518 exports.isNotIn = isNotIn;
10519 exports.isNumber = isNumber;
10520 exports.isNumberString = isNumberString;
10521 exports.isObject = isObject;
10522 exports.isOctal = isOctal;
10523 exports.isPassportNumber = isPassportNumber;
10524 exports.isPhoneNumber = isPhoneNumber;
10525 exports.isPort = isPort;
10526 exports.isPositive = isPositive;
10527 exports.isPostalCode = isPostalCode;
10528 exports.isRFC3339 = isRFC3339;
10529 exports.isRgbColor = isRgbColor;
10530 exports.isSemVer = isSemVer;
10531 exports.isString = isString;
10532 exports.isSurrogatePair = isSurrogatePair;
10533 exports.isURL = isURL;
10534 exports.isUUID = isUUID;
10535 exports.isUppercase = isUppercase;
10536 exports.isValidationOptions = isValidationOptions;
10537 exports.isVariableWidth = isVariableWidth;
10538 exports.length = length;
10539 exports.matches = matches;
10540 exports.max = max;
10541 exports.maxDate = maxDate;
10542 exports.maxLength = maxLength;
10543 exports.min = min;
10544 exports.minDate = minDate;
10545 exports.minLength = minLength;
10546 exports.notContains = notContains;
10547 exports.notEquals = notEquals;
10548 exports.registerDecorator = registerDecorator;
10549 exports.registerSchema = registerSchema;
10550 exports.setClassValidatorMessages = setClassValidatorMessages;
10551 exports.setClassValidatorPropertyTitle = setClassValidatorPropertyTitle;
10552 exports.setClassValidatorTitle = setClassValidatorTitle;
10553 exports.useContainer = useContainer;
10554 exports.validate = validate;
10555 exports.validateOrReject = validateOrReject;
10556 exports.validateSync = validateSync;
10557
10558 Object.defineProperty(exports, '__esModule', { value: true });
10559
10560}));
10561//# sourceMappingURL=class-validator-multi-lang.umd.js.map