twenty/packages/twenty-server/patches/class-validator+0.14.0.patch

5602 lines
5.5 MiB
Diff
Raw Normal View History

diff --git a/bundles/class-validator.umd.js b/bundles/class-validator.umd.js
index 28d9b7d..aee362b 100644
--- a/bundles/class-validator.umd.js
+++ b/bundles/class-validator.umd.js
@@ -435,7 +435,7 @@
if (messageString &&
validationArguments.value !== undefined &&
validationArguments.value !== null &&
- typeof validationArguments.value === 'string')
+ ['string', 'boolean', 'number'].includes(typeof validationArguments.value))
messageString = messageString.replace(/\$value/g, validationArguments.value);
if (messageString)
messageString = messageString.replace(/\$property/g, validationArguments.property);
@@ -480,6 +480,7 @@
// -------------------------------------------------------------------------
// Private Properties
// -------------------------------------------------------------------------
+ this.instance = undefined;
this.metadataStorage = getMetadataStorage();
}
// -------------------------------------------------------------------------
@@ -499,6 +500,10 @@
" - There may be multiple class-validator versions installed. You will need to flatten your dependencies to fix the issue.\n" +
" - This validation runs before any file with validation decorator was parsed by NodeJS.");
}
+ // Keep the instance to the original object
+ if (this.instance === undefined) {
+ this.instance = object;
+ }
var groups = this.validatorOptions ? this.validatorOptions.groups : undefined;
var strictGroups = (this.validatorOptions && this.validatorOptions.strictGroups) || false;
var always = (this.validatorOptions && this.validatorOptions.always) || false;
@@ -648,6 +653,7 @@
targetName: object.constructor ? object.constructor.name : undefined,
property: metadata.propertyName,
object: object,
+ instance: _this.instance,
value: value,
constraints: metadata.constraints,
};
@@ -772,6 +778,7 @@
property: metadata.propertyName,
object: object,
value: value,
+ instance: this.instance,
constraints: metadata.constraints,
};
var message = metadata.message || '';
@@ -1185,6 +1192,8 @@
var assertString = {exports: {}};
+ assertString.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -1209,8 +1218,12 @@
module.exports.default = exports.default;
} (assertString, assertString.exports));
+ var assertStringExports = assertString.exports;
+
var merge = {exports: {}};
+ merge.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -1235,6 +1248,10 @@
module.exports.default = exports.default;
} (merge, merge.exports));
+ var mergeExports = merge.exports;
+
+ isLatLong$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -1242,9 +1259,9 @@
});
exports.default = isLatLong;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
- var _merge = _interopRequireDefault(merge.exports);
+ var _merge = _interopRequireDefault(mergeExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -1274,7 +1291,8 @@
module.exports.default = exports.default;
} (isLatLong$1, isLatLong$1.exports));
- var isLatLongValidator = /*@__PURE__*/getDefaultExportFromCjs(isLatLong$1.exports);
+ var isLatLongExports = isLatLong$1.exports;
+ var isLatLongValidator = /*@__PURE__*/getDefaultExportFromCjs(isLatLongExports);
var IS_LATLONG = 'isLatLong';
/**
@@ -1423,7 +1441,7 @@
* Checks if given value is in a array of allowed values.
*/
function isIn$1(value, possibleValues) {
- return !Array.isArray(possibleValues) || possibleValues.some(function (possibleValue) { return possibleValue === value; });
+ return Array.isArray(possibleValues) && possibleValues.some(function (possibleValue) { return possibleValue === value; });
}
/**
* Checks if given value is in a array of allowed values.
@@ -1471,7 +1489,7 @@
Object.defineProperty(alpha$1, "__esModule", {
value: true
});
- 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;
+ alpha$1.commaDecimal = alpha$1.dotDecimal = alpha$1.bengaliLocales = alpha$1.farsiLocales = alpha$1.arabicLocales = alpha$1.englishLocales = alpha$1.decimal = alpha$1.alphanumeric = alpha$1.alpha = void 0;
var alpha = {
'en-US': /^[A-Z]+$/i,
'az-AZ': /^[A-VXYZÇƏĞİıÖŞÜ]+$/i,
@@ -1485,6 +1503,7 @@
'fi-FI': /^[A-ZÅÄÖ]+$/i,
'fr-FR': /^[A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i,
'it-IT': /^[A-ZÀÉÈÌÎÓÒÙ]+$/i,
+ 'ja-JP': /^[ぁ-んァ-ヶヲ-゚一-龠ー・。、]+$/i,
'nb-NO': /^[A-ZÆØÅ]+$/i,
'nl-NL': /^[A-ZÁÉËÏÓÖÜÚ]+$/i,
'nn-NO': /^[A-ZÆØÅ]+$/i,
@@ -1501,11 +1520,14 @@
'tr-TR': /^[A-ZÇĞİıÖŞÜ]+$/i,
'uk-UA': /^[АЬЮЯЄIЇҐі]+$/i,
'vi-VN': /^[A-ZÀÁẠẢÃÂẦẤẬẨẪĂẰẮẶẲẴĐÈÉẸẺẼÊỀẾỆỂỄÌÍỊỈĨÒÓỌỎÕÔỒỐỘỔỖƠỜỚỢỞỠÙÚỤỦŨƯỪỨỰỬỮỲÝỴỶỸ]+$/i,
+ 'ko-KR': /^[ㄱ-ㅎㅏ-ㅣ가-힣]*$/,
'ku-IQ': /^[ئابپتجچحخدرڕزژسشعغفڤقکگلڵمنوۆھەیێيطؤثآإأكضصةظذ]+$/i,
ar: /^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/,
he: /^[א-ת]+$/,
fa: /^['آاءأؤئبپتثجچحخدذرزژسشصضطظعغفقکگلمنوهةی']+$/i,
- 'hi-IN': /^[\u0900-\u0961]+[\u0972-\u097F]*$/i
+ bn: /^['ঀঁংঃঅআইঈউঊঋঌএঐওঔকখগঘঙচছজঝঞটঠডঢণতথদধনপফবভমযরলশষসহ়ঽািীুূৃৄেৈোৌ্ৎৗড়ঢ়য়ৠৡৢৣৰৱ৲৳৴৵৶৷৸৹৺৻']+$/,
+ 'hi-IN': /^[\u0900-\u0961]+[\u0972-\u097F]*$/i,
+ 'si-LK': /^[\u0D80-\u0DFF]+$/
};
alpha$1.alpha = alpha;
var alphanumeric = {
@@ -1520,6 +1542,7 @@
'fi-FI': /^[0-9A-ZÅÄÖ]+$/i,
'fr-FR': /^[0-9A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i,
'it-IT': /^[0-9A-ZÀÉÈÌÎÓÒÙ]+$/i,
+ 'ja-JP': /^[0-9-9ぁ-んァ-ヶヲ-゚一-龠ー・。、]+$/i,
'hu-HU': /^[0-9A-ZÁÉÍÓÖŐÚÜŰ]+$/i,
'nb-NO': /^[0-9A-ZÆØÅ]+$/i,
'nl-NL': /^[0-9A-ZÁÉËÏÓÖÜÚ]+$/i,
@@ -1535,12 +1558,15 @@
'th-TH': /^[ก-๙\s]+$/i,
'tr-TR': /^[0-9A-ZÇĞİıÖŞÜ]+$/i,
'uk-UA': /^[0-9АЬЮЯЄIЇҐі]+$/i,
+ 'ko-KR': /^[0-9ㄱ-ㅎㅏ-ㅣ가-힣]*$/,
'ku-IQ': /^[٠١٢٣٤٥٦٧٨٩0-9ئابپتجچحخدرڕزژسشعغفڤقکگلڵمنوۆھەیێيطؤثآإأكضصةظذ]+$/i,
'vi-VN': /^[0-9A-ZÀÁẠẢÃÂẦẤẬẨẪĂẰẮẶẲẴĐÈÉẸẺẼÊỀẾỆỂỄÌÍỊỈĨÒÓỌỎÕÔỒỐỘỔỖƠỜỚỢỞỠÙÚỤỦŨƯỪỨỰỬỮỲÝỴỶỸ]+$/i,
ar: /^[٠١٢٣٤٥٦٧٨٩0-9ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/,
he: /^[0-9א-ת]+$/,
fa: /^['0-9آاءأؤئبپتثجچحخدذرزژسشصضطظعغفقکگلمنوهةی۱۲۳۴۵۶۷۸۹۰']+$/i,
- 'hi-IN': /^[\u0900-\u0963]+[\u0966-\u097F]*$/i
+ bn: /^['ঀঁংঃঅআইঈউঊঋঌএঐওঔকখগঘঙচছজঝঞটঠডঢণতথদধনপফবভমযরলশষসহ়ঽািীুূৃৄেৈোৌ্ৎৗড়ঢ়য়ৠৡৢৣ০১২৩৪৫৬৭৮৯ৰৱ৲৳৴৵৶৷৸৹৺৻']+$/,
+ 'hi-IN': /^[\u0900-\u0963]+[\u0966-\u097F]*$/i,
+ 'si-LK': /^[0-9\u0D80-\u0DFF]+$/
};
alpha$1.alphanumeric = alphanumeric;
var decimal = {
@@ -1576,20 +1602,30 @@
_locale2 = "fa-".concat(farsiLocales[_i2]);
alphanumeric[_locale2] = alphanumeric.fa;
decimal[_locale2] = decimal.ar;
+ }
+
+ var bengaliLocales = ['BD', 'IN'];
+ alpha$1.bengaliLocales = bengaliLocales;
+
+ for (var _locale3, _i3 = 0; _i3 < bengaliLocales.length; _i3++) {
+ _locale3 = "bn-".concat(bengaliLocales[_i3]);
+ alpha[_locale3] = alpha.bn;
+ alphanumeric[_locale3] = alphanumeric.bn;
+ decimal[_locale3] = decimal['en-US'];
} // Source: https://en.wikipedia.org/wiki/Decimal_mark
var dotDecimal = ['ar-EG', 'ar-LB', 'ar-LY'];
alpha$1.dotDecimal = dotDecimal;
- 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'];
+ 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', 'si-LK', 'sl-SI', 'sr-RS@latin', 'sr-RS', 'sv-SE', 'tr-TR', 'uk-UA', 'vi-VN'];
alpha$1.commaDecimal = commaDecimal;
- for (var _i3 = 0; _i3 < dotDecimal.length; _i3++) {
- decimal[dotDecimal[_i3]] = decimal['en-US'];
+ for (var _i4 = 0; _i4 < dotDecimal.length; _i4++) {
+ decimal[dotDecimal[_i4]] = decimal['en-US'];
}
- for (var _i4 = 0; _i4 < commaDecimal.length; _i4++) {
- decimal[commaDecimal[_i4]] = ',';
+ for (var _i5 = 0; _i5 < commaDecimal.length; _i5++) {
+ decimal[commaDecimal[_i5]] = ',';
}
alpha['fr-CA'] = alpha['fr-FR'];
@@ -1610,7 +1646,7 @@
isFloat$1.default = isFloat;
isFloat$1.locales = void 0;
- var _assertString$a = _interopRequireDefault$a(assertString.exports);
+ var _assertString$a = _interopRequireDefault$a(assertStringExports);
var _alpha$2 = alpha$1;
@@ -1621,7 +1657,7 @@
options = options || {};
var float = new RegExp("^(?:[-+])?(?:[0-9]+)?(?:\\".concat(options.locale ? _alpha$2.decimal[options.locale] : '.', "[0-9]*)?(?:[eE][\\+\\-]?(?:[0-9]+))?$"));
- if (str === '' || str === '.' || str === '-' || str === '+') {
+ if (str === '' || str === '.' || str === ',' || str === '-' || str === '+') {
return false;
}
@@ -1632,6 +1668,8 @@
var locales$5 = Object.keys(_alpha$2.decimal);
isFloat$1.locales = locales$5;
+ toFloat.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -1652,6 +1690,10 @@
module.exports.default = exports.default;
} (toFloat, toFloat.exports));
+ var toFloatExports = toFloat.exports;
+
+ isDivisibleBy$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -1659,9 +1701,9 @@
});
exports.default = isDivisibleBy;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
- var _toFloat = _interopRequireDefault(toFloat.exports);
+ var _toFloat = _interopRequireDefault(toFloatExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -1674,7 +1716,8 @@
module.exports.default = exports.default;
} (isDivisibleBy$1, isDivisibleBy$1.exports));
- var isDivisibleByValidator = /*@__PURE__*/getDefaultExportFromCjs(isDivisibleBy$1.exports);
+ var isDivisibleByExports = isDivisibleBy$1.exports;
+ var isDivisibleByValidator = /*@__PURE__*/getDefaultExportFromCjs(isDivisibleByExports);
var IS_DIVISIBLE_BY = 'isDivisibleBy';
/**
@@ -1825,6 +1868,8 @@
var toString$1 = {exports: {}};
+ toString$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -1852,6 +1897,10 @@
module.exports.default = exports.default;
} (toString$1, toString$1.exports));
+ var toStringExports = toString$1.exports;
+
+ contains$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -1859,11 +1908,11 @@
});
exports.default = contains;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
- var _toString = _interopRequireDefault(toString$1.exports);
+ var _toString = _interopRequireDefault(toStringExports);
- var _merge = _interopRequireDefault(merge.exports);
+ var _merge = _interopRequireDefault(mergeExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -1887,7 +1936,8 @@
module.exports.default = exports.default;
} (contains$1, contains$1.exports));
- var containsValidator = /*@__PURE__*/getDefaultExportFromCjs(contains$1.exports);
+ var containsExports = contains$1.exports;
+ var containsValidator = /*@__PURE__*/getDefaultExportFromCjs(containsExports);
var CONTAINS = 'contains';
/**
@@ -1943,7 +1993,7 @@
var _default$8 = isAlpha$2.default = isAlpha$1;
isAlpha$2.locales = void 0;
- var _assertString$9 = _interopRequireDefault$9(assertString.exports);
+ var _assertString$9 = _interopRequireDefault$9(assertStringExports);
var _alpha$1 = alpha$1;
@@ -2007,7 +2057,7 @@
var _default$7 = isAlphanumeric$2.default = isAlphanumeric$1;
isAlphanumeric$2.locales = void 0;
- var _assertString$8 = _interopRequireDefault$8(assertString.exports);
+ var _assertString$8 = _interopRequireDefault$8(assertStringExports);
var _alpha = alpha$1;
@@ -2067,6 +2117,8 @@
var includes = {exports: {}};
+ includes.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -2086,6 +2138,10 @@
module.exports.default = exports.default;
} (includes, includes.exports));
+ var includesExports = includes.exports;
+
+ isDecimal$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -2093,11 +2149,11 @@
});
exports.default = isDecimal;
- var _merge = _interopRequireDefault(merge.exports);
+ var _merge = _interopRequireDefault(mergeExports);
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
- var _includes = _interopRequireDefault(includes.exports);
+ var _includes = _interopRequireDefault(includesExports);
var _alpha = alpha$1;
@@ -2130,7 +2186,8 @@
module.exports.default = exports.default;
} (isDecimal$1, isDecimal$1.exports));
- var isDecimalValidator = /*@__PURE__*/getDefaultExportFromCjs(isDecimal$1.exports);
+ var isDecimalExports = isDecimal$1.exports;
+ var isDecimalValidator = /*@__PURE__*/getDefaultExportFromCjs(isDecimalExports);
var IS_DECIMAL = 'isDecimal';
/**
@@ -2157,6 +2214,8 @@
var isAscii$1 = {exports: {}};
+ isAscii$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -2164,7 +2223,7 @@
});
exports.default = isAscii;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -2181,7 +2240,8 @@
module.exports.default = exports.default;
} (isAscii$1, isAscii$1.exports));
- var isAsciiValidator = /*@__PURE__*/getDefaultExportFromCjs(isAscii$1.exports);
+ var isAsciiExports = isAscii$1.exports;
+ var isAsciiValidator = /*@__PURE__*/getDefaultExportFromCjs(isAsciiExports);
var IS_ASCII = 'isAscii';
/**
@@ -2207,6 +2267,8 @@
var isBase64$1 = {exports: {}};
+ isBase64$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -2214,9 +2276,9 @@
});
exports.default = isBase64;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
- var _merge = _interopRequireDefault(merge.exports);
+ var _merge = _interopRequireDefault(mergeExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -2247,23 +2309,25 @@
module.exports.default = exports.default;
} (isBase64$1, isBase64$1.exports));
- var isBase64Validator = /*@__PURE__*/getDefaultExportFromCjs(isBase64$1.exports);
+ var isBase64Exports = isBase64$1.exports;
+ var isBase64Validator = /*@__PURE__*/getDefaultExportFromCjs(isBase64Exports);
var IS_BASE64 = 'isBase64';
/**
* Checks if a string is base64 encoded.
* If given value is not a string, then it returns false.
*/
- function isBase64(value) {
- return typeof value === 'string' && isBase64Validator(value);
+ function isBase64(value, options) {
+ return typeof value === 'string' && isBase64Validator(value, options);
}
/**
* Checks if a string is base64 encoded.
* If given value is not a string, then it returns false.
*/
- function IsBase64(validationOptions) {
+ function IsBase64(options, validationOptions) {
return ValidateBy({
name: IS_BASE64,
+ constraints: [options],
validator: {
validate: function (value, args) { return isBase64(value); },
defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be base64 encoded'; }, validationOptions),
@@ -2273,6 +2337,8 @@
var isByteLength$1 = {exports: {}};
+ isByteLength$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -2280,7 +2346,7 @@
});
exports.default = isByteLength;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -2309,7 +2375,8 @@
module.exports.default = exports.default;
} (isByteLength$1, isByteLength$1.exports));
- var isByteLengthValidator = /*@__PURE__*/getDefaultExportFromCjs(isByteLength$1.exports);
+ var isByteLengthExports = isByteLength$1.exports;
+ var isByteLengthValidator = /*@__PURE__*/getDefaultExportFromCjs(isByteLengthExports);
var IS_BYTE_LENGTH = 'isByteLength';
/**
@@ -2336,29 +2403,24 @@
var isCreditCard$1 = {exports: {}};
+ var isLuhnNumber = {exports: {}};
+
+ isLuhnNumber.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
value: true
});
- exports.default = isCreditCard;
+ exports.default = isLuhnNumber;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- /* eslint-disable max-len */
- 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}))$/;
- /* eslint-enable max-len */
-
- function isCreditCard(str) {
+ function isLuhnNumber(str) {
(0, _assertString.default)(str);
var sanitized = str.replace(/[- ]+/g, '');
-
- if (!creditCard.test(sanitized)) {
- return false;
- }
-
var sum = 0;
var digit;
var tmpNum;
@@ -2386,11 +2448,70 @@
return !!(sum % 10 === 0 ? sanitized : false);
}
+ module.exports = exports.default;
+ module.exports.default = exports.default;
+ } (isLuhnNumber, isLuhnNumber.exports));
+
+ var isLuhnNumberExports = isLuhnNumber.exports;
+
+ isCreditCard$1.exports;
+
+ (function (module, exports) {
+
+ Object.defineProperty(exports, "__esModule", {
+ value: true
+ });
+ exports.default = isCreditCard;
+
+ var _assertString = _interopRequireDefault(assertStringExports);
+
+ var _isLuhnNumber = _interopRequireDefault(isLuhnNumberExports);
+
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+ var cards = {
+ amex: /^3[47][0-9]{13}$/,
+ dinersclub: /^3(?:0[0-5]|[68][0-9])[0-9]{11}$/,
+ discover: /^6(?:011|5[0-9][0-9])[0-9]{12,15}$/,
+ jcb: /^(?:2131|1800|35\d{3})\d{11}$/,
+ mastercard: /^5[1-5][0-9]{2}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}$/,
+ // /^[25][1-7][0-9]{14}$/;
+ unionpay: /^(6[27][0-9]{14}|^(81[0-9]{14,17}))$/,
+ visa: /^(?:4[0-9]{12})(?:[0-9]{3,6})?$/
+ };
+ /* eslint-disable max-len */
+
+ var allCards = /^(?: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}))$/;
+ /* eslint-enable max-len */
+
+ function isCreditCard(card) {
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
+ (0, _assertString.default)(card);
+ var provider = options.provider;
+ var sanitized = card.replace(/[- ]+/g, '');
+
+ if (provider && provider.toLowerCase() in cards) {
+ // specific provider in the list
+ if (!cards[provider.toLowerCase()].test(sanitized)) {
+ return false;
+ }
+ } else if (provider && !(provider.toLowerCase() in cards)) {
+ /* specific provider not in the list */
+ throw new Error("".concat(provider, " is not a valid credit card provider."));
+ } else if (!allCards.test(sanitized)) {
+ // no specific provider
+ return false;
+ }
+
+ return (0, _isLuhnNumber.default)(card);
+ }
+
module.exports = exports.default;
module.exports.default = exports.default;
} (isCreditCard$1, isCreditCard$1.exports));
- var isCreditCardValidator = /*@__PURE__*/getDefaultExportFromCjs(isCreditCard$1.exports);
+ var isCreditCardExports = isCreditCard$1.exports;
+ var isCreditCardValidator = /*@__PURE__*/getDefaultExportFromCjs(isCreditCardExports);
var IS_CREDIT_CARD = 'isCreditCard';
/**
@@ -2416,6 +2537,8 @@
var isCurrency$1 = {exports: {}};
+ isCurrency$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -2423,9 +2546,9 @@
});
exports.default = isCurrency;
- var _merge = _interopRequireDefault(merge.exports);
+ var _merge = _interopRequireDefault(mergeExports);
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -2509,7 +2632,8 @@
module.exports.default = exports.default;
} (isCurrency$1, isCurrency$1.exports));
- var isCurrencyValidator = /*@__PURE__*/getDefaultExportFromCjs(isCurrency$1.exports);
+ var isCurrencyExports = isCurrency$1.exports;
+ var isCurrencyValidator = /*@__PURE__*/getDefaultExportFromCjs(isCurrencyExports);
var IS_CURRENCY = 'isCurrency';
/**
@@ -2538,6 +2662,8 @@
var isFQDN$1 = {exports: {}};
+ isFQDN$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -2545,9 +2671,9 @@
});
exports.default = isFQDN;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
- var _merge = _interopRequireDefault(merge.exports);
+ var _merge = _interopRequireDefault(mergeExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -2556,7 +2682,8 @@
allow_underscores: false,
allow_trailing_dot: false,
allow_numeric_tld: false,
- allow_wildcard: false
+ allow_wildcard: false,
+ ignore_max_length: false
};
function isFQDN(str, options) {
@@ -2583,7 +2710,7 @@
return false;
}
- if (!/^([a-z\u00A1-\u00A8\u00AA-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}|xn[a-z0-9-]{2,})$/i.test(tld)) {
+ if (!options.allow_numeric_tld && !/^([a-z\u00A1-\u00A8\u00AA-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}|xn[a-z0-9-]{2,})$/i.test(tld)) {
return false;
} // disallow spaces
@@ -2599,7 +2726,7 @@
}
return parts.every(function (part) {
- if (part.length > 63) {
+ if (part.length > 63 && !options.ignore_max_length) {
return false;
}
@@ -2629,10 +2756,13 @@
module.exports.default = exports.default;
} (isFQDN$1, isFQDN$1.exports));
- var isFqdnValidator = /*@__PURE__*/getDefaultExportFromCjs(isFQDN$1.exports);
+ var isFQDNExports = isFQDN$1.exports;
+ var isFqdnValidator = /*@__PURE__*/getDefaultExportFromCjs(isFQDNExports);
var isIP$1 = {exports: {}};
+ isIP$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -2640,7 +2770,7 @@
});
exports.default = isIP;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -2689,18 +2819,11 @@
}
if (version === '4') {
- if (!IPv4AddressRegExp.test(str)) {
- return false;
- }
-
- var parts = str.split('.').sort(function (a, b) {
- return a - b;
- });
- return parts[3] <= 255;
+ return IPv4AddressRegExp.test(str);
}
if (version === '6') {
- return !!IPv6AddressRegExp.test(str);
+ return IPv6AddressRegExp.test(str);
}
return false;
@@ -2710,7 +2833,10 @@
module.exports.default = exports.default;
} (isIP$1, isIP$1.exports));
- var isIPValidator = /*@__PURE__*/getDefaultExportFromCjs(isIP$1.exports);
+ var isIPExports = isIP$1.exports;
+ var isIPValidator = /*@__PURE__*/getDefaultExportFromCjs(isIPExports);
+
+ isEmail$1.exports;
(function (module, exports) {
@@ -2719,15 +2845,15 @@
});
exports.default = isEmail;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
- var _merge = _interopRequireDefault(merge.exports);
+ var _merge = _interopRequireDefault(mergeExports);
- var _isByteLength = _interopRequireDefault(isByteLength$1.exports);
+ var _isByteLength = _interopRequireDefault(isByteLengthExports);
- var _isFQDN = _interopRequireDefault(isFQDN$1.exports);
+ var _isFQDN = _interopRequireDefault(isFQDNExports);
- var _isIP = _interopRequireDefault(isIP$1.exports);
+ var _isIP = _interopRequireDefault(isIPExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -2738,7 +2864,8 @@
require_tld: true,
blacklisted_chars: '',
ignore_max_length: false,
- host_blacklist: []
+ host_blacklist: [],
+ host_whitelist: []
};
/* eslint-disable max-len */
@@ -2805,7 +2932,7 @@
// the display name is `myname` instead of `myname `, so need to trim the last space
if (display_name.endsWith(' ')) {
- display_name = display_name.substr(0, display_name.length - 1);
+ display_name = display_name.slice(0, -1);
}
if (!validateDisplayName(display_name)) {
@@ -2828,6 +2955,10 @@
return false;
}
+ if (options.host_whitelist.length > 0 && !options.host_whitelist.includes(lower_domain)) {
+ return false;
+ }
+
var user = parts.join('@');
if (options.domain_specific_validation && (lower_domain === 'gmail.com' || lower_domain === 'googlemail.com')) {
@@ -2867,7 +2998,8 @@
}
if (!(0, _isFQDN.default)(domain, {
- require_tld: options.require_tld
+ require_tld: options.require_tld,
+ ignore_max_length: options.ignore_max_length
})) {
if (!options.allow_ip_domain) {
return false;
@@ -2878,7 +3010,7 @@
return false;
}
- var noBracketdomain = domain.substr(1, domain.length - 2);
+ var noBracketdomain = domain.slice(1, -1);
if (noBracketdomain.length === 0 || !(0, _isIP.default)(noBracketdomain)) {
return false;
@@ -2911,7 +3043,8 @@
module.exports.default = exports.default;
} (isEmail$1, isEmail$1.exports));
- var isEmailValidator = /*@__PURE__*/getDefaultExportFromCjs(isEmail$1.exports);
+ var isEmailExports = isEmail$1.exports;
+ var isEmailValidator = /*@__PURE__*/getDefaultExportFromCjs(isEmailExports);
var IS_EMAIL = 'isEmail';
/**
@@ -2967,7 +3100,7 @@
var _default$6 = isFullWidth$2.default = isFullWidth$1;
isFullWidth$2.fullWidth = void 0;
- var _assertString$7 = _interopRequireDefault$7(assertString.exports);
+ var _assertString$7 = _interopRequireDefault$7(assertStringExports);
function _interopRequireDefault$7(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -3009,7 +3142,7 @@
var _default$5 = isHalfWidth$2.default = isHalfWidth$1;
isHalfWidth$2.halfWidth = void 0;
- var _assertString$6 = _interopRequireDefault$6(assertString.exports);
+ var _assertString$6 = _interopRequireDefault$6(assertStringExports);
function _interopRequireDefault$6(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -3045,6 +3178,8 @@
var isVariableWidth$1 = {exports: {}};
+ isVariableWidth$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -3052,7 +3187,7 @@
});
exports.default = isVariableWidth;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
var _isFullWidth = isFullWidth$2;
@@ -3069,7 +3204,8 @@
module.exports.default = exports.default;
} (isVariableWidth$1, isVariableWidth$1.exports));
- var isVariableWidthValidator = /*@__PURE__*/getDefaultExportFromCjs(isVariableWidth$1.exports);
+ var isVariableWidthExports = isVariableWidth$1.exports;
+ var isVariableWidthValidator = /*@__PURE__*/getDefaultExportFromCjs(isVariableWidthExports);
var IS_VARIABLE_WIDTH = 'isVariableWidth';
/**
@@ -3095,6 +3231,8 @@
var isHexColor$1 = {exports: {}};
+ isHexColor$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -3102,7 +3240,7 @@
});
exports.default = isHexColor;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -3117,7 +3255,8 @@
module.exports.default = exports.default;
} (isHexColor$1, isHexColor$1.exports));
- var isHexColorValidator = /*@__PURE__*/getDefaultExportFromCjs(isHexColor$1.exports);
+ var isHexColorExports = isHexColor$1.exports;
+ var isHexColorValidator = /*@__PURE__*/getDefaultExportFromCjs(isHexColorExports);
var IS_HEX_COLOR = 'isHexColor';
/**
@@ -3143,6 +3282,8 @@
var isHexadecimal$1 = {exports: {}};
+ isHexadecimal$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -3150,7 +3291,7 @@
});
exports.default = isHexadecimal;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -3165,7 +3306,8 @@
module.exports.default = exports.default;
} (isHexadecimal$1, isHexadecimal$1.exports));
- var isHexadecimalValidator = /*@__PURE__*/getDefaultExportFromCjs(isHexadecimal$1.exports);
+ var isHexadecimalExports = isHexadecimal$1.exports;
+ var isHexadecimalValidator = /*@__PURE__*/getDefaultExportFromCjs(isHexadecimalExports);
var IS_HEXADECIMAL = 'isHexadecimal';
/**
@@ -3198,6 +3340,8 @@
var isMACAddress$1 = {exports: {}};
+ isMACAddress$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -3205,32 +3349,61 @@
});
exports.default = isMACAddress;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- var macAddress = /^(?:[0-9a-fA-F]{2}([-:\s]))([0-9a-fA-F]{2}\1){4}([0-9a-fA-F]{2})$/;
- var macAddressNoSeparators = /^([0-9a-fA-F]){12}$/;
- var macAddressWithDots = /^([0-9a-fA-F]{4}\.){2}([0-9a-fA-F]{4})$/;
+ var macAddress48 = /^(?:[0-9a-fA-F]{2}([-:\s]))([0-9a-fA-F]{2}\1){4}([0-9a-fA-F]{2})$/;
+ var macAddress48NoSeparators = /^([0-9a-fA-F]){12}$/;
+ var macAddress48WithDots = /^([0-9a-fA-F]{4}\.){2}([0-9a-fA-F]{4})$/;
+ var macAddress64 = /^(?:[0-9a-fA-F]{2}([-:\s]))([0-9a-fA-F]{2}\1){6}([0-9a-fA-F]{2})$/;
+ var macAddress64NoSeparators = /^([0-9a-fA-F]){16}$/;
+ var macAddress64WithDots = /^([0-9a-fA-F]{4}\.){3}([0-9a-fA-F]{4})$/;
function isMACAddress(str, options) {
(0, _assertString.default)(str);
+
+ if (options !== null && options !== void 0 && options.eui) {
+ options.eui = String(options.eui);
+ }
/**
* @deprecated `no_colons` TODO: remove it in the next major
*/
- if (options && (options.no_colons || options.no_separators)) {
- return macAddressNoSeparators.test(str);
+
+ if (options !== null && options !== void 0 && options.no_colons || options !== null && options !== void 0 && options.no_separators) {
+ if (options.eui === '48') {
+ return macAddress48NoSeparators.test(str);
+ }
+
+ if (options.eui === '64') {
+ return macAddress64NoSeparators.test(str);
+ }
+
+ return macAddress48NoSeparators.test(str) || macAddress64NoSeparators.test(str);
+ }
+
+ if ((options === null || options === void 0 ? void 0 : options.eui) === '48') {
+ return macAddress48.test(str) || macAddress48WithDots.test(str);
+ }
+
+ if ((options === null || options === void 0 ? void 0 : options.eui) === '64') {
+ return macAddress64.test(str) || macAddress64WithDots.test(str);
}
- return macAddress.test(str) || macAddressWithDots.test(str);
+ return isMACAddress(str, {
+ eui: '48'
+ }) || isMACAddress(str, {
+ eui: '64'
+ });
}
module.exports = exports.default;
module.exports.default = exports.default;
} (isMACAddress$1, isMACAddress$1.exports));
- var isMacAddressValidator = /*@__PURE__*/getDefaultExportFromCjs(isMACAddress$1.exports);
+ var isMACAddressExports = isMACAddress$1.exports;
+ var isMacAddressValidator = /*@__PURE__*/getDefaultExportFromCjs(isMACAddressExports);
var IS_MAC_ADDRESS = 'isMacAddress';
/**
@@ -3284,6 +3457,8 @@
var isInt$1 = {exports: {}};
+ isInt$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -3291,7 +3466,7 @@
});
exports.default = isInt;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -3316,6 +3491,10 @@
module.exports.default = exports.default;
} (isInt$1, isInt$1.exports));
+ var isIntExports = isInt$1.exports;
+
+ isPort$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -3323,7 +3502,7 @@
});
exports.default = isPort;
- var _isInt = _interopRequireDefault(isInt$1.exports);
+ var _isInt = _interopRequireDefault(isIntExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -3338,7 +3517,8 @@
module.exports.default = exports.default;
} (isPort$1, isPort$1.exports));
- var isPortValidator = /*@__PURE__*/getDefaultExportFromCjs(isPort$1.exports);
+ var isPortExports = isPort$1.exports;
+ var isPortValidator = /*@__PURE__*/getDefaultExportFromCjs(isPortExports);
var IS_PORT = 'isPort';
/**
@@ -3362,6 +3542,8 @@
var isISBN$1 = {exports: {}};
+ isISBN$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -3369,56 +3551,60 @@
});
exports.default = isISBN;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- var isbn10Maybe = /^(?:[0-9]{9}X|[0-9]{10})$/;
- var isbn13Maybe = /^(?:[0-9]{13})$/;
+ var possibleIsbn10 = /^(?:[0-9]{9}X|[0-9]{10})$/;
+ var possibleIsbn13 = /^(?:[0-9]{13})$/;
var factor = [1, 3];
- function isISBN(str) {
- var version = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
- (0, _assertString.default)(str);
- version = String(version);
+ function isISBN(isbn, options) {
+ (0, _assertString.default)(isbn); // For backwards compatibility:
+ // isISBN(str [, version]), i.e. `options` could be used as argument for the legacy `version`
- if (!version) {
- return isISBN(str, 10) || isISBN(str, 13);
+ var version = String((options === null || options === void 0 ? void 0 : options.version) || options);
+
+ if (!(options !== null && options !== void 0 && options.version || options)) {
+ return isISBN(isbn, {
+ version: 10
+ }) || isISBN(isbn, {
+ version: 13
+ });
}
- var sanitized = str.replace(/[\s-]+/g, '');
+ var sanitizedIsbn = isbn.replace(/[\s-]+/g, '');
var checksum = 0;
- var i;
if (version === '10') {
- if (!isbn10Maybe.test(sanitized)) {
+ if (!possibleIsbn10.test(sanitizedIsbn)) {
return false;
}
- for (i = 0; i < 9; i++) {
- checksum += (i + 1) * sanitized.charAt(i);
+ for (var i = 0; i < version - 1; i++) {
+ checksum += (i + 1) * sanitizedIsbn.charAt(i);
}
- if (sanitized.charAt(9) === 'X') {
+ if (sanitizedIsbn.charAt(9) === 'X') {
checksum += 10 * 10;
} else {
- checksum += 10 * sanitized.charAt(9);
+ checksum += 10 * sanitizedIsbn.charAt(9);
}
if (checksum % 11 === 0) {
- return !!sanitized;
+ return true;
}
} else if (version === '13') {
- if (!isbn13Maybe.test(sanitized)) {
+ if (!possibleIsbn13.test(sanitizedIsbn)) {
return false;
}
- for (i = 0; i < 12; i++) {
- checksum += factor[i % 2] * sanitized.charAt(i);
+ for (var _i = 0; _i < 12; _i++) {
+ checksum += factor[_i % 2] * sanitizedIsbn.charAt(_i);
}
- if (sanitized.charAt(12) - (10 - checksum % 10) % 10 === 0) {
- return !!sanitized;
+ if (sanitizedIsbn.charAt(12) - (10 - checksum % 10) % 10 === 0) {
+ return true;
}
}
@@ -3429,7 +3615,8 @@
module.exports.default = exports.default;
} (isISBN$1, isISBN$1.exports));
- var isIsbnValidator = /*@__PURE__*/getDefaultExportFromCjs(isISBN$1.exports);
+ var isISBNExports = isISBN$1.exports;
+ var isIsbnValidator = /*@__PURE__*/getDefaultExportFromCjs(isISBNExports);
var IS_ISBN = 'isIsbn';
/**
@@ -3458,6 +3645,8 @@
var isISIN$1 = {exports: {}};
+ isISIN$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -3465,7 +3654,7 @@
});
exports.default = isISIN;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -3533,7 +3722,8 @@
module.exports.default = exports.default;
} (isISIN$1, isISIN$1.exports));
- var isIsinValidator = /*@__PURE__*/getDefaultExportFromCjs(isISIN$1.exports);
+ var isISINExports = isISIN$1.exports;
+ var isIsinValidator = /*@__PURE__*/getDefaultExportFromCjs(isISINExports);
var IS_ISIN = 'isIsin';
/**
@@ -3559,6 +3749,8 @@
var isISO8601$1 = {exports: {}};
+ isISO8601$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -3566,7 +3758,7 @@
});
exports.default = isISO8601;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -3620,7 +3812,8 @@
module.exports.default = exports.default;
} (isISO8601$1, isISO8601$1.exports));
- var isIso8601Validator = /*@__PURE__*/getDefaultExportFromCjs(isISO8601$1.exports);
+ var isISO8601Exports = isISO8601$1.exports;
+ var isIso8601Validator = /*@__PURE__*/getDefaultExportFromCjs(isISO8601Exports);
var IS_ISO8601 = 'isIso8601';
/**
@@ -3649,6 +3842,8 @@
var isJSON$1 = {exports: {}};
+ isJSON$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -3656,9 +3851,9 @@
});
exports.default = isJSON;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
- var _merge = _interopRequireDefault(merge.exports);
+ var _merge = _interopRequireDefault(mergeExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -3692,7 +3887,8 @@
module.exports.default = exports.default;
} (isJSON$1, isJSON$1.exports));
- var isJSONValidator = /*@__PURE__*/getDefaultExportFromCjs(isJSON$1.exports);
+ var isJSONExports = isJSON$1.exports;
+ var isJSONValidator = /*@__PURE__*/getDefaultExportFromCjs(isJSONExports);
var IS_JSON = 'isJson';
/**
@@ -3718,6 +3914,8 @@
var isJWT$1 = {exports: {}};
+ isJWT$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -3725,9 +3923,9 @@
});
exports.default = isJWT;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
- var _isBase = _interopRequireDefault(isBase64$1.exports);
+ var _isBase = _interopRequireDefault(isBase64Exports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -3751,7 +3949,8 @@
module.exports.default = exports.default;
} (isJWT$1, isJWT$1.exports));
- var isJwtValidator = /*@__PURE__*/getDefaultExportFromCjs(isJWT$1.exports);
+ var isJWTExports = isJWT$1.exports;
+ var isJwtValidator = /*@__PURE__*/getDefaultExportFromCjs(isJWTExports);
var IS_JWT = 'isJwt';
/**
@@ -3777,6 +3976,8 @@
var isLowercase$1 = {exports: {}};
+ isLowercase$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -3784,7 +3985,7 @@
});
exports.default = isLowercase;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -3797,7 +3998,8 @@
module.exports.default = exports.default;
} (isLowercase$1, isLowercase$1.exports));
- var isLowercaseValidator = /*@__PURE__*/getDefaultExportFromCjs(isLowercase$1.exports);
+ var isLowercaseExports = isLowercase$1.exports;
+ var isLowercaseValidator = /*@__PURE__*/getDefaultExportFromCjs(isLowercaseExports);
var IS_LOWERCASE = 'isLowercase';
/**
@@ -3829,7 +4031,7 @@
var _default$4 = isMobilePhone$2.default = isMobilePhone$1;
isMobilePhone$2.locales = void 0;
- var _assertString$5 = _interopRequireDefault$5(assertString.exports);
+ var _assertString$5 = _interopRequireDefault$5(assertStringExports);
function _interopRequireDefault$5(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -3843,7 +4045,7 @@
'ar-EG': /^((\+?20)|0)?1[0125]\d{8}$/,
'ar-IQ': /^(\+?964|0)?7[0-9]\d{8}$/,
'ar-JO': /^(\+?962|0)?7[789]\d{7}$/,
- 'ar-KW': /^(\+?965)[569]\d{7}$/,
+ 'ar-KW': /^(\+?965)([569]\d{7}|41\d{6})$/,
'ar-LY': /^((\+?218)|0)?(9[1-6]\d{7}|[1-8]\d{7,9})$/,
'ar-MA': /^(?:(?:\+|00)212|0)[5-7]\d{8}$/,
'ar-OM': /^((\+|00)968)?(9[1-9])\d{6}$/,
@@ -3851,7 +4053,7 @@
'ar-SA': /^(!?(\+?966)|0)?5\d{8}$/,
'ar-SY': /^(!?(\+?963)|0)?9\d{8}$/,
'ar-TN': /^(\+?216)?[2459]\d{7}$/,
- 'az-AZ': /^(\+994|0)(5[015]|7[07]|99)\d{7}$/,
+ 'az-AZ': /^(\+994|0)(10|5[015]|7[07]|99)\d{7}$/,
'bs-BA': /^((((\+|00)3876)|06))((([0-3]|[5-6])\d{6})|(4\d{7}))$/,
'be-BY': /^(\+?375)?(24|25|29|33|44)\d{7}$/,
'bg-BG': /^(\+?359|0)?8[789]\d{7}$/,
@@ -3859,14 +4061,18 @@
'ca-AD': /^(\+376)?[346]\d{5}$/,
'cs-CZ': /^(\+?420)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/,
'da-DK': /^(\+?45)?\s?\d{2}\s?\d{2}\s?\d{2}\s?\d{2}$/,
- '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}$/,
+ 'de-DE': /^((\+49|0)1)(5[0-25-9]\d|6([23]|0\d?)|7([0-57-9]|6\d))\d{7,9}$/,
'de-AT': /^(\+43|0)\d{1,4}\d{3,12}$/,
'de-CH': /^(\+41|0)([1-9])\d{1,9}$/,
'de-LU': /^(\+352)?((6\d1)\d{6})$/,
- 'dv-MV': /^(\+?960)?(7[2-9]|91|9[3-9])\d{7}$/,
- 'el-GR': /^(\+?30|0)?(69\d{8})$/,
+ 'dv-MV': /^(\+?960)?(7[2-9]|9[1-9])\d{5}$/,
+ 'el-GR': /^(\+?30|0)?6(8[5-9]|9(?![26])[0-9])\d{7}$/,
+ 'el-CY': /^(\+?357?)?(9(9|6)\d{6})$/,
+ 'en-AI': /^(\+?1|0)264(?:2(35|92)|4(?:6[1-2]|76|97)|5(?:3[6-9]|8[1-4])|7(?:2(4|9)|72))\d{4}$/,
'en-AU': /^(\+?61|0)4\d{8}$/,
- 'en-BM': /^(\+?1)?441(((3|7)\d{6}$)|(5[0-3][0-9]\d{4}$)|(59\d{5}))/,
+ 'en-AG': /^(?:\+1|1)268(?:464|7(?:1[3-9]|[28]\d|3[0246]|64|7[0-689]))\d{4}$/,
+ 'en-BM': /^(\+?1)?441(((3|7)\d{6}$)|(5[0-3][0-9]\d{4}$)|(59\d{5}$))/,
+ 'en-BS': /^(\+?1[-\s]?|0)?\(?242\)?[-\s]?\d{3}[-\s]?\d{4}$/,
'en-GB': /^(\+?44|0)7\d{9}$/,
'en-GG': /^(\+?44|0)1481\d{6}$/,
'en-GH': /^(\+233|0)(20|50|24|54|27|57|26|56|23|28|55|59)\d{7}$/,
@@ -3875,13 +4081,18 @@
'en-MO': /^(\+?853[-\s]?)?[6]\d{3}[-\s]?\d{4}$/,
'en-IE': /^(\+?353|0)8[356789]\d{7}$/,
'en-IN': /^(\+?91|0)?[6789]\d{9}$/,
+ 'en-JM': /^(\+?876)?\d{7}$/,
'en-KE': /^(\+?254|0)(7|1)\d{8}$/,
+ 'en-SS': /^(\+?211|0)(9[1257])\d{7}$/,
'en-KI': /^((\+686|686)?)?( )?((6|7)(2|3|8)[0-9]{6})$/,
+ 'en-KN': /^(?:\+1|1)869(?:46\d|48[89]|55[6-8]|66\d|76[02-7])\d{4}$/,
+ 'en-LS': /^(\+?266)(22|28|57|58|59|27|52)\d{6}$/,
'en-MT': /^(\+?356|0)?(99|79|77|21|27|22|25)[0-9]{6}$/,
'en-MU': /^(\+?230|0)?\d{8}$/,
'en-NA': /^(\+?264|0)(6|8)\d{7}$/,
'en-NG': /^(\+?234|0)?[789]\d{9}$/,
'en-NZ': /^(\+?64|0)[28]\d{7,9}$/,
+ 'en-PG': /^(\+?675|0)?(7\d|8[18])\d{6}$/,
'en-PK': /^((00|\+)?92|0)3[0-6]\d{8}$/,
'en-PH': /^(09|\+639)\d{9}$/,
'en-RW': /^(\+?250|0)?[7]\d{8}$/,
@@ -3901,11 +4112,12 @@
'es-CR': /^(\+506)?[2-8]\d{7}$/,
'es-CU': /^(\+53|0053)?5\d{7}/,
'es-DO': /^(\+?1)?8[024]9\d{7}$/,
- 'es-HN': /^(\+?504)?[9|8]\d{7}$/,
+ 'es-HN': /^(\+?504)?[9|8|3|2]\d{7}$/,
'es-EC': /^(\+?593|0)([2-7]|9[2-9])\d{7}$/,
'es-ES': /^(\+?34)?[6|7]\d{8}$/,
'es-PE': /^(\+?51)?9\d{8}$/,
'es-MX': /^(\+?52)?(1|01)?\d{10,11}$/,
+ 'es-NI': /^(\+?505)\d{7,8}$/,
'es-PA': /^(\+?507)\d{7,8}$/,
'es-PY': /^(\+?595|0)9[9876]\d{7}$/,
'es-SV': /^(\+?503)?[67]\d{7}$/,
@@ -3913,10 +4125,12 @@
'es-VE': /^(\+?58)?(2|4)\d{9}$/,
'et-EE': /^(\+?372)?\s?(5|8[1-4])\s?([0-9]\s?){6,7}$/,
'fa-IR': /^(\+?98[\-\s]?|0)9[0-39]\d[\-\s]?\d{3}[\-\s]?\d{4}$/,
- 'fi-FI': /^(\+?358|0)\s?(4(0|1|2|4|5|6)?|50)\s?(\d\s?){4,8}\d$/,
+ 'fi-FI': /^(\+?358|0)\s?(4[0-6]|50)\s?(\d\s?){4,8}$/,
'fj-FJ': /^(\+?679)?\s?\d{3}\s?\d{4}$/,
'fo-FO': /^(\+?298)?\s?\d{2}\s?\d{2}\s?\d{2}$/,
'fr-BF': /^(\+226|0)[67]\d{7}$/,
+ 'fr-BJ': /^(\+229)\d{8}$/,
+ 'fr-CD': /^(\+?243|0)?(8|9)\d{8}$/,
'fr-CM': /^(\+?237)6[0-9]{8}$/,
'fr-FR': /^(\+?33|0)[67]\d{8}$/,
'fr-GF': /^(\+?594|0|00594)[67]\d{8}$/,
@@ -3927,27 +4141,34 @@
'he-IL': /^(\+972|0)([23489]|5[012345689]|77)[1-9]\d{6}$/,
'hu-HU': /^(\+?36|06)(20|30|31|50|70)\d{7}$/,
'id-ID': /^(\+?62|0)8(1[123456789]|2[1238]|3[1238]|5[12356789]|7[78]|9[56789]|8[123456789])([\s?|\d]{5,11})$/,
+ 'ir-IR': /^(\+98|0)?9\d{9}$/,
'it-IT': /^(\+?39)?\s?3\d{2} ?\d{6,7}$/,
'it-SM': /^((\+378)|(0549)|(\+390549)|(\+3780549))?6\d{5,9}$/,
'ja-JP': /^(\+81[ \-]?(\(0\))?|0)[6789]0[ \-]?\d{4}[ \-]?\d{4}$/,
- 'ka-GE': /^(\+?995)?(5|79)\d{7}$/,
+ 'ka-GE': /^(\+?995)?(79\d{7}|5\d{8})$/,
'kk-KZ': /^(\+?7|8)?7\d{9}$/,
'kl-GL': /^(\+?299)?\s?\d{2}\s?\d{2}\s?\d{2}$/,
'ko-KR': /^((\+?82)[ \-]?)?0?1([0|1|6|7|8|9]{1})[ \-]?\d{3,4}[ \-]?\d{4}$/,
+ 'ky-KG': /^(\+?7\s?\+?7|0)\s?\d{2}\s?\d{3}\s?\d{4}$/,
'lt-LT': /^(\+370|8)\d{8}$/,
'lv-LV': /^(\+?371)2\d{7}$/,
- 'ms-MY': /^(\+?6?01){1}(([0145]{1}(\-|\s)?\d{7,8})|([236789]{1}(\s|\-)?\d{7}))$/,
+ 'mg-MG': /^((\+?261|0)(2|3)\d)?\d{7}$/,
+ 'mn-MN': /^(\+|00|011)?976(77|81|88|91|94|95|96|99)\d{6}$/,
+ 'my-MM': /^(\+?959|09|9)(2[5-7]|3[1-2]|4[0-5]|6[6-9]|7[5-9]|9[6-9])[0-9]{7}$/,
+ 'ms-MY': /^(\+?60|0)1(([0145](-|\s)?\d{7,8})|([236-9](-|\s)?\d{7}))$/,
'mz-MZ': /^(\+?258)?8[234567]\d{7}$/,
'nb-NO': /^(\+?47)?[49]\d{7}$/,
'ne-NP': /^(\+?977)?9[78]\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9[28])\d{9}$/,
'zh-TW': /^(\+?886\-?|0)?9\d{8}$/,
- 'dz-BT': /^(\+?975|0)?(17|16|77|02)\d{6}$/
+ 'dz-BT': /^(\+?975|0)?(17|16|77|02)\d{6}$/,
+ 'ar-YE': /^(((\+|00)9677|0?7)[0137]\d{7}|((\+|00)967|0)[1-7]\d{6})$/,
+ 'ar-EH': /^(\+?212|0)[\s\-]?(5288|5289)[\s\-]?\d{5}$/,
+ 'fa-AF': /^(\+93|0)?(2{1}[0-8]{1}|[3-5]{1}[0-4]{1})(\d{7})$/
};
/* eslint-enable max-len */
// aliases
@@ -4069,7 +4293,7 @@
var _default$3 = isISO31661Alpha2$2.default = isISO31661Alpha2$1;
isISO31661Alpha2$2.CountryCodes = void 0;
- var _assertString$4 = _interopRequireDefault$4(assertString.exports);
+ var _assertString$4 = _interopRequireDefault$4(assertStringExports);
function _interopRequireDefault$4(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -4106,6 +4330,8 @@
var isISO31661Alpha3$1 = {exports: {}};
+ isISO31661Alpha3$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -4113,7 +4339,7 @@
});
exports.default = isISO31661Alpha3;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -4129,7 +4355,8 @@
module.exports.default = exports.default;
} (isISO31661Alpha3$1, isISO31661Alpha3$1.exports));
- var isISO31661Alpha3Validator = /*@__PURE__*/getDefaultExportFromCjs(isISO31661Alpha3$1.exports);
+ var isISO31661Alpha3Exports = isISO31661Alpha3$1.exports;
+ var isISO31661Alpha3Validator = /*@__PURE__*/getDefaultExportFromCjs(isISO31661Alpha3Exports);
var IS_ISO31661_ALPHA_3 = 'isISO31661Alpha3';
/**
@@ -4153,6 +4380,8 @@
var isMongoId$1 = {exports: {}};
+ isMongoId$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -4160,9 +4389,9 @@
});
exports.default = isMongoId;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
- var _isHexadecimal = _interopRequireDefault(isHexadecimal$1.exports);
+ var _isHexadecimal = _interopRequireDefault(isHexadecimalExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -4175,7 +4404,8 @@
module.exports.default = exports.default;
} (isMongoId$1, isMongoId$1.exports));
- var isMongoIdValidator = /*@__PURE__*/getDefaultExportFromCjs(isMongoId$1.exports);
+ var isMongoIdExports = isMongoId$1.exports;
+ var isMongoIdValidator = /*@__PURE__*/getDefaultExportFromCjs(isMongoIdExports);
var IS_MONGO_ID = 'isMongoId';
/**
@@ -4201,6 +4431,8 @@
var isMultibyte$1 = {exports: {}};
+ isMultibyte$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -4208,7 +4440,7 @@
});
exports.default = isMultibyte;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -4225,7 +4457,8 @@
module.exports.default = exports.default;
} (isMultibyte$1, isMultibyte$1.exports));
- var isMultibyteValidator = /*@__PURE__*/getDefaultExportFromCjs(isMultibyte$1.exports);
+ var isMultibyteExports = isMultibyte$1.exports;
+ var isMultibyteValidator = /*@__PURE__*/getDefaultExportFromCjs(isMultibyteExports);
var IS_MULTIBYTE = 'isMultibyte';
/**
@@ -4251,6 +4484,8 @@
var isSurrogatePair$1 = {exports: {}};
+ isSurrogatePair$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -4258,7 +4493,7 @@
});
exports.default = isSurrogatePair;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -4273,7 +4508,8 @@
module.exports.default = exports.default;
} (isSurrogatePair$1, isSurrogatePair$1.exports));
- var isSurrogatePairValidator = /*@__PURE__*/getDefaultExportFromCjs(isSurrogatePair$1.exports);
+ var isSurrogatePairExports = isSurrogatePair$1.exports;
+ var isSurrogatePairValidator = /*@__PURE__*/getDefaultExportFromCjs(isSurrogatePairExports);
var IS_SURROGATE_PAIR = 'isSurrogatePair';
/**
@@ -4299,6 +4535,8 @@
var isURL$1 = {exports: {}};
+ isURL$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -4306,13 +4544,13 @@
});
exports.default = isURL;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
- var _isFQDN = _interopRequireDefault(isFQDN$1.exports);
+ var _isFQDN = _interopRequireDefault(isFQDNExports);
- var _isIP = _interopRequireDefault(isIP$1.exports);
+ var _isIP = _interopRequireDefault(isIPExports);
- var _merge = _interopRequireDefault(merge.exports);
+ var _merge = _interopRequireDefault(mergeExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -4412,12 +4650,12 @@
}
} else if (options.require_protocol) {
return false;
- } else if (url.substr(0, 2) === '//') {
+ } else if (url.slice(0, 2) === '//') {
if (!options.allow_protocol_relative_urls) {
return false;
}
- split[0] = url.substr(2);
+ split[0] = url.slice(2);
}
url = split.join('://');
@@ -4492,6 +4730,10 @@
return checkHost(host, options.host_whitelist);
}
+ if (host === '' && !options.require_host) {
+ return true;
+ }
+
if (!(0, _isIP.default)(host) && !(0, _isFQDN.default)(host, options) && (!ipv6 || !(0, _isIP.default)(ipv6, 6))) {
return false;
}
@@ -4509,7 +4751,8 @@
module.exports.default = exports.default;
} (isURL$1, isURL$1.exports));
- var isUrlValidator = /*@__PURE__*/getDefaultExportFromCjs(isURL$1.exports);
+ var isURLExports = isURL$1.exports;
+ var isUrlValidator = /*@__PURE__*/getDefaultExportFromCjs(isURLExports);
var IS_URL = 'isUrl';
/**
@@ -4536,6 +4779,8 @@
var isUUID$1 = {exports: {}};
+ isUUID$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -4543,7 +4788,7 @@
});
exports.default = isUUID;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -4566,7 +4811,8 @@
module.exports.default = exports.default;
} (isUUID$1, isUUID$1.exports));
- var isUuidValidator = /*@__PURE__*/getDefaultExportFromCjs(isUUID$1.exports);
+ var isUUIDExports = isUUID$1.exports;
+ var isUuidValidator = /*@__PURE__*/getDefaultExportFromCjs(isUUIDExports);
var IS_UUID = 'isUuid';
/**
@@ -4616,6 +4862,8 @@
var isUppercase$1 = {exports: {}};
+ isUppercase$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -4623,7 +4871,7 @@
});
exports.default = isUppercase;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -4636,7 +4884,8 @@
module.exports.default = exports.default;
} (isUppercase$1, isUppercase$1.exports));
- var isUppercaseValidator = /*@__PURE__*/getDefaultExportFromCjs(isUppercase$1.exports);
+ var isUppercaseExports = isUppercase$1.exports;
+ var isUppercaseValidator = /*@__PURE__*/getDefaultExportFromCjs(isUppercaseExports);
var IS_UPPERCASE = 'isUppercase';
/**
@@ -4662,6 +4911,8 @@
var isLength = {exports: {}};
+ isLength.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -4669,7 +4920,7 @@
});
exports.default = isLength;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -4690,8 +4941,9 @@
max = arguments[2];
}
+ var presentationSequences = str.match(/(\uFE0F|\uFE0E)/g) || [];
var surrogatePairs = str.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g) || [];
- var len = str.length - surrogatePairs.length;
+ var len = str.length - presentationSequences.length - surrogatePairs.length;
return len >= min && (typeof max === 'undefined' || len <= max);
}
@@ -4699,7 +4951,8 @@
module.exports.default = exports.default;
} (isLength, isLength.exports));
- var isLengthValidator = /*@__PURE__*/getDefaultExportFromCjs(isLength.exports);
+ var isLengthExports = isLength.exports;
+ var isLengthValidator = /*@__PURE__*/getDefaultExportFromCjs(isLengthExports);
var IS_LENGTH = 'isLength';
/**
@@ -4783,6 +5036,8 @@
var matches$1 = {exports: {}};
+ matches$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -4790,7 +5045,7 @@
});
exports.default = matches;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -4801,14 +5056,15 @@
pattern = new RegExp(pattern, modifiers);
}
- return pattern.test(str);
+ return !!str.match(pattern);
}
module.exports = exports.default;
module.exports.default = exports.default;
} (matches$1, matches$1.exports));
- var matchesValidator = /*@__PURE__*/getDefaultExportFromCjs(matches$1.exports);
+ var matchesExports = matches$1.exports;
+ var matchesValidator = /*@__PURE__*/getDefaultExportFromCjs(matchesExports);
var MATCHES = 'matches';
function matches(value, pattern, modifiers) {
@@ -4835,7 +5091,7 @@
// This file is a workaround for a bug in web browsers' "native"
// ES6 importing system which is uncapable of importing "*.json" files.
// https://github.com/catamphetamine/libphonenumber-js/issues/239
- 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","0
+ 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],0,0,0,0,0,0,0,[["6[2-467]\\d{3}",[5]],["4\\d{4}",[5]],0,0,0,0,["(?:0[1-9]|[1589]\\d)\\d{4}",[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"]]],0,0,0,0,0,0,[["[78]\\d{5}",[6]],["690\\d{6}|[356]\\d{5}",[6,9]],["180[02]\\d{4}",[8]],["[19]\\d{5}",[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",0,0,0,0,0,[["[2-4679][2-8]\\d{6}",[8]],["5[024-68]\\d{7}",[9]],["400\\d{6}|800\\d{2,9}"],["900[02]\\d{5}",[9]],0,0,["600[25]\\d{5}",[9]],0,0,["700[05]\\d{5}",[9]]]],"AF":["93","00","[2-7]\\d{8}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[2-7]"],"0$1"]],"0",0,0,0,0,0,[["(?:[25][0-8]|[34][0-4]|6[0-5])[2-9]\\d{6}"],["7\\d{8}"]]],"AG":["1","011","(?:268|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([457]\\d{6})$|1","268$1",0,"268",[["268(?:4(?:6[0-38]|84)|56[
// Importing from a ".js" file is a workaround for Node.js "ES Modules"
@@ -4954,6 +5210,11 @@
return !a[1] && b[1] ? 1 : a[1] && !b[1] ? -1 : 0;
}
+ var objectConstructor = {}.constructor;
+ function isObject$1(object) {
+ return object !== undefined && object !== null && object.constructor === objectConstructor;
+ }
+
function _typeof$1(obj) { "@babel/helpers - typeof"; return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof$1(obj); }
function _classCallCheck$1(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -5520,23 +5781,15 @@
// `country_calling_codes` in `1.0.18`.
- if (!is_object(metadata) || !is_object(metadata.countries)) {
- 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, "."));
+ if (!isObject$1(metadata) || !isObject$1(metadata.countries)) {
+ 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(isObject$1(metadata) ? 'an object of shape: { ' + Object.keys(metadata).join(', ') + ' }' : 'a ' + typeOf(metadata) + ': ' + metadata, "."));
}
} // Babel transforms `typeof` into some "branches"
// so istanbul will show this as "branch not covered".
/* istanbul ignore next */
- var is_object = function is_object(_) {
- return _typeof$1(_) === 'object';
- }; // Babel transforms `typeof` into some "branches"
- // so istanbul will show this as "branch not covered".
-
- /* istanbul ignore next */
-
-
- var type_of = function type_of(_) {
+ var typeOf = function typeOf(_) {
return _typeof$1(_);
};
/**
@@ -5559,11 +5812,6 @@
throw new Error("Unknown country: ".concat(country));
}
- function isSupportedCountry(country, metadata) {
- // metadata = new Metadata(metadata)
- // return metadata.hasCountry(country)
- return metadata.countries[country] !== undefined;
- }
function setVersion(metadata) {
var version = metadata.version;
@@ -5875,11 +6123,11 @@
return DIGITS[character];
}
- function _createForOfIteratorHelperLoose$5(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray$6(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
+ function _createForOfIteratorHelperLoose$4(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray$5(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
- function _unsupportedIterableToArray$6(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$6(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$6(o, minLen); }
+ function _unsupportedIterableToArray$5(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$5(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$5(o, minLen); }
- function _arrayLikeToArray$6(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; }
+ function _arrayLikeToArray$5(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; }
/**
* Parses phone number characters from a string.
* Drops all punctuation leaving only digits and the leading `+` sign (if any).
@@ -5904,7 +6152,7 @@
// (including non-European ones) don't fall into that range
// so such "exotic" characters would be discarded anyway.
- for (var _iterator = _createForOfIteratorHelperLoose$5(string.split('')), _step; !(_step = _iterator()).done;) {
+ for (var _iterator = _createForOfIteratorHelperLoose$4(string.split('')), _step; !(_step = _iterator()).done;) {
var character = _step.value;
result += parsePhoneNumberCharacter(character, result) || '';
}
@@ -5939,11 +6187,11 @@
return parseDigit(character);
}
- function _createForOfIteratorHelperLoose$4(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray$5(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
+ function _createForOfIteratorHelperLoose$3(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray$4(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
- function _unsupportedIterableToArray$5(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$5(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$5(o, minLen); }
+ function _unsupportedIterableToArray$4(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$4(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$4(o, minLen); }
- function _arrayLikeToArray$5(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; }
+ function _arrayLikeToArray$4(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; }
/**
* Merges two arrays.
@@ -5954,7 +6202,7 @@
function mergeArrays(a, b) {
var merged = a.slice();
- for (var _iterator = _createForOfIteratorHelperLoose$4(b), _step; !(_step = _iterator()).done;) {
+ for (var _iterator = _createForOfIteratorHelperLoose$3(b), _step; !(_step = _iterator()).done;) {
var element = _step.value;
if (a.indexOf(element) < 0) {
@@ -6051,6 +6299,20 @@
return possible_lengths.indexOf(actual_length, 1) >= 0 ? 'IS_POSSIBLE' : 'INVALID_LENGTH';
}
+ /**
+ * Checks if a phone number is "possible" (basically just checks its length).
+ *
+ * isPossible(phoneNumberInstance, { ..., v2: true }, metadata)
+ *
+ * isPossible({ phone: '8005553535', country: 'RU' }, { ... }, metadata)
+ * isPossible({ phone: '8005553535', country: 'RU' }, undefined, metadata)
+ *
+ * @param {object|PhoneNumber} input — If `options.v2: true` flag is passed, the `input` should be a `PhoneNumber` instance. Otherwise, it should be an object of shape `{ phone: '...', country: '...' }`.
+ * @param {object} [options]
+ * @param {object} metadata
+ * @return {string}
+ */
+
function isPossiblePhoneNumber(input, options, metadata) {
/* istanbul ignore if */
if (options === undefined) {
@@ -6119,94 +6381,6 @@
}
}
- function _slicedToArray$1(arr, i) { return _arrayWithHoles$1(arr) || _iterableToArrayLimit$1(arr, i) || _unsupportedIterableToArray$4(arr, i) || _nonIterableRest$1(); }
-
- function _nonIterableRest$1() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
-
- function _iterableToArrayLimit$1(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_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; }
-
- function _arrayWithHoles$1(arr) { if (Array.isArray(arr)) return arr; }
-
- function _createForOfIteratorHelperLoose$3(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray$4(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
-
- function _unsupportedIterableToArray$4(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$4(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$4(o, minLen); }
-
- function _arrayLikeToArray$4(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; }
-
- /**
- * @param {string} text - Phone URI (RFC 3966).
- * @return {object} `{ ?number, ?ext }`.
- */
-
- function parseRFC3966(text) {
- var number;
- var ext; // Replace "tel:" with "tel=" for parsing convenience.
-
- text = text.replace(/^tel:/, 'tel=');
-
- for (var _iterator = _createForOfIteratorHelperLoose$3(text.split(';')), _step; !(_step = _iterator()).done;) {
- var part = _step.value;
-
- var _part$split = part.split('='),
- _part$split2 = _slicedToArray$1(_part$split, 2),
- name = _part$split2[0],
- value = _part$split2[1];
-
- switch (name) {
- case 'tel':
- number = value;
- break;
-
- case 'ext':
- ext = value;
- break;
-
- case 'phone-context':
- // Only "country contexts" are supported.
- // "Domain contexts" are ignored.
- if (value[0] === '+') {
- number = value + number;
- }
-
- break;
- }
- } // If the phone number is not viable, then abort.
-
-
- if (!isViablePhoneNumber(number)) {
- return {};
- }
-
- var result = {
- number: number
- };
-
- if (ext) {
- result.ext = ext;
- }
-
- return result;
- }
- /**
- * @param {object} - `{ ?number, ?extension }`.
- * @return {string} Phone URI (RFC 3966).
- */
-
- function formatRFC3966(_ref) {
- var number = _ref.number,
- ext = _ref.ext;
-
- if (!number) {
- return '';
- }
-
- if (number[0] !== '+') {
- throw new Error("\"formatRFC3966()\" expects \"number\" to be in E.164 format.");
- }
-
- return "tel:".concat(number).concat(ext ? ';ext=' + ext : '');
- }
-
/**
* Checks whether the entire input sequence can be matched
* against the regular expression.
@@ -6229,10 +6403,11 @@
function getNumberType(input, options, metadata) {
// If assigning the `{}` default value is moved to the arguments above,
// code coverage would decrease for some weird reason.
- options = options || {}; // When `parse()` returned `{}`
- // meaning that the phone number is not a valid one.
+ options = options || {}; // When `parse()` returns an empty object — `{}` —
+ // that means that the phone number is malformed,
+ // so it can't possibly be valid.
- if (!input.country) {
+ if (!input.country && !input.countryCallingCode) {
return;
}
@@ -6309,6 +6484,11 @@
/**
* Checks if a given phone number is valid.
*
+ * isValid(phoneNumberInstance, { ..., v2: true }, metadata)
+ *
+ * isPossible({ phone: '8005553535', country: 'RU' }, { ... }, metadata)
+ * isPossible({ phone: '8005553535', country: 'RU' }, undefined, metadata)
+ *
* If the `number` is a string, it will be parsed to an object,
* but only if it contains only valid phone number characters (including punctuation).
* If the `number` is an object, it is used as is.
@@ -6340,12 +6520,15 @@
// If assigning the `{}` default value is moved to the arguments above,
// code coverage would decrease for some weird reason.
options = options || {};
- metadata = new Metadata(metadata); // This is just to support `isValidNumber({})`
- // for cases when `parseNumber()` returns `{}`.
-
- if (!input.country) {
- return false;
- }
+ metadata = new Metadata(metadata);
+ /**
+ * Checks if a phone number is "possible" (basically just checks its length).
+ *
+ * @param {object|PhoneNumber} input — If `options.v2: true` flag is passed, the `input` should be a `PhoneNumber` instance. Otherwise, it should be an object of shape `{ phone: '...', country: '...' }`.
+ * @param {object} [options]
+ * @param {object} metadata
+ * @return {string}
+ */
metadata.selectNumberingPlan(input.country, input.countryCallingCode); // By default, countries only have type regexps when it's required for
// distinguishing different countries having the same `countryCallingCode`.
@@ -6356,8 +6539,42 @@
// `nationalNumberPattern` as a "better than nothing" replacement.
- var national_number = options.v2 ? input.nationalNumber : input.phone;
- return matchesEntirely(national_number, metadata.nationalNumberPattern());
+ var nationalNumber = options.v2 ? input.nationalNumber : input.phone;
+ return matchesEntirely(nationalNumber, metadata.nationalNumberPattern());
+ }
+
+ /**
+ * Returns a list of countries that the phone number could potentially belong to.
+ * @param {string} callingCode — Calling code.
+ * @param {string} nationalNumber — National (significant) number.
+ * @param {object} metadata — Metadata.
+ * @return {string[]} A list of possible countries.
+ */
+
+ function getPossibleCountriesForNumber(callingCode, nationalNumber, metadata) {
+ var _metadata = new Metadata(metadata);
+
+ var possibleCountries = _metadata.getCountryCodesForCallingCode(callingCode);
+
+ if (!possibleCountries) {
+ return [];
+ }
+
+ return possibleCountries.filter(function (country) {
+ return couldNationalNumberBelongToCountry(nationalNumber, country, metadata);
+ });
+ }
+
+ function couldNationalNumberBelongToCountry(nationalNumber, country, metadata) {
+ var _metadata = new Metadata(metadata);
+
+ _metadata.selectNumberingPlan(country);
+
+ if (_metadata.numberingPlan.possibleLengths().indexOf(nationalNumber.length) >= 0) {
+ return true;
+ }
+
+ return false;
}
//
@@ -6452,39 +6669,62 @@
}
}
+ /**
+ * @param {object} - `{ ?number, ?extension }`.
+ * @return {string} Phone URI (RFC 3966).
+ */
+
+ function formatRFC3966(_ref) {
+ var number = _ref.number,
+ ext = _ref.ext;
+
+ if (!number) {
+ return '';
+ }
+
+ if (number[0] !== '+') {
+ throw new Error("\"formatRFC3966()\" expects \"number\" to be in E.164 format.");
+ }
+
+ return "tel:".concat(number).concat(ext ? ';ext=' + ext : '');
+ }
+
function _createForOfIteratorHelperLoose$1(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray$2(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray$2(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$2(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$2(o, minLen); }
function _arrayLikeToArray$2(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; }
- function ownKeys$4(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
+ function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
- function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$4(Object(source), !0).forEach(function (key) { _defineProperty$4(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$4(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
+ function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$3(Object(source), !0).forEach(function (key) { _defineProperty$3(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
- 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; }
+ 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; }
var DEFAULT_OPTIONS = {
formatExtension: function formatExtension(formattedNumber, extension, metadata) {
return "".concat(formattedNumber).concat(metadata.ext()).concat(extension);
}
- }; // Formats a phone number
- //
- // Example use cases:
- //
- // ```js
- // formatNumber('8005553535', 'RU', 'INTERNATIONAL')
- // formatNumber('8005553535', 'RU', 'INTERNATIONAL', metadata)
- // formatNumber({ phone: '8005553535', country: 'RU' }, 'INTERNATIONAL')
- // formatNumber({ phone: '8005553535', country: 'RU' }, 'INTERNATIONAL', metadata)
- // formatNumber('+78005553535', 'NATIONAL')
- // formatNumber('+78005553535', 'NATIONAL', metadata)
- // ```
- //
+ };
+ /**
+ * Formats a phone number.
+ *
+ * format(phoneNumberInstance, 'INTERNATIONAL', { ..., v2: true }, metadata)
+ * format(phoneNumberInstance, 'NATIONAL', { ..., v2: true }, metadata)
+ *
+ * format({ phone: '8005553535', country: 'RU' }, 'INTERNATIONAL', { ... }, metadata)
+ * format({ phone: '8005553535', country: 'RU' }, 'NATIONAL', undefined, metadata)
+ *
+ * @param {object|PhoneNumber} input — If `options.v2: true` flag is passed, the `input` should be a `PhoneNumber` instance. Otherwise, it should be an object of shape `{ phone: '...', country: '...' }`.
+ * @param {string} format
+ * @param {object} [options]
+ * @param {object} metadata
+ * @return {string}
+ */
function formatNumber(input, format, options, metadata) {
// Apply default options.
if (options) {
- options = _objectSpread$4(_objectSpread$4({}, DEFAULT_OPTIONS), options);
+ options = _objectSpread$3(_objectSpread$3({}, DEFAULT_OPTIONS), options);
} else {
options = DEFAULT_OPTIONS;
}
@@ -6629,11 +6869,11 @@
}
}
- function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
+ function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
- function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$3(Object(source), !0).forEach(function (key) { _defineProperty$3(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
+ function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$2(Object(source), !0).forEach(function (key) { _defineProperty$2(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
- 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; }
+ 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; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -6642,10 +6882,16 @@
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
var PhoneNumber = /*#__PURE__*/function () {
- function PhoneNumber(countryCallingCode, nationalNumber, metadata) {
+ /**
+ * @param {string} countryOrCountryCallingCode
+ * @param {string} nationalNumber
+ * @param {object} metadata — Metadata JSON
+ * @return {PhoneNumber}
+ */
+ function PhoneNumber(countryOrCountryCallingCode, nationalNumber, metadata) {
_classCallCheck(this, PhoneNumber);
- if (!countryCallingCode) {
+ if (!countryOrCountryCallingCode) {
throw new TypeError('`country` or `countryCallingCode` not passed');
}
@@ -6657,22 +6903,21 @@
throw new TypeError('`metadata` not passed');
}
- var _metadata = new Metadata(metadata); // If country code is passed then derive `countryCallingCode` from it.
- // Also store the country code as `.country`.
-
-
- if (isCountryCode(countryCallingCode)) {
- this.country = countryCallingCode;
-
- _metadata.country(countryCallingCode);
-
- countryCallingCode = _metadata.countryCallingCode();
- }
+ var _getCountryAndCountry = getCountryAndCountryCallingCode(countryOrCountryCallingCode, metadata),
+ country = _getCountryAndCountry.country,
+ countryCallingCode = _getCountryAndCountry.countryCallingCode;
+ this.country = country;
this.countryCallingCode = countryCallingCode;
this.nationalNumber = nationalNumber;
- this.number = '+' + this.countryCallingCode + this.nationalNumber;
- this.metadata = metadata;
+ this.number = '+' + this.countryCallingCode + this.nationalNumber; // Exclude `metadata` property output from `PhoneNumber.toString()`
+ // so that it doesn't clutter the console output of Node.js.
+ // Previously, when Node.js did `console.log(new PhoneNumber(...))`,
+ // it would output the whole internal structure of the `metadata` object.
+
+ this.getMetadata = function () {
+ return metadata;
+ };
}
_createClass(PhoneNumber, [{
@@ -6680,34 +6925,52 @@
value: function setExt(ext) {
this.ext = ext;
}
+ }, {
+ key: "getPossibleCountries",
+ value: function getPossibleCountries() {
+ if (this.country) {
+ return [this.country];
+ }
+
+ return getPossibleCountriesForNumber(this.countryCallingCode, this.nationalNumber, this.getMetadata());
+ }
}, {
key: "isPossible",
value: function isPossible() {
return isPossiblePhoneNumber(this, {
v2: true
- }, this.metadata);
+ }, this.getMetadata());
}
}, {
key: "isValid",
value: function isValid() {
return isValidNumber(this, {
v2: true
- }, this.metadata);
+ }, this.getMetadata());
}
}, {
key: "isNonGeographic",
value: function isNonGeographic() {
- var metadata = new Metadata(this.metadata);
+ var metadata = new Metadata(this.getMetadata());
return metadata.isNonGeographicCallingCode(this.countryCallingCode);
}
}, {
key: "isEqual",
value: function isEqual(phoneNumber) {
return this.number === phoneNumber.number && this.ext === phoneNumber.ext;
- } // // Is just an alias for `this.isValid() && this.country === country`.
- // // https://github.com/googlei18n/libphonenumber/blob/master/FAQ.md#when-should-i-use-isvalidnumberforregion
- // isValidForRegion(country) {
- // return isValidNumberForRegion(this, country, { v2: true }, this.metadata)
+ } // This function was originally meant to be an equivalent for `validatePhoneNumberLength()`,
+ // but later it was found out that it doesn't include the possible `TOO_SHORT` result
+ // returned from `parsePhoneNumberWithError()` in the original `validatePhoneNumberLength()`,
+ // so eventually I simply commented out this method from the `PhoneNumber` class
+ // and just left the `validatePhoneNumberLength()` function, even though that one would require
+ // and additional step to also validate the actual country / calling code of the phone number.
+ // validateLength() {
+ // const metadata = new Metadata(this.getMetadata())
+ // metadata.selectNumberingPlan(this.countryCallingCode)
+ // const result = checkNumberLength(this.nationalNumber, metadata)
+ // if (result !== 'IS_POSSIBLE') {
+ // return result
+ // }
// }
}, {
@@ -6715,16 +6978,16 @@
value: function getType() {
return getNumberType(this, {
v2: true
- }, this.metadata);
+ }, this.getMetadata());
}
}, {
key: "format",
value: function format(_format, options) {
- return formatNumber(this, _format, options ? _objectSpread$3(_objectSpread$3({}, options), {}, {
+ return formatNumber(this, _format, options ? _objectSpread$2(_objectSpread$2({}, options), {}, {
v2: true
}) : {
v2: true
- }, this.metadata);
+ }, this.getMetadata());
}
}, {
key: "formatNational",
@@ -6750,6 +7013,26 @@
return /^[A-Z]{2}$/.test(value);
};
+ function getCountryAndCountryCallingCode(countryOrCountryCallingCode, metadataJson) {
+ var country;
+ var countryCallingCode;
+ var metadata = new Metadata(metadataJson); // If country code is passed then derive `countryCallingCode` from it.
+ // Also store the country code as `.country`.
+
+ if (isCountryCode(countryOrCountryCallingCode)) {
+ country = countryOrCountryCallingCode;
+ metadata.selectNumberingPlan(country);
+ countryCallingCode = metadata.countryCallingCode();
+ } else {
+ countryCallingCode = countryOrCountryCallingCode;
+ }
+
+ return {
+ country: country,
+ countryCallingCode: countryCallingCode
+ };
+ }
+
var CAPTURING_DIGIT_PATTERN = new RegExp('([' + VALID_DIGITS + '])');
function stripIddPrefix(number, country, callingCode, metadata) {
if (!country) {
@@ -7052,7 +7335,7 @@
* @param {string} [country] — Default country.
* @param {string} [callingCode] — Default calling code (some phone numbering plans are non-geographic).
* @param {object} metadata
- * @return {object} `{ countryCallingCode: string?, number: string }`
+ * @return {object} `{ countryCallingCodeSource: string?, countryCallingCode: string?, number: string }`
* @example
* // Returns `{ countryCallingCode: "1", number: "2133734253" }`.
* extractCountryCallingCode('2133734253', 'US', null, metadata)
@@ -7064,7 +7347,9 @@
function extractCountryCallingCode(number, country, callingCode, metadata) {
if (!number) {
return {};
- } // If this is not an international phone number,
+ }
+
+ var isNumberWithIddPrefix; // If this is not an international phone number,
// then either extract an "IDD" prefix, or extract a
// country calling code from a number by autocorrecting it
// by prepending a leading `+` in cases when it starts
@@ -7072,7 +7357,6 @@
// https://wikitravel.org/en/International_dialling_prefix
// https://github.com/catamphetamine/libphonenumber-js/issues/376
-
if (number[0] !== '+') {
// Convert an "out-of-country" dialing phone number
// to a proper international phone number.
@@ -7081,6 +7365,7 @@
// for subsequent parsing.
if (numberWithoutIDD && numberWithoutIDD !== number) {
+ isNumberWithIddPrefix = true;
number = '+' + numberWithoutIDD;
} else {
// Check to see if the number starts with the country calling code
@@ -7094,6 +7379,7 @@
if (countryCallingCode) {
return {
+ countryCallingCodeSource: 'FROM_NUMBER_WITHOUT_PLUS_SIGN',
countryCallingCode: countryCallingCode,
number: shorterNumber
};
@@ -7101,6 +7387,8 @@
}
return {
+ // No need to set it to `UNSPECIFIED`. It can be just `undefined`.
+ // countryCallingCodeSource: 'UNSPECIFIED',
number: number
};
}
@@ -7129,6 +7417,7 @@
if (metadata.hasCallingCode(_countryCallingCode)) {
metadata.selectNumberingPlan(_countryCallingCode);
return {
+ countryCallingCodeSource: isNumberWithIddPrefix ? 'FROM_NUMBER_WITH_IDD' : 'FROM_NUMBER_WITH_PLUS_SIGN',
countryCallingCode: _countryCallingCode,
number: number.slice(i)
};
@@ -7138,22 +7427,106 @@
}
return {};
- }
+ } // The possible values for the returned `countryCallingCodeSource` are:
+ //
+ // Copy-pasted from:
+ // https://github.com/google/libphonenumber/blob/master/resources/phonenumber.proto
+ //
+ // // The source from which the country_code is derived. This is not set in the
+ // // general parsing method, but in the method that parses and keeps raw_input.
+ // // New fields could be added upon request.
+ // enum CountryCodeSource {
+ // // Default value returned if this is not set, because the phone number was
+ // // created using parse, not parseAndKeepRawInput. hasCountryCodeSource will
+ // // return false if this is the case.
+ // UNSPECIFIED = 0;
+ //
+ // // The country_code is derived based on a phone number with a leading "+",
+ // // e.g. the French number "+33 1 42 68 53 00".
+ // FROM_NUMBER_WITH_PLUS_SIGN = 1;
+ //
+ // // The country_code is derived based on a phone number with a leading IDD,
+ // // e.g. the French number "011 33 1 42 68 53 00", as it is dialled from US.
+ // FROM_NUMBER_WITH_IDD = 5;
+ //
+ // // The country_code is derived based on a phone number without a leading
+ // // "+", e.g. the French number "33 1 42 68 53 00" when defaultCountry is
+ // // supplied as France.
+ // FROM_NUMBER_WITHOUT_PLUS_SIGN = 10;
+ //
+ // // The country_code is derived NOT based on the phone number itself, but
+ // // from the defaultCountry parameter provided in the parsing function by the
+ // // clients. This happens mostly for numbers written in the national format
+ // // (without country code). For example, this would be set when parsing the
+ // // French number "01 42 68 53 00", when defaultCountry is supplied as
+ // // France.
+ // FROM_DEFAULT_COUNTRY = 20;
+ // }
function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray$1(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray$1(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$1(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$1(o, minLen); }
function _arrayLikeToArray$1(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; }
+ function getCountryByNationalNumber(nationalPhoneNumber, _ref) {
+ var countries = _ref.countries,
+ defaultCountry = _ref.defaultCountry,
+ metadata = _ref.metadata;
+ // Re-create `metadata` because it will be selecting a `country`.
+ metadata = new Metadata(metadata);
+ var matchingCountries = [];
+
+ for (var _iterator = _createForOfIteratorHelperLoose(countries), _step; !(_step = _iterator()).done;) {
+ var country = _step.value;
+ metadata.country(country); // "Leading digits" patterns are only defined for about 20% of all countries.
+ // By definition, matching "leading digits" is a sufficient but not a necessary
+ // condition for a phone number to belong to a country.
+ // The point of "leading digits" check is that it's the fastest one to get a match.
+ // https://gitlab.com/catamphetamine/libphonenumber-js/blob/master/METADATA.md#leading_digits
+ // I'd suppose that "leading digits" patterns are mutually exclusive for different countries
+ // because of the intended use of that feature.
+
+ if (metadata.leadingDigits()) {
+ if (nationalPhoneNumber && nationalPhoneNumber.search(metadata.leadingDigits()) === 0) {
+ return country;
+ }
+ } // Else perform full validation with all of those
+ // fixed-line/mobile/etc regular expressions.
+ else if (getNumberType({
+ phone: nationalPhoneNumber,
+ country: country
+ }, undefined, metadata.metadata)) {
+ // If the `defaultCountry` is among the `matchingCountries` then return it.
+ if (defaultCountry) {
+ if (country === defaultCountry) {
+ return country;
+ }
+
+ matchingCountries.push(country);
+ } else {
+ return country;
+ }
+ }
+ } // Return the first ("main") one of the `matchingCountries`.
+
+
+ if (matchingCountries.length > 0) {
+ return matchingCountries[0];
+ }
+ }
+
var USE_NON_GEOGRAPHIC_COUNTRY_CODE = false;
- function getCountryByCallingCode(callingCode, nationalPhoneNumber, metadata) {
+ function getCountryByCallingCode(callingCode, _ref) {
+ var nationalPhoneNumber = _ref.nationalNumber,
+ defaultCountry = _ref.defaultCountry,
+ metadata = _ref.metadata;
+
/* istanbul ignore if */
if (USE_NON_GEOGRAPHIC_COUNTRY_CODE) {
if (metadata.isNonGeographicCallingCode(callingCode)) {
return '001';
}
- } // Is always non-empty, because `callingCode` is always valid
-
+ }
var possibleCountries = metadata.getCountryCodesForCallingCode(callingCode);
@@ -7167,32 +7540,154 @@
return possibleCountries[0];
}
- return selectCountryFromList(possibleCountries, nationalPhoneNumber, metadata.metadata);
+ return getCountryByNationalNumber(nationalPhoneNumber, {
+ countries: possibleCountries,
+ defaultCountry: defaultCountry,
+ metadata: metadata.metadata
+ });
}
- function selectCountryFromList(possibleCountries, nationalPhoneNumber, metadata) {
- // Re-create `metadata` because it will be selecting a `country`.
- metadata = new Metadata(metadata);
+ // When phone numbers are written in `RFC3966` format — `"tel:+12133734253"` —
+ var PLUS_SIGN = '+';
+ var RFC3966_VISUAL_SEPARATOR_ = '[\\-\\.\\(\\)]?';
+ var RFC3966_PHONE_DIGIT_ = '(' + '[' + VALID_DIGITS + ']' + '|' + RFC3966_VISUAL_SEPARATOR_ + ')';
+ var RFC3966_GLOBAL_NUMBER_DIGITS_ = '^' + '\\' + PLUS_SIGN + RFC3966_PHONE_DIGIT_ + '*' + '[' + VALID_DIGITS + ']' + RFC3966_PHONE_DIGIT_ + '*' + '$';
+ /**
+ * Regular expression of valid global-number-digits for the phone-context
+ * parameter, following the syntax defined in RFC3966.
+ */
- for (var _iterator = _createForOfIteratorHelperLoose(possibleCountries), _step; !(_step = _iterator()).done;) {
- var country = _step.value;
- metadata.country(country); // Leading digits check would be the simplest and fastest one.
- // Leading digits patterns are only defined for about 20% of all countries.
- // https://gitlab.com/catamphetamine/libphonenumber-js/blob/master/METADATA.md#leading_digits
- // Matching "leading digits" is a sufficient but not necessary condition.
+ var RFC3966_GLOBAL_NUMBER_DIGITS_PATTERN_ = new RegExp(RFC3966_GLOBAL_NUMBER_DIGITS_, 'g'); // In this port of Google's library, we don't accept alpha characters in phone numbers.
+ // const ALPHANUM_ = VALID_ALPHA_ + VALID_DIGITS
- if (metadata.leadingDigits()) {
- if (nationalPhoneNumber && nationalPhoneNumber.search(metadata.leadingDigits()) === 0) {
- return country;
- }
- } // Else perform full validation with all of those
- // fixed-line/mobile/etc regular expressions.
- else if (getNumberType({
- phone: nationalPhoneNumber,
- country: country
- }, undefined, metadata.metadata)) {
- return country;
+ var ALPHANUM_ = VALID_DIGITS;
+ var RFC3966_DOMAINLABEL_ = '[' + ALPHANUM_ + ']+((\\-)*[' + ALPHANUM_ + '])*';
+ var VALID_ALPHA_ = 'a-zA-Z';
+ var RFC3966_TOPLABEL_ = '[' + VALID_ALPHA_ + ']+((\\-)*[' + ALPHANUM_ + '])*';
+ var RFC3966_DOMAINNAME_ = '^(' + RFC3966_DOMAINLABEL_ + '\\.)*' + RFC3966_TOPLABEL_ + '\\.?$';
+ /**
+ * Regular expression of valid domainname for the phone-context parameter,
+ * following the syntax defined in RFC3966.
+ */
+
+ var RFC3966_DOMAINNAME_PATTERN_ = new RegExp(RFC3966_DOMAINNAME_, 'g');
+ var RFC3966_PREFIX_ = 'tel:';
+ var RFC3966_PHONE_CONTEXT_ = ';phone-context=';
+ var RFC3966_ISDN_SUBADDRESS_ = ';isub=';
+ /**
+ * Extracts the value of the phone-context parameter of `numberToExtractFrom`,
+ * following the syntax defined in RFC3966.
+ *
+ * @param {string} numberToExtractFrom
+ * @return {string|null} the extracted string (possibly empty), or `null` if no phone-context parameter is found.
+ */
+
+ function extractPhoneContext(numberToExtractFrom) {
+ var indexOfPhoneContext = numberToExtractFrom.indexOf(RFC3966_PHONE_CONTEXT_); // If no phone-context parameter is present
+
+ if (indexOfPhoneContext < 0) {
+ return null;
+ }
+
+ var phoneContextStart = indexOfPhoneContext + RFC3966_PHONE_CONTEXT_.length; // If phone-context parameter is empty
+
+ if (phoneContextStart >= numberToExtractFrom.length) {
+ return '';
+ }
+
+ var phoneContextEnd = numberToExtractFrom.indexOf(';', phoneContextStart); // If phone-context is not the last parameter
+
+ if (phoneContextEnd >= 0) {
+ return numberToExtractFrom.substring(phoneContextStart, phoneContextEnd);
+ } else {
+ return numberToExtractFrom.substring(phoneContextStart);
+ }
+ }
+ /**
+ * Returns whether the value of phoneContext follows the syntax defined in RFC3966.
+ *
+ * @param {string|null} phoneContext
+ * @return {boolean}
+ */
+
+ function isPhoneContextValid(phoneContext) {
+ if (phoneContext === null) {
+ return true;
+ }
+
+ if (phoneContext.length === 0) {
+ return false;
+ } // Does phone-context value match pattern of global-number-digits or domainname.
+
+
+ return RFC3966_GLOBAL_NUMBER_DIGITS_PATTERN_.test(phoneContext) || RFC3966_DOMAINNAME_PATTERN_.test(phoneContext);
+ }
+
+ /**
+ * @param {string} numberToParse
+ * @param {string} nationalNumber
+ * @return {}
+ */
+
+ function extractFormattedPhoneNumberFromPossibleRfc3966NumberUri(numberToParse, _ref) {
+ var extractFormattedPhoneNumber = _ref.extractFormattedPhoneNumber;
+ var phoneContext = extractPhoneContext(numberToParse);
+
+ if (!isPhoneContextValid(phoneContext)) {
+ throw new ParseError('NOT_A_NUMBER');
+ }
+
+ var phoneNumberString;
+
+ if (phoneContext === null) {
+ // Extract a possible number from the string passed in.
+ // (this strips leading characters that could not be the start of a phone number)
+ phoneNumberString = extractFormattedPhoneNumber(numberToParse) || '';
+ } else {
+ phoneNumberString = ''; // If the phone context contains a phone number prefix, we need to capture
+ // it, whereas domains will be ignored.
+
+ if (phoneContext.charAt(0) === PLUS_SIGN) {
+ phoneNumberString += phoneContext;
+ } // Now append everything between the "tel:" prefix and the phone-context.
+ // This should include the national number, an optional extension or
+ // isdn-subaddress component. Note we also handle the case when "tel:" is
+ // missing, as we have seen in some of the phone number inputs.
+ // In that case, we append everything from the beginning.
+
+
+ var indexOfRfc3966Prefix = numberToParse.indexOf(RFC3966_PREFIX_);
+ var indexOfNationalNumber; // RFC 3966 "tel:" prefix is preset at this stage because
+ // `isPhoneContextValid()` requires it to be present.
+
+ /* istanbul ignore else */
+
+ if (indexOfRfc3966Prefix >= 0) {
+ indexOfNationalNumber = indexOfRfc3966Prefix + RFC3966_PREFIX_.length;
+ } else {
+ indexOfNationalNumber = 0;
}
+
+ var indexOfPhoneContext = numberToParse.indexOf(RFC3966_PHONE_CONTEXT_);
+ phoneNumberString += numberToParse.substring(indexOfNationalNumber, indexOfPhoneContext);
+ } // Delete the isdn-subaddress and everything after it if it is present.
+ // Note extension won't appear at the same time with isdn-subaddress
+ // according to paragraph 5.3 of the RFC3966 spec.
+
+
+ var indexOfIsdn = phoneNumberString.indexOf(RFC3966_ISDN_SUBADDRESS_);
+
+ if (indexOfIsdn > 0) {
+ phoneNumberString = phoneNumberString.substring(0, indexOfIsdn);
+ } // If both phone context and isdn-subaddress are absent but other
+ // parameters are present, the parameters are left in nationalNumber.
+ // This is because we are concerned about deleting content from a potential
+ // number string when there is no strong evidence that the number is
+ // actually written in RFC3966.
+
+
+ if (phoneNumberString !== '') {
+ return phoneNumberString;
}
}
@@ -7217,6 +7712,19 @@
// ```
//
+ /**
+ * Parses a phone number.
+ *
+ * parse('123456789', { defaultCountry: 'RU', v2: true }, metadata)
+ * parse('123456789', { defaultCountry: 'RU' }, metadata)
+ * parse('123456789', undefined, metadata)
+ *
+ * @param {string} input
+ * @param {object} [options]
+ * @param {object} metadata
+ * @return {object|PhoneNumber?} If `options.v2: true` flag is passed, it returns a `PhoneNumber?` instance. Otherwise, returns an object of shape `{ phone: '...', country: '...' }` (or just `{}` if no phone number was parsed).
+ */
+
function parse(text, options, metadata) {
// If assigning the `{}` default value is moved to the arguments above,
// code coverage would decrease for some weird reason.
@@ -7250,10 +7758,11 @@
return {};
}
- var _parsePhoneNumber = parsePhoneNumber$1(formattedPhoneNumber, options.defaultCountry, options.defaultCallingCode, metadata),
+ var _parsePhoneNumber = parsePhoneNumber(formattedPhoneNumber, options.defaultCountry, options.defaultCallingCode, metadata),
country = _parsePhoneNumber.country,
nationalNumber = _parsePhoneNumber.nationalNumber,
countryCallingCode = _parsePhoneNumber.countryCallingCode,
+ countryCallingCodeSource = _parsePhoneNumber.countryCallingCodeSource,
carrierCode = _parsePhoneNumber.carrierCode;
if (!metadata.hasSelectedNumberingPlan()) {
@@ -7310,6 +7819,7 @@
phoneNumber.ext = ext;
}
+ phoneNumber.__countryCallingCodeSource = countryCallingCodeSource;
return phoneNumber;
} // Check if national phone number pattern matches the number.
// National number pattern is different for each country,
@@ -7346,7 +7856,7 @@
* extractFormattedPhoneNumber("Call (213) 373-4253 for assistance.")
*/
- function extractFormattedPhoneNumber(text, extract, throwOnError) {
+ function _extractFormattedPhoneNumber(text, extract, throwOnError) {
if (!text) {
return;
}
@@ -7383,12 +7893,16 @@
function parseInput(text, v2, extract) {
- // Parse RFC 3966 phone number URI.
- if (text && text.indexOf('tel:') === 0) {
- return parseRFC3966(text);
- }
-
- var number = extractFormattedPhoneNumber(text, extract, v2); // If the phone number is not viable, then abort.
+ // // Parse RFC 3966 phone number URI.
+ // if (text && text.indexOf('tel:') === 0) {
+ // return parseRFC3966(text)
+ // }
+ // let number = extractFormattedPhoneNumber(text, extract, v2)
+ var number = extractFormattedPhoneNumberFromPossibleRfc3966NumberUri(text, {
+ extractFormattedPhoneNumber: function extractFormattedPhoneNumber(text) {
+ return _extractFormattedPhoneNumber(text, extract, v2);
+ }
+ }); // If the phone number is not viable, then abort.
if (!number) {
return {};
@@ -7443,9 +7957,10 @@
*/
- function parsePhoneNumber$1(formattedPhoneNumber, defaultCountry, defaultCallingCode, metadata) {
+ function parsePhoneNumber(formattedPhoneNumber, defaultCountry, defaultCallingCode, metadata) {
// Extract calling code from phone number.
var _extractCountryCallin = extractCountryCallingCode(parseIncompletePhoneNumber(formattedPhoneNumber), defaultCountry, defaultCallingCode, metadata.metadata),
+ countryCallingCodeSource = _extractCountryCallin.countryCallingCodeSource,
countryCallingCode = _extractCountryCallin.countryCallingCode,
number = _extractCountryCallin.number; // Choose a country by `countryCallingCode`.
@@ -7454,8 +7969,8 @@
if (countryCallingCode) {
metadata.selectNumberingPlan(countryCallingCode);
- } // If `formattedPhoneNumber` is in "national" format
- // then `number` is defined and `countryCallingCode` isn't.
+ } // If `formattedPhoneNumber` is passed in "national" format
+ // then `number` is defined and `countryCallingCode` is `undefined`.
else if (number && (defaultCountry || defaultCallingCode)) {
metadata.selectNumberingPlan(defaultCountry, defaultCallingCode);
@@ -7468,6 +7983,7 @@
if (!number) {
return {
+ countryCallingCodeSource: countryCallingCodeSource,
countryCallingCode: countryCallingCode
};
}
@@ -7486,7 +8002,11 @@
//
- var exactCountry = getCountryByCallingCode(countryCallingCode, nationalNumber, metadata);
+ var exactCountry = getCountryByCallingCode(countryCallingCode, {
+ nationalNumber: nationalNumber,
+ defaultCountry: defaultCountry,
+ metadata: metadata
+ });
if (exactCountry) {
country = exactCountry;
@@ -7500,29 +8020,28 @@
return {
country: country,
countryCallingCode: countryCallingCode,
+ countryCallingCodeSource: countryCallingCodeSource,
nationalNumber: nationalNumber,
carrierCode: carrierCode
};
}
- function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
+ function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
- function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$2(Object(source), !0).forEach(function (key) { _defineProperty$2(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
+ function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) { _defineProperty$1(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
- 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; }
- function parsePhoneNumber(text, options, metadata) {
- return parse(text, _objectSpread$2(_objectSpread$2({}, options), {}, {
+ 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; }
+ function parsePhoneNumberWithError$2(text, options, metadata) {
+ return parse(text, _objectSpread$1(_objectSpread$1({}, options), {}, {
v2: true
}), metadata);
}
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
-
- function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
- function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) { _defineProperty$1(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
- 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; }
+ 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; }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
@@ -7535,6 +8054,10 @@
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_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; }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
+ // * input `text`
+ // * `options` object
+ // * `metadata` JSON
+
function normalizeArguments(args) {
var _Array$prototype$slic = Array.prototype.slice.call(args),
_Array$prototype$slic2 = _slicedToArray(_Array$prototype$slic, 4),
@@ -7564,7 +8087,7 @@
}
if (arg_2) {
- options = _objectSpread$1({
+ options = _objectSpread({
defaultCountry: arg_2
}, options);
}
@@ -7584,49 +8107,19 @@
options: options,
metadata: metadata
};
- } // Otherwise istanbul would show this as "branch not covered".
-
- /* istanbul ignore next */
-
- var isObject$1 = function isObject(_) {
- return _typeof(_) === 'object';
- };
-
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
-
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
-
- 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; }
- function parsePhoneNumberFromString$2(text, options, metadata) {
- // Validate `defaultCountry`.
- if (options && options.defaultCountry && !isSupportedCountry(options.defaultCountry, metadata)) {
- options = _objectSpread(_objectSpread({}, options), {}, {
- defaultCountry: undefined
- });
- } // Parse phone number.
-
-
- try {
- return parsePhoneNumber(text, options, metadata);
- } catch (error) {
- /* istanbul ignore else */
- if (error instanceof ParseError) ; else {
- throw error;
- }
- }
}
- function parsePhoneNumberFromString$1() {
+ function parsePhoneNumberWithError$1() {
var _normalizeArguments = normalizeArguments(arguments),
text = _normalizeArguments.text,
options = _normalizeArguments.options,
metadata = _normalizeArguments.metadata;
- return parsePhoneNumberFromString$2(text, options, metadata);
+ return parsePhoneNumberWithError$2(text, options, metadata);
}
- function parsePhoneNumberFromString() {
- return withMetadataArgument(parsePhoneNumberFromString$1, arguments)
+ function parsePhoneNumberWithError() {
+ return withMetadataArgument(parsePhoneNumberWithError$1, arguments)
}
var IS_PHONE_NUMBER = 'isPhoneNumber';
@@ -7639,13 +8132,21 @@
* If text doesn't start with the international calling code (e.g. +41), then you must set this parameter.
*/
function isPhoneNumber(value, region) {
+ if (typeof value !== 'string' || value.trim() !== value) {
+ return false;
+ }
try {
- var phoneNum = parsePhoneNumberFromString(value, region);
- var result = phoneNum === null || phoneNum === void 0 ? void 0 : phoneNum.isValid();
- return !!result;
+ var phoneNumber = parsePhoneNumberWithError(value, region);
+ /**
+ * We fail the validation if the user provided a region code
+ * and it doesn't match with the country code of the parsed number.
+ **/
+ if (region && phoneNumber.country !== region) {
+ return false;
+ }
+ return phoneNumber.isValid();
}
catch (error) {
- // logging?
return false;
}
}
@@ -7692,6 +8193,8 @@
var isHash$1 = {exports: {}};
+ isHash$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -7699,7 +8202,7 @@
});
exports.default = isHash;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -7729,7 +8232,8 @@
module.exports.default = exports.default;
} (isHash$1, isHash$1.exports));
- var isHashValidator = /*@__PURE__*/getDefaultExportFromCjs(isHash$1.exports);
+ var isHashExports = isHash$1.exports;
+ var isHashValidator = /*@__PURE__*/getDefaultExportFromCjs(isHashExports);
var IS_HASH = 'isHash';
/**
@@ -7758,6 +8262,8 @@
var isISSN$1 = {exports: {}};
+ isISSN$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -7765,7 +8271,7 @@
});
exports.default = isISSN;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -7797,7 +8303,8 @@
module.exports.default = exports.default;
} (isISSN$1, isISSN$1.exports));
- var isISSNValidator = /*@__PURE__*/getDefaultExportFromCjs(isISSN$1.exports);
+ var isISSNExports = isISSN$1.exports;
+ var isISSNValidator = /*@__PURE__*/getDefaultExportFromCjs(isISSNExports);
var IS_ISSN = 'isISSN';
/**
@@ -7845,6 +8352,8 @@
var isBoolean$1 = {exports: {}};
+ isBoolean$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -7852,7 +8361,7 @@
});
exports.default = isBoolean;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -7877,7 +8386,8 @@
module.exports.default = exports.default;
} (isBoolean$1, isBoolean$1.exports));
- var isBooleanValidator = /*@__PURE__*/getDefaultExportFromCjs(isBoolean$1.exports);
+ var isBooleanExports = isBoolean$1.exports;
+ var isBooleanValidator = /*@__PURE__*/getDefaultExportFromCjs(isBooleanExports);
var IS_BOOLEAN_STRING = 'isBooleanString';
/**
@@ -7903,6 +8413,8 @@
var isNumeric = {exports: {}};
+ isNumeric.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -7910,7 +8422,7 @@
});
exports.default = isNumeric;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
var _alpha = alpha$1;
@@ -7932,7 +8444,8 @@
module.exports.default = exports.default;
} (isNumeric, isNumeric.exports));
- var isNumericValidator = /*@__PURE__*/getDefaultExportFromCjs(isNumeric.exports);
+ var isNumericExports = isNumeric.exports;
+ var isNumericValidator = /*@__PURE__*/getDefaultExportFromCjs(isNumericExports);
var IS_NUMBER_STRING = 'isNumberString';
/**
@@ -7959,6 +8472,8 @@
var isBase32$1 = {exports: {}};
+ isBase32$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -7966,14 +8481,26 @@
});
exports.default = isBase32;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
+
+ var _merge = _interopRequireDefault(mergeExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var base32 = /^[A-Z2-7]+=*$/;
+ var crockfordBase32 = /^[A-HJKMNP-TV-Z0-9]+$/;
+ var defaultBase32Options = {
+ crockford: false
+ };
- function isBase32(str) {
+ function isBase32(str, options) {
(0, _assertString.default)(str);
+ options = (0, _merge.default)(options, defaultBase32Options);
+
+ if (options.crockford) {
+ return crockfordBase32.test(str);
+ }
+
var len = str.length;
if (len % 8 === 0 && base32.test(str)) {
@@ -7987,7 +8514,8 @@
module.exports.default = exports.default;
} (isBase32$1, isBase32$1.exports));
- var isBase32Validator = /*@__PURE__*/getDefaultExportFromCjs(isBase32$1.exports);
+ var isBase32Exports = isBase32$1.exports;
+ var isBase32Validator = /*@__PURE__*/getDefaultExportFromCjs(isBase32Exports);
var IS_BASE32 = 'isBase32';
/**
@@ -8013,6 +8541,8 @@
var isBIC$1 = {exports: {}};
+ isBIC$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -8020,7 +8550,7 @@
});
exports.default = isBIC;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
var _isISO31661Alpha = isISO31661Alpha2$2;
@@ -8033,7 +8563,9 @@
(0, _assertString.default)(str); // toUpperCase() should be removed when a new major version goes out that changes
// the regex to [A-Z] (per the spec).
- if (!_isISO31661Alpha.CountryCodes.has(str.slice(4, 6).toUpperCase())) {
+ var countryCode = str.slice(4, 6).toUpperCase();
+
+ if (!_isISO31661Alpha.CountryCodes.has(countryCode) && countryCode !== 'XK') {
return false;
}
@@ -8044,7 +8576,8 @@
module.exports.default = exports.default;
} (isBIC$1, isBIC$1.exports));
- var isBICValidator = /*@__PURE__*/getDefaultExportFromCjs(isBIC$1.exports);
+ var isBICExports = isBIC$1.exports;
+ var isBICValidator = /*@__PURE__*/getDefaultExportFromCjs(isBICExports);
var IS_BIC = 'isBIC';
/**
@@ -8070,6 +8603,8 @@
var isBtcAddress$1 = {exports: {}};
+ isBtcAddress$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -8077,29 +8612,24 @@
});
exports.default = isBtcAddress;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- // supports Bech32 addresses
var bech32 = /^(bc1)[a-z0-9]{25,39}$/;
var base58 = /^(1|3)[A-HJ-NP-Za-km-z1-9]{25,39}$/;
function isBtcAddress(str) {
- (0, _assertString.default)(str); // check for bech32
-
- if (str.startsWith('bc1')) {
- return bech32.test(str);
- }
-
- return base58.test(str);
+ (0, _assertString.default)(str);
+ return bech32.test(str) || base58.test(str);
}
module.exports = exports.default;
module.exports.default = exports.default;
} (isBtcAddress$1, isBtcAddress$1.exports));
- var isBtcAddressValidator = /*@__PURE__*/getDefaultExportFromCjs(isBtcAddress$1.exports);
+ var isBtcAddressExports = isBtcAddress$1.exports;
+ var isBtcAddressValidator = /*@__PURE__*/getDefaultExportFromCjs(isBtcAddressExports);
var IS_BTC_ADDRESS = 'isBtcAddress';
/**
@@ -8125,6 +8655,8 @@
var isDataURI$1 = {exports: {}};
+ isDataURI$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -8132,11 +8664,11 @@
});
exports.default = isDataURI;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- var validMediaType = /^[a-z]+\/[a-z0-9\-\+]+$/i;
+ var validMediaType = /^[a-z]+\/[a-z0-9\-\+\._]+$/i;
var validAttribute = /^[a-z\-]+=[a-z0-9\-]+$/i;
var validData = /^[a-z0-9!\$&'\(\)\*\+,;=\-\._~:@\/\?%\s]*$/i;
@@ -8151,11 +8683,11 @@
var attributes = data.shift().trim().split(';');
var schemeAndMediaType = attributes.shift();
- if (schemeAndMediaType.substr(0, 5) !== 'data:') {
+ if (schemeAndMediaType.slice(0, 5) !== 'data:') {
return false;
}
- var mediaType = schemeAndMediaType.substr(5);
+ var mediaType = schemeAndMediaType.slice(5);
if (mediaType !== '' && !validMediaType.test(mediaType)) {
return false;
@@ -8180,7 +8712,8 @@
module.exports.default = exports.default;
} (isDataURI$1, isDataURI$1.exports));
- var isDataURIValidator = /*@__PURE__*/getDefaultExportFromCjs(isDataURI$1.exports);
+ var isDataURIExports = isDataURI$1.exports;
+ var isDataURIValidator = /*@__PURE__*/getDefaultExportFromCjs(isDataURIExports);
var IS_DATA_URI = 'isDataURI';
/**
@@ -8206,6 +8739,8 @@
var isEAN$1 = {exports: {}};
+ isEAN$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -8213,7 +8748,7 @@
});
exports.default = isEAN;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -8293,7 +8828,8 @@
module.exports.default = exports.default;
} (isEAN$1, isEAN$1.exports));
- var isEANValidator = /*@__PURE__*/getDefaultExportFromCjs(isEAN$1.exports);
+ var isEANExports = isEAN$1.exports;
+ var isEANValidator = /*@__PURE__*/getDefaultExportFromCjs(isEANExports);
var IS_EAN = 'isEAN';
/**
@@ -8319,6 +8855,8 @@
var isEthereumAddress$1 = {exports: {}};
+ isEthereumAddress$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -8326,7 +8864,7 @@
});
exports.default = isEthereumAddress;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -8341,7 +8879,8 @@
module.exports.default = exports.default;
} (isEthereumAddress$1, isEthereumAddress$1.exports));
- var isEthereumAddressValidator = /*@__PURE__*/getDefaultExportFromCjs(isEthereumAddress$1.exports);
+ var isEthereumAddressExports = isEthereumAddress$1.exports;
+ var isEthereumAddressValidator = /*@__PURE__*/getDefaultExportFromCjs(isEthereumAddressExports);
var IS_ETHEREUM_ADDRESS = 'isEthereumAddress';
/**
@@ -8367,6 +8906,8 @@
var isHSL$1 = {exports: {}};
+ isHSL$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -8374,7 +8915,7 @@
});
exports.default = isHSL;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -8397,7 +8938,8 @@
module.exports.default = exports.default;
} (isHSL$1, isHSL$1.exports));
- var isHSLValidator = /*@__PURE__*/getDefaultExportFromCjs(isHSL$1.exports);
+ var isHSLExports = isHSL$1.exports;
+ var isHSLValidator = /*@__PURE__*/getDefaultExportFromCjs(isHSLExports);
var IS_HSL = 'isHSL';
/**
@@ -8431,7 +8973,7 @@
var _default$2 = isIBAN$2.default = isIBAN$1;
isIBAN$2.locales = void 0;
- var _assertString$3 = _interopRequireDefault$3(assertString.exports);
+ var _assertString$3 = _interopRequireDefault$3(assertStringExports);
function _interopRequireDefault$3(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -8598,6 +9140,8 @@
var isIdentityCard$1 = {exports: {}};
+ isIdentityCard$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -8605,9 +9149,9 @@
});
exports.default = isIdentityCard;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
- var _isInt = _interopRequireDefault(isInt$1.exports);
+ var _isInt = _interopRequireDefault(isIntExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -8707,13 +9251,13 @@
},
IR: function IR(str) {
if (!str.match(/^\d{10}$/)) return false;
- str = "0000".concat(str).substr(str.length - 6);
- if (parseInt(str.substr(3, 6), 10) === 0) return false;
- var lastNumber = parseInt(str.substr(9, 1), 10);
+ str = "0000".concat(str).slice(str.length - 6);
+ if (parseInt(str.slice(3, 9), 10) === 0) return false;
+ var lastNumber = parseInt(str.slice(9, 10), 10);
var sum = 0;
for (var i = 0; i < 9; i++) {
- sum += parseInt(str.substr(i, 1), 10) * (10 - i);
+ sum += parseInt(str.slice(i, i + 1), 10) * (10 - i);
}
sum %= 11;
@@ -8910,6 +9454,32 @@
return checkIdCardNo(str);
},
+ 'zh-HK': function zhHK(str) {
+ // sanitize user input
+ str = str.trim(); // HKID number starts with 1 or 2 letters, followed by 6 digits,
+ // then a checksum contained in square / round brackets or nothing
+
+ var regexHKID = /^[A-Z]{1,2}[0-9]{6}((\([0-9A]\))|(\[[0-9A]\])|([0-9A]))$/;
+ var regexIsDigit = /^[0-9]$/; // convert the user input to all uppercase and apply regex
+
+ str = str.toUpperCase();
+ if (!regexHKID.test(str)) return false;
+ str = str.replace(/\[|\]|\(|\)/g, '');
+ if (str.length === 8) str = "3".concat(str);
+ var checkSumVal = 0;
+
+ for (var i = 0; i <= 7; i++) {
+ var convertedChar = void 0;
+ if (!regexIsDigit.test(str[i])) convertedChar = (str[i].charCodeAt(0) - 55) % 11;else convertedChar = str[i];
+ checkSumVal += convertedChar * (9 - i);
+ }
+
+ checkSumVal %= 11;
+ var checkSumConverted;
+ if (checkSumVal === 0) checkSumConverted = '0';else if (checkSumVal === 1) checkSumConverted = 'A';else checkSumConverted = String(11 - checkSumVal);
+ if (checkSumConverted === str[str.length - 1]) return true;
+ return false;
+ },
'zh-TW': function zhTW(str) {
var ALPHABET_CODES = {
A: 10,
@@ -8984,7 +9554,8 @@
module.exports.default = exports.default;
} (isIdentityCard$1, isIdentityCard$1.exports));
- var isIdentityCardValidator = /*@__PURE__*/getDefaultExportFromCjs(isIdentityCard$1.exports);
+ var isIdentityCardExports = isIdentityCard$1.exports;
+ var isIdentityCardValidator = /*@__PURE__*/getDefaultExportFromCjs(isIdentityCardExports);
var IS_IDENTITY_CARD = 'isIdentityCard';
/**
@@ -9015,6 +9586,8 @@
var isISRC$1 = {exports: {}};
+ isISRC$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -9022,7 +9595,7 @@
});
exports.default = isISRC;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -9038,7 +9611,8 @@
module.exports.default = exports.default;
} (isISRC$1, isISRC$1.exports));
- var isISRCValidator = /*@__PURE__*/getDefaultExportFromCjs(isISRC$1.exports);
+ var isISRCExports = isISRC$1.exports;
+ var isISRCValidator = /*@__PURE__*/getDefaultExportFromCjs(isISRCExports);
var IS_ISRC = 'isISRC';
/**
@@ -9064,6 +9638,8 @@
var isLocale$1 = {exports: {}};
+ isLocale$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -9071,7 +9647,7 @@
});
exports.default = isLocale;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -9091,7 +9667,8 @@
module.exports.default = exports.default;
} (isLocale$1, isLocale$1.exports));
- var isLocaleValidator = /*@__PURE__*/getDefaultExportFromCjs(isLocale$1.exports);
+ var isLocaleExports = isLocale$1.exports;
+ var isLocaleValidator = /*@__PURE__*/getDefaultExportFromCjs(isLocaleExports);
var IS_LOCALE = 'isLocale';
/**
@@ -9117,6 +9694,8 @@
var isMagnetURI$1 = {exports: {}};
+ isMagnetURI$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -9124,22 +9703,28 @@
});
exports.default = isMagnetURI;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- 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;
+ var magnetURIComponent = /(?:^magnet:\?|[^?&]&)xt(?:\.1)?=urn:(?:(?:aich|bitprint|btih|ed2k|ed2khash|kzhash|md5|sha1|tree:tiger):[a-z0-9]{32}(?:[a-z0-9]{8})?|btmh:1220[a-z0-9]{64})(?:$|&)/i;
function isMagnetURI(url) {
(0, _assertString.default)(url);
- return magnetURI.test(url.trim());
+
+ if (url.indexOf('magnet:?') !== 0) {
+ return false;
+ }
+
+ return magnetURIComponent.test(url);
}
module.exports = exports.default;
module.exports.default = exports.default;
} (isMagnetURI$1, isMagnetURI$1.exports));
- var isMagnetURIValidator = /*@__PURE__*/getDefaultExportFromCjs(isMagnetURI$1.exports);
+ var isMagnetURIExports = isMagnetURI$1.exports;
+ var isMagnetURIValidator = /*@__PURE__*/getDefaultExportFromCjs(isMagnetURIExports);
var IS_MAGNET_URI = 'isMagnetURI';
/**
@@ -9165,6 +9750,8 @@
var isMimeType$1 = {exports: {}};
+ isMimeType$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -9172,7 +9759,7 @@
});
exports.default = isMimeType;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -9201,7 +9788,7 @@
// NB :
// Subtype length must not exceed 100 characters.
// This rule does not comply to the RFC specs (what is the max length ?).
- var mimeTypeSimple = /^(application|audio|font|image|message|model|multipart|text|video)\/[a-zA-Z0-9\.\-\+]{1,100}$/i; // eslint-disable-line max-len
+ var mimeTypeSimple = /^(application|audio|font|image|message|model|multipart|text|video)\/[a-zA-Z0-9\.\-\+_]{1,100}$/i; // eslint-disable-line max-len
// Handle "charset" in "text/*"
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
@@ -9218,7 +9805,8 @@
module.exports.default = exports.default;
} (isMimeType$1, isMimeType$1.exports));
- var isMimeTypeValidator = /*@__PURE__*/getDefaultExportFromCjs(isMimeType$1.exports);
+ var isMimeTypeExports = isMimeType$1.exports;
+ var isMimeTypeValidator = /*@__PURE__*/getDefaultExportFromCjs(isMimeTypeExports);
var IS_MIME_TYPE = 'isMimeType';
/**
@@ -9244,6 +9832,8 @@
var isOctal$1 = {exports: {}};
+ isOctal$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -9251,7 +9841,7 @@
});
exports.default = isOctal;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -9266,7 +9856,8 @@
module.exports.default = exports.default;
} (isOctal$1, isOctal$1.exports));
- var isOctalValidator = /*@__PURE__*/getDefaultExportFromCjs(isOctal$1.exports);
+ var isOctalExports = isOctal$1.exports;
+ var isOctalValidator = /*@__PURE__*/getDefaultExportFromCjs(isOctalExports);
var IS_OCTAL = 'isOctal';
/**
@@ -9292,6 +9883,8 @@
var isPassportNumber$1 = {exports: {}};
+ isPassportNumber$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -9299,7 +9892,7 @@
});
exports.default = isPassportNumber;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -9318,6 +9911,8 @@
// AUSTRIA
AU: /^[A-Z]\d{7}$/,
// AUSTRALIA
+ AZ: /^[A-Z]{2,3}\d{7,8}$/,
+ // AZERBAIJAN
BE: /^[A-Z]{2}\d{6}$/,
// BELGIUM
BG: /^\d{9}$/,
@@ -9370,10 +9965,16 @@
// ICELAND
IT: /^[A-Z0-9]{2}\d{7}$/,
// ITALY
+ JM: /^[Aa]\d{7}$/,
+ // JAMAICA
JP: /^[A-Z]{2}\d{7}$/,
// JAPAN
KR: /^[MS]\d{8}$/,
// SOUTH KOREA, REPUBLIC OF KOREA, [S=PS Passports, M=PM Passports]
+ KZ: /^[a-zA-Z]\d{7}$/,
+ // KAZAKHSTAN
+ LI: /^[a-zA-Z]\d{5}$/,
+ // LIECHTENSTEIN
LT: /^[A-Z0-9]{8}$/,
// LITHUANIA
LU: /^[A-Z0-9]{8}$/,
@@ -9388,8 +9989,16 @@
// MOZAMBIQUE
MY: /^[AHK]\d{8}$/,
// MALAYSIA
+ MX: /^\d{10,11}$/,
+ // MEXICO
NL: /^[A-Z]{2}[A-Z0-9]{6}\d$/,
// NETHERLANDS
+ NZ: /^([Ll]([Aa]|[Dd]|[Ff]|[Hh])|[Ee]([Aa]|[Pp])|[Nn])\d{6}$/,
+ // NEW ZEALAND
+ PH: /^([A-Z](\d{6}|\d{7}[A-Z]))|([A-Z]{2}(\d{6}|\d{7}))$/,
+ // PHILIPPINES
+ PK: /^[A-Z]{2}\d{7}$/,
+ // PAKISTAN
PL: /^[A-Z]{2}\d{7}$/,
// POLAND
PT: /^[A-Z]\d{6}$/,
@@ -9401,9 +10010,11 @@
SE: /^\d{8}$/,
// SWEDEN
SL: /^(P)[A-Z]\d{7}$/,
- // SLOVANIA
+ // SLOVENIA
SK: /^[0-9A-Z]\d{7}$/,
// SLOVAKIA
+ TH: /^[A-Z]{1,2}\d{6,7}$/,
+ // THAILAND
TR: /^[A-Z]\d{8}$/,
// TURKEY
UA: /^[A-Z]{2}\d{6}$/,
@@ -9432,7 +10043,8 @@
module.exports.default = exports.default;
} (isPassportNumber$1, isPassportNumber$1.exports));
- var isPassportNumberValidator = /*@__PURE__*/getDefaultExportFromCjs(isPassportNumber$1.exports);
+ var isPassportNumberExports = isPassportNumber$1.exports;
+ var isPassportNumberValidator = /*@__PURE__*/getDefaultExportFromCjs(isPassportNumberExports);
var IS_PASSPORT_NUMBER = 'isPassportNumber';
/**
@@ -9465,7 +10077,7 @@
var _default$1 = isPostalCode$2.default = isPostalCode$1;
isPostalCode$2.locales = void 0;
- var _assertString$2 = _interopRequireDefault$2(assertString.exports);
+ var _assertString$2 = _interopRequireDefault$2(assertStringExports);
function _interopRequireDefault$2(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -9479,10 +10091,11 @@
AT: fourDigit,
AU: fourDigit,
AZ: /^AZ\d{4}$/,
+ BA: /^([7-8]\d{4}$)/,
BE: fourDigit,
BG: fourDigit,
BR: /^\d{5}-\d{3}$/,
- BY: /2[1-4]{1}\d{4}$/,
+ BY: /^2[1-4]\d{4}$/,
CA: /^[ABCEGHJKLMNPRSTVXY]\d[ABCEGHJ-NPRSTV-Z][\s\-]?\d[ABCEGHJ-NPRSTV-Z]\d$/i,
CH: fourDigit,
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}$/,
@@ -9504,7 +10117,7 @@
IE: /^(?!.*(?:o))[A-Za-z]\d[\dw]\s\w{4}$/i,
IL: /^(\d{5}|\d{7})$/,
IN: /^((?!10|29|35|54|55|65|66|86|87|88|89)[1-9][0-9]{5})$/,
- IR: /\b(?!(\d)\1{3})[13-9]{4}[1346-9][013-9]{5}\b/,
+ IR: /^(?!(\d)\1{3})[13-9]{4}[1346-9][013-9]{5}$/,
IS: threeDigit,
IT: fiveDigit,
JP: /^\d{3}\-\d{4}$/,
@@ -9515,6 +10128,7 @@
LU: fourDigit,
LV: /^LV\-\d{4}$/,
LK: fiveDigit,
+ MG: threeDigit,
MX: fiveDigit,
MT: /^[A-Za-z]{3}\s{0,1}\d{4}$/,
MY: fiveDigit,
@@ -9592,6 +10206,8 @@
var isRFC3339$1 = {exports: {}};
+ isRFC3339$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -9599,7 +10215,7 @@
});
exports.default = isRFC3339;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -9627,7 +10243,8 @@
module.exports.default = exports.default;
} (isRFC3339$1, isRFC3339$1.exports));
- var isRFC3339Validator = /*@__PURE__*/getDefaultExportFromCjs(isRFC3339$1.exports);
+ var isRFC3339Exports = isRFC3339$1.exports;
+ var isRFC3339Validator = /*@__PURE__*/getDefaultExportFromCjs(isRFC3339Exports);
var IS_RFC_3339 = 'isRFC3339';
/**
@@ -9653,6 +10270,8 @@
var isRgbColor$1 = {exports: {}};
+ isRgbColor$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -9660,14 +10279,14 @@
});
exports.default = isRgbColor;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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])\)$/;
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)?)\)$/;
- var rgbColorPercent = /^rgb\((([0-9]%|[1-9][0-9]%|100%),){2}([0-9]%|[1-9][0-9]%|100%)\)/;
- var rgbaColorPercent = /^rgba\((([0-9]%|[1-9][0-9]%|100%),){3}(0?\.\d|1(\.0)?|0(\.0)?)\)/;
+ var rgbColorPercent = /^rgb\((([0-9]%|[1-9][0-9]%|100%),){2}([0-9]%|[1-9][0-9]%|100%)\)$/;
+ var rgbaColorPercent = /^rgba\((([0-9]%|[1-9][0-9]%|100%),){3}(0?\.\d|1(\.0)?|0(\.0)?)\)$/;
function isRgbColor(str) {
var includePercentValues = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
@@ -9684,7 +10303,8 @@
module.exports.default = exports.default;
} (isRgbColor$1, isRgbColor$1.exports));
- var isRgbColorValidator = /*@__PURE__*/getDefaultExportFromCjs(isRgbColor$1.exports);
+ var isRgbColorExports = isRgbColor$1.exports;
+ var isRgbColorValidator = /*@__PURE__*/getDefaultExportFromCjs(isRgbColorExports);
var IS_RGB_COLOR = 'isRgbColor';
/**
@@ -9715,6 +10335,8 @@
var multilineRegex = {exports: {}};
+ multilineRegex.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -9739,6 +10361,10 @@
module.exports.default = exports.default;
} (multilineRegex, multilineRegex.exports));
+ var multilineRegexExports = multilineRegex.exports;
+
+ isSemVer$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -9746,9 +10372,9 @@
});
exports.default = isSemVer;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
- var _multilineRegex = _interopRequireDefault(multilineRegex.exports);
+ var _multilineRegex = _interopRequireDefault(multilineRegexExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -9769,7 +10395,8 @@
module.exports.default = exports.default;
} (isSemVer$1, isSemVer$1.exports));
- var isSemVerValidator = /*@__PURE__*/getDefaultExportFromCjs(isSemVer$1.exports);
+ var isSemVerExports = isSemVer$1.exports;
+ var isSemVerValidator = /*@__PURE__*/getDefaultExportFromCjs(isSemVerExports);
var IS_SEM_VER = 'isSemVer';
/**
@@ -9797,6 +10424,8 @@
var toDate = {exports: {}};
+ toDate.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -9804,7 +10433,7 @@
});
exports.default = toDate;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -9818,8 +10447,12 @@
module.exports.default = exports.default;
} (toDate, toDate.exports));
+ var toDateExports = toDate.exports;
+
var toInt = {exports: {}};
+ toInt.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -9827,7 +10460,7 @@
});
exports.default = toInt;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -9840,8 +10473,12 @@
module.exports.default = exports.default;
} (toInt, toInt.exports));
+ var toIntExports = toInt.exports;
+
var toBoolean = {exports: {}};
+ toBoolean.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -9849,7 +10486,7 @@
});
exports.default = toBoolean;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -9867,8 +10504,12 @@
module.exports.default = exports.default;
} (toBoolean, toBoolean.exports));
+ var toBooleanExports = toBoolean.exports;
+
var equals = {exports: {}};
+ equals.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -9876,7 +10517,7 @@
});
exports.default = equals;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -9889,8 +10530,12 @@
module.exports.default = exports.default;
} (equals, equals.exports));
+ var equalsExports = equals.exports;
+
var isIPRange = {exports: {}};
+ isIPRange.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -9898,9 +10543,9 @@
});
exports.default = isIPRange;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
- var _isIP = _interopRequireDefault(isIP$1.exports);
+ var _isIP = _interopRequireDefault(isIPExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -9955,8 +10600,12 @@
module.exports.default = exports.default;
} (isIPRange, isIPRange.exports));
+ var isIPRangeExports = isIPRange.exports;
+
var isDate$1 = {exports: {}};
+ isDate$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -9964,7 +10613,7 @@
});
exports.default = isDate;
- var _merge = _interopRequireDefault(merge.exports);
+ var _merge = _interopRequireDefault(mergeExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -10058,8 +10707,54 @@
module.exports.default = exports.default;
} (isDate$1, isDate$1.exports));
+ var isDateExports = isDate$1.exports;
+
+ var isTime = {exports: {}};
+
+ isTime.exports;
+
+ (function (module, exports) {
+
+ Object.defineProperty(exports, "__esModule", {
+ value: true
+ });
+ exports.default = isTime;
+
+ var _merge = _interopRequireDefault(mergeExports);
+
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+ var default_time_options = {
+ hourFormat: 'hour24',
+ mode: 'default'
+ };
+ var formats = {
+ hour24: {
+ default: /^([01]?[0-9]|2[0-3]):([0-5][0-9])$/,
+ withSeconds: /^([01]?[0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$/
+ },
+ hour12: {
+ default: /^(0?[1-9]|1[0-2]):([0-5][0-9]) (A|P)M$/,
+ withSeconds: /^(0?[1-9]|1[0-2]):([0-5][0-9]):([0-5][0-9]) (A|P)M$/
+ }
+ };
+
+ function isTime(input, options) {
+ options = (0, _merge.default)(options, default_time_options);
+ if (typeof input !== 'string') return false;
+ return formats[options.hourFormat][options.mode].test(input);
+ }
+
+ module.exports = exports.default;
+ module.exports.default = exports.default;
+ } (isTime, isTime.exports));
+
+ var isTimeExports = isTime.exports;
+
var isIMEI = {exports: {}};
+ isIMEI.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -10067,7 +10762,7 @@
});
exports.default = isIMEI;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -10123,8 +10818,12 @@
module.exports.default = exports.default;
} (isIMEI, isIMEI.exports));
+ var isIMEIExports = isIMEI.exports;
+
var isMD5 = {exports: {}};
+ isMD5.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -10132,7 +10831,7 @@
});
exports.default = isMD5;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -10147,8 +10846,12 @@
module.exports.default = exports.default;
} (isMD5, isMD5.exports));
+ var isMD5Exports = isMD5.exports;
+
var isEmpty = {exports: {}};
+ isEmpty.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -10156,9 +10859,9 @@
});
exports.default = isEmpty;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
- var _merge = _interopRequireDefault(merge.exports);
+ var _merge = _interopRequireDefault(mergeExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -10176,8 +10879,12 @@
module.exports.default = exports.default;
} (isEmpty, isEmpty.exports));
+ var isEmptyExports = isEmpty.exports;
+
var isAfter = {exports: {}};
+ isAfter.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -10185,17 +10892,16 @@
});
exports.default = isAfter;
- var _assertString = _interopRequireDefault(assertString.exports);
-
- var _toDate = _interopRequireDefault(toDate.exports);
+ var _toDate = _interopRequireDefault(toDateExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- function isAfter(str) {
- var date = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : String(new Date());
- (0, _assertString.default)(str);
- var comparison = (0, _toDate.default)(date);
- var original = (0, _toDate.default)(str);
+ function isAfter(date, options) {
+ // For backwards compatibility:
+ // isAfter(str [, date]), i.e. `options` could be used as argument for the legacy `date`
+ var comparisonDate = (options === null || options === void 0 ? void 0 : options.comparisonDate) || options || Date().toString();
+ var comparison = (0, _toDate.default)(comparisonDate);
+ var original = (0, _toDate.default)(date);
return !!(original && comparison && original > comparison);
}
@@ -10203,8 +10909,12 @@
module.exports.default = exports.default;
} (isAfter, isAfter.exports));
+ var isAfterExports = isAfter.exports;
+
var isBefore = {exports: {}};
+ isBefore.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -10212,9 +10922,9 @@
});
exports.default = isBefore;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
- var _toDate = _interopRequireDefault(toDate.exports);
+ var _toDate = _interopRequireDefault(toDateExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -10230,8 +10940,12 @@
module.exports.default = exports.default;
} (isBefore, isBefore.exports));
+ var isBeforeExports = isBefore.exports;
+
var isIn = {exports: {}};
+ isIn.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -10239,9 +10953,9 @@
});
exports.default = isIn;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
- var _toString = _interopRequireDefault(toString$1.exports);
+ var _toString = _interopRequireDefault(toStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -10276,17 +10990,19 @@
module.exports.default = exports.default;
} (isIn, isIn.exports));
+ var isInExports = isIn.exports;
+
var isTaxID = {exports: {}};
- var algorithms = {};
+ var algorithms$1 = {};
- Object.defineProperty(algorithms, "__esModule", {
+ Object.defineProperty(algorithms$1, "__esModule", {
value: true
});
- algorithms.iso7064Check = iso7064Check;
- algorithms.luhnCheck = luhnCheck;
- algorithms.reverseMultiplyAndSum = reverseMultiplyAndSum;
- algorithms.verhoeffCheck = verhoeffCheck;
+ algorithms$1.iso7064Check = iso7064Check;
+ algorithms$1.luhnCheck = luhnCheck;
+ algorithms$1.reverseMultiplyAndSum = reverseMultiplyAndSum;
+ algorithms$1.verhoeffCheck = verhoeffCheck;
/**
* Algorithmic validation functions
@@ -10380,6 +11096,8 @@
return checksum === 0;
}
+ isTaxID.exports;
+
(function (module, exports) {
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); }
@@ -10389,11 +11107,11 @@
});
exports.default = isTaxID;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
- var algorithms$1 = _interopRequireWildcard(algorithms);
+ var algorithms = _interopRequireWildcard(algorithms$1);
- var _isDate = _interopRequireDefault(isDate$1.exports);
+ var _isDate = _interopRequireDefault(isDateExports);
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
@@ -10480,6 +11198,37 @@
checksum = checksum % 11 === 10 ? 0 : checksum % 11;
return checksum === digits[9];
}
+ /**
+ * Check if an input is a valid Canadian SIN (Social Insurance Number)
+ *
+ * The Social Insurance Number (SIN) is a 9 digit number that
+ * you need to work in Canada or to have access to government programs and benefits.
+ *
+ * https://en.wikipedia.org/wiki/Social_Insurance_Number
+ * https://www.canada.ca/en/employment-social-development/services/sin.html
+ * https://www.codercrunch.com/challenge/819302488/sin-validator
+ *
+ * @param {string} input
+ * @return {boolean}
+ */
+
+
+ function isCanadianSIN(input) {
+ var digitsArray = input.split('');
+ var even = digitsArray.filter(function (_, idx) {
+ return idx % 2;
+ }).map(function (i) {
+ return Number(i) * 2;
+ }).join('').split('');
+ var total = digitsArray.filter(function (_, idx) {
+ return !(idx % 2);
+ }).concat(even).map(function (i) {
+ return Number(i);
+ }).reduce(function (acc, cur) {
+ return acc + cur;
+ });
+ return total % 10 === 0;
+ }
/*
* cs-CZ validation function
* (Rodné číslo (RČ), persons only)
@@ -10573,7 +11322,7 @@
function deAtCheck(tin) {
- return algorithms$1.luhnCheck(tin);
+ return algorithms.luhnCheck(tin);
}
/*
* de-DE validation function
@@ -10628,7 +11377,7 @@
}
}
- return algorithms$1.iso7064Check(tin);
+ return algorithms.iso7064Check(tin);
}
/*
* dk-DK validation function
@@ -10779,7 +11528,7 @@
function enIeCheck(tin) {
- var checksum = algorithms$1.reverseMultiplyAndSum(tin.split('').slice(0, 7).map(function (a) {
+ var checksum = algorithms.reverseMultiplyAndSum(tin.split('').slice(0, 7).map(function (a) {
return parseInt(a, 10);
}), 8);
@@ -10832,7 +11581,7 @@
function enUsCheck(tin) {
- return enUsGetPrefixes().indexOf(tin.substr(0, 2)) !== -1;
+ return enUsGetPrefixes().indexOf(tin.slice(0, 2)) !== -1;
}
/*
* es-ES validation function
@@ -11051,12 +11800,12 @@
} // Run Luhn check
- if (!algorithms$1.luhnCheck(tin.slice(0, 12))) {
+ if (!algorithms.luhnCheck(tin.slice(0, 12))) {
return false;
} // Remove Luhn check digit and run Verhoeff check
- return algorithms$1.verhoeffCheck("".concat(tin.slice(0, 11)).concat(tin[12]));
+ return algorithms.verhoeffCheck("".concat(tin.slice(0, 11)).concat(tin[12]));
}
/*
* hr-HR validation function
@@ -11066,7 +11815,7 @@
function hrHrCheck(tin) {
- return algorithms$1.iso7064Check(tin);
+ return algorithms.iso7064Check(tin);
}
/*
* hu-HU validation function
@@ -11391,7 +12140,7 @@
function nlNlCheck(tin) {
- return algorithms$1.reverseMultiplyAndSum(tin.split('').slice(0, 8).map(function (a) {
+ return algorithms.reverseMultiplyAndSum(tin.split('').slice(0, 8).map(function (a) {
return parseInt(a, 10);
}), 9) % 11 === parseInt(tin[8], 10);
}
@@ -11566,7 +12315,7 @@
function ptPtCheck(tin) {
- var checksum = 11 - algorithms$1.reverseMultiplyAndSum(tin.split('').slice(0, 8).map(function (a) {
+ var checksum = 11 - algorithms.reverseMultiplyAndSum(tin.split('').slice(0, 8).map(function (a) {
return parseInt(a, 10);
}), 9) % 11;
@@ -11700,7 +12449,7 @@
function slSiCheck(tin) {
- var checksum = 11 - algorithms$1.reverseMultiplyAndSum(tin.split('').slice(0, 7).map(function (a) {
+ var checksum = 11 - algorithms.reverseMultiplyAndSum(tin.split('').slice(0, 7).map(function (a) {
return parseInt(a, 10);
}), 8) % 11;
@@ -11777,7 +12526,7 @@
return false;
}
- return algorithms$1.luhnCheck(tin.replace(/\W/, ''));
+ return algorithms.luhnCheck(tin.replace(/\W/, ''));
} // Locale lookup objects
/*
@@ -11796,6 +12545,7 @@
'dk-DK': /^\d{6}-{0,1}\d{4}$/,
'el-CY': /^[09]\d{7}[A-Z]$/,
'el-GR': /^([0-4]|[7-9])\d{8}$/,
+ 'en-CA': /^\d{9}$/,
'en-GB': /^\d{10}$|^(?!GB|NK|TN|ZZ)(?![DFIQUV])[A-Z](?![DFIQUVO])[A-Z]\d{6}[ABCD ]$/i,
'en-IE': /^\d{7}[A-W][A-IW]{0,1}$/i,
'en-US': /^\d{2}[- ]{0,1}\d{7}$/,
@@ -11824,7 +12574,8 @@
taxIdFormat['lb-LU'] = taxIdFormat['fr-LU'];
taxIdFormat['lt-LT'] = taxIdFormat['et-EE'];
- taxIdFormat['nl-BE'] = taxIdFormat['fr-BE']; // Algorithmic tax id check functions for various locales
+ taxIdFormat['nl-BE'] = taxIdFormat['fr-BE'];
+ taxIdFormat['fr-CA'] = taxIdFormat['en-CA']; // Algorithmic tax id check functions for various locales
var taxIdCheck = {
'bg-BG': bgBgCheck,
@@ -11834,6 +12585,7 @@
'dk-DK': dkDkCheck,
'el-CY': elCyCheck,
'el-GR': elGrCheck,
+ 'en-CA': isCanadianSIN,
'en-IE': enIeCheck,
'en-US': enUsCheck,
'es-ES': esEsCheck,
@@ -11859,7 +12611,8 @@
taxIdCheck['lb-LU'] = taxIdCheck['fr-LU'];
taxIdCheck['lt-LT'] = taxIdCheck['et-EE'];
- taxIdCheck['nl-BE'] = taxIdCheck['fr-BE']; // Regexes for locales where characters should be omitted before checking format
+ taxIdCheck['nl-BE'] = taxIdCheck['fr-BE'];
+ taxIdCheck['fr-CA'] = taxIdCheck['en-CA']; // Regexes for locales where characters should be omitted before checking format
var allsymbols = /[-\\\/!@#$%\^&\*\(\)\+\=\[\]]+/g;
var sanitizeRegexes = {
@@ -11906,7 +12659,36 @@
module.exports.default = exports.default;
} (isTaxID, isTaxID.exports));
- var isTaxIDValidator = /*@__PURE__*/getDefaultExportFromCjs(isTaxID.exports);
+ var isTaxIDExports = isTaxID.exports;
+ var isTaxIDValidator = /*@__PURE__*/getDefaultExportFromCjs(isTaxIDExports);
+
+ var isISO6391 = {exports: {}};
+
+ isISO6391.exports;
+
+ (function (module, exports) {
+
+ Object.defineProperty(exports, "__esModule", {
+ value: true
+ });
+ exports.default = isISO6391;
+
+ var _assertString = _interopRequireDefault(assertStringExports);
+
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+ var isISO6391Set = new Set(['aa', 'ab', 'ae', 'af', 'ak', 'am', 'an', 'ar', 'as', 'av', 'ay', 'az', 'az', 'ba', 'be', 'bg', 'bh', 'bi', 'bm', 'bn', 'bo', 'br', 'bs', 'ca', 'ce', 'ch', 'co', 'cr', 'cs', 'cu', 'cv', 'cy', 'da', 'de', 'dv', 'dz', 'ee', 'el', 'en', 'eo', 'es', 'et', 'eu', 'fa', 'ff', 'fi', 'fj', 'fo', 'fr', 'fy', 'ga', 'gd', 'gl', 'gn', 'gu', 'gv', 'ha', 'he', 'hi', 'ho', 'hr', 'ht', 'hu', 'hy', 'hz', 'ia', 'id', 'ie', 'ig', 'ii', 'ik', 'io', 'is', 'it', 'iu', 'ja', 'jv', 'ka', 'kg', 'ki', 'kj', 'kk', 'kl', 'km', 'kn', 'ko', 'kr', 'ks', 'ku', 'kv', 'kw', 'ky', 'la', 'lb', 'lg', 'li', 'ln', 'lo', 'lt', 'lu', 'lv', 'mg', 'mh', 'mi', 'mk', 'ml', 'mn', 'mr', 'ms', 'mt', 'my', 'na', 'nb', 'nd', 'ne', 'ng', 'nl', 'nn', 'no', 'nr', 'nv', 'ny', 'oc', 'oj', 'om', 'or', 'os', 'pa', 'pi', 'pl', 'ps', 'pt', 'qu', 'rm', 'rn', 'ro', 'ru', 'rw', 'sa', 'sc', 'sd', 'se', 'sg', 'si', 'sk', 'sl', 'sm', 'sn', 'so', 'sq', 'sr', 'ss', 'st', 'su', 'sv', 'sw', 'ta', 'te', 'tg', 'th', 'ti', 'tk', 'tl', 'tn', 'to', 'tr', 'ts', 'tt', 'tw', 'ty', 'ug', 'uk', 'ur', 'uz', 've', 'vi', 'vo', 'wa', 'wo', 'xh', 'yi', 'yo', 'za', 'zh', 'zu']);
+
+ function isISO6391(str) {
+ (0, _assertString.default)(str);
+ return isISO6391Set.has(str);
+ }
+
+ module.exports = exports.default;
+ module.exports.default = exports.default;
+ } (isISO6391, isISO6391.exports));
+
+ var isISO6391Exports = isISO6391.exports;
var isISO4217$1 = {};
@@ -11916,7 +12698,7 @@
var _default = isISO4217$1.default = isISO4217;
isISO4217$1.CurrencyCodes = void 0;
- var _assertString$1 = _interopRequireDefault$1(assertString.exports);
+ var _assertString$1 = _interopRequireDefault$1(assertStringExports);
function _interopRequireDefault$1(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -11933,6 +12715,8 @@
var isBase58$1 = {exports: {}};
+ isBase58$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -11940,7 +12724,7 @@
});
exports.default = isBase58;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -11961,10 +12745,13 @@
module.exports.default = exports.default;
} (isBase58$1, isBase58$1.exports));
- var isBase58Validator = /*@__PURE__*/getDefaultExportFromCjs(isBase58$1.exports);
+ var isBase58Exports = isBase58$1.exports;
+ var isBase58Validator = /*@__PURE__*/getDefaultExportFromCjs(isBase58Exports);
var ltrim = {exports: {}};
+ ltrim.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -11972,7 +12759,7 @@
});
exports.default = ltrim;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -11987,8 +12774,12 @@
module.exports.default = exports.default;
} (ltrim, ltrim.exports));
+ var ltrimExports = ltrim.exports;
+
var rtrim = {exports: {}};
+ rtrim.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -11996,7 +12787,7 @@
});
exports.default = rtrim;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -12023,8 +12814,12 @@
module.exports.default = exports.default;
} (rtrim, rtrim.exports));
+ var rtrimExports = rtrim.exports;
+
var trim = {exports: {}};
+ trim.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -12032,9 +12827,9 @@
});
exports.default = trim;
- var _rtrim = _interopRequireDefault(rtrim.exports);
+ var _rtrim = _interopRequireDefault(rtrimExports);
- var _ltrim = _interopRequireDefault(ltrim.exports);
+ var _ltrim = _interopRequireDefault(ltrimExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -12046,8 +12841,12 @@
module.exports.default = exports.default;
} (trim, trim.exports));
+ var trimExports = trim.exports;
+
var _escape = {exports: {}};
+ _escape.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -12055,7 +12854,7 @@
});
exports.default = escape;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -12068,8 +12867,12 @@
module.exports.default = exports.default;
} (_escape, _escape.exports));
+ var _escapeExports = _escape.exports;
+
var _unescape = {exports: {}};
+ _unescape.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -12077,7 +12880,7 @@
});
exports.default = unescape;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -12092,10 +12895,14 @@
module.exports.default = exports.default;
} (_unescape, _unescape.exports));
+ var _unescapeExports = _unescape.exports;
+
var stripLow = {exports: {}};
var blacklist = {exports: {}};
+ blacklist.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -12103,7 +12910,7 @@
});
exports.default = blacklist;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -12116,6 +12923,10 @@
module.exports.default = exports.default;
} (blacklist, blacklist.exports));
+ var blacklistExports = blacklist.exports;
+
+ stripLow.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -12123,9 +12934,9 @@
});
exports.default = stripLow;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
- var _blacklist = _interopRequireDefault(blacklist.exports);
+ var _blacklist = _interopRequireDefault(blacklistExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -12139,8 +12950,12 @@
module.exports.default = exports.default;
} (stripLow, stripLow.exports));
+ var stripLowExports = stripLow.exports;
+
var whitelist = {exports: {}};
+ whitelist.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -12148,7 +12963,7 @@
});
exports.default = whitelist;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -12161,8 +12976,12 @@
module.exports.default = exports.default;
} (whitelist, whitelist.exports));
+ var whitelistExports = whitelist.exports;
+
var isWhitelisted = {exports: {}};
+ isWhitelisted.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -12170,7 +12989,7 @@
});
exports.default = isWhitelisted;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -12190,8 +13009,12 @@
module.exports.default = exports.default;
} (isWhitelisted, isWhitelisted.exports));
+ var isWhitelistedExports = isWhitelisted.exports;
+
var normalizeEmail = {exports: {}};
+ normalizeEmail.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -12199,7 +13022,7 @@
});
exports.default = normalizeEmail;
- var _merge = _interopRequireDefault(merge.exports);
+ var _merge = _interopRequireDefault(mergeExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -12345,8 +13168,12 @@
module.exports.default = exports.default;
} (normalizeEmail, normalizeEmail.exports));
+ var normalizeEmailExports = normalizeEmail.exports;
+
var isSlug = {exports: {}};
+ isSlug.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -12354,7 +13181,7 @@
});
exports.default = isSlug;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -12369,8 +13196,12 @@
module.exports.default = exports.default;
} (isSlug, isSlug.exports));
+ var isSlugExports = isSlug.exports;
+
var isLicensePlate = {exports: {}};
+ isLicensePlate.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -12378,31 +13209,43 @@
});
exports.default = isLicensePlate;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var validators = {
'cs-CZ': function csCZ(str) {
- return /^(([ABCDEFHKIJKLMNPRSTUVXYZ]|[0-9])-?){5,8}$/.test(str);
+ return /^(([ABCDEFHIJKLMNPRSTUVXYZ]|[0-9])-?){5,8}$/.test(str);
},
'de-DE': function deDE(str) {
- return /^((AW|UL|AK|GA|AÖ|LF|AZ|AM|AS|ZE|AN|AB|A|KG|KH|BA|EW|BZ|HY|KM|BT|HP|B|BC|BI|BO|FN|TT|ÜB|BN|AH|BS|FR|HB|ZZ|BB|BK|BÖ|OC|OK|CW|CE|C|CO|LH|CB|KW|LC|LN|DA|DI|DE|DH|SY|NÖ|DO|DD|DU|DN|D|EI|EA|EE|FI|EM|EL|EN|PF|ED|EF|ER|AU|ZP|E|ES|NT|EU|FL|FO|FT|FF|F|FS|FD|FÜ|GE|G|GI|GF|GS|ZR|GG|GP|GR|NY|ZI|GÖ|GZ|GT|HA|HH|HM|HU|WL|HZ|WR|RN|HK|HD|HN|HS|GK|HE|HF|RZ|HI|HG|HO|HX|IK|IL|IN|J|JL|KL|KA|KS|KF|KE|KI|KT|KO|KN|KR|KC|KU|K|LD|LL|LA|L|OP|LM|LI|LB|LU|LÖ|HL|LG|MD|GN|MZ|MA|ML|MR|MY|AT|DM|MC|NZ|RM|RG|MM|ME|MB|MI|FG|DL|HC|MW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R|OSL|OVI|OVL|OVP|PAF|PAN|PAR|PCH|PEG|PIR|PLÖ|PRÜ|QFT|QLB|RDG|REG|REH|REI|RID|RIE|ROD|ROF|ROK|ROL|ROS|ROT|ROW|RSL|RÜD|RÜG|SAB|SAD|SAN|SAW|SBG|SBK|SCZ|SDH|SDL|SDT|SEB|SEE|SEF|SEL|SFB|SFT|SGH|SHA|SHG|SHK|SHL|SIG|SIM|SLE|SLF|SLK|SLN|SLS|SLÜ|SLZ|SMÜ|SOB|SOG|SOK|SÖM|SON|SPB|SPN|SRB|SRO|STA|STB|STD|STE|STL|SUL|SÜW|SWA|SZB|TBB|TDO|TET|TIR|TÖL|TUT|UEM|UER|UFF|USI|VAI|VEC|VER|VIB|VIE|VIT|VOH|WAF|WAK|WAN|WAR|WAT|WBS|WDA|WEL|WEN|WER|WES|WHV|WIL|WIS|WIT|WIZ|WLG|WMS|WND|WOB|WOH|WOL|WOR|WOS|WRN|WSF|WST|WSW|WTL|WTM|WUG|WÜM|WUN|WUR|WZL|ZEL|ZIG)[- ]?(([A-Z][- ]?\d{1,4})|([A-Z]{2}[- ]?\d{1,3})))[- ]?(E|H)?$/.test(str);
},
'de-LI': function deLI(str) {
return /^FL[- ]?\d{1,5}[UZ]?$/.test(str);
},
+ 'en-IN': function enIN(str) {
+ return /^[A-Z]{2}[ -]?[0-9]{1,2}(?:[ -]?[A-Z])(?:[ -]?[A-Z]*)?[ -]?[0-9]{4}$/.test(str);
+ },
+ 'es-AR': function esAR(str) {
+ return /^(([A-Z]{2} ?[0-9]{3} ?[A-Z]{2})|([A-Z]{3} ?[0-9]{3}))$/.test(str);
+ },
'fi-FI': function fiFI(str) {
return /^(?=.{4,7})(([A-Z]{1,3}|[0-9]{1,3})[\s-]?([A-Z]{1,3}|[0-9]{1,5}))$/.test(str);
},
+ 'hu-HU': function huHU(str) {
+ return /^((((?!AAA)(([A-NPRSTVZWXY]{1})([A-PR-Z]{1})([A-HJ-NPR-Z]))|(A[ABC]I)|A[ABC]O|A[A-W]Q|BPI|BPO|UCO|UDO|XAO)-(?!000)\d{3})|(M\d{6})|((CK|DT|CD|HC|H[ABEFIKLMNPRSTVX]|MA|OT|R[A-Z]) \d{2}-\d{2})|(CD \d{3}-\d{3})|(C-(C|X) \d{4})|(X-(A|B|C) \d{4})|(([EPVZ]-\d{5}))|(S A[A-Z]{2} \d{2})|(SP \d{2}-\d{2}))$/.test(str);
+ },
+ 'pt-BR': function ptBR(str) {
+ return /^[A-Z]{3}[ -]?[0-9][A-Z][0-9]{2}|[A-Z]{3}[ -]?[0-9]{4}$/.test(str);
+ },
'pt-PT': function ptPT(str) {
return /^([A-Z]{2}|[0-9]{2})[ -·]?([A-Z]{2}|[0-9]{2})[ -·]?([A-Z]{2}|[0-9]{2})$/.test(str);
},
'sq-AL': function sqAL(str) {
return /^[A-Z]{2}[- ]?((\d{3}[- ]?(([A-Z]{2})|T))|(R[- ]?\d{3}))$/.test(str);
},
- 'pt-BR': function ptBR(str) {
- return /^[A-Z]{3}[ -]?[0-9][A-Z][0-9]{2}|[A-Z]{3}[ -]?[0-9]{4}$/.test(str);
+ 'sv-SE': function svSE(str) {
+ return /^[A-HJ-PR-UW-Z]{3} ?[\d]{2}[A-HJ-PR-UW-Z1-9]$|(^[A-ZÅÄÖ ]{2,7}$)/.test(str.trim());
}
};
@@ -12431,8 +13274,12 @@
module.exports.default = exports.default;
} (isLicensePlate, isLicensePlate.exports));
+ var isLicensePlateExports = isLicensePlate.exports;
+
var isStrongPassword$1 = {exports: {}};
+ isStrongPassword$1.exports;
+
(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
@@ -12440,16 +13287,16 @@
});
exports.default = isStrongPassword;
- var _merge = _interopRequireDefault(merge.exports);
+ var _merge = _interopRequireDefault(mergeExports);
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var upperCaseRegex = /^[A-Z]$/;
var lowerCaseRegex = /^[a-z]$/;
var numberRegex = /^[0-9]$/;
- var symbolRegex = /^[-#!$@%^&*()_+|~=`{}\[\]:";'<>?,.\/ ]$/;
+ var symbolRegex = /^[-#!$@£%^&*()_+|~=`{}\[\]:";'<>?,.\/ ]$/;
var defaultOptions = {
minLength: 8,
minLowercase: 1,
@@ -12550,22 +13397,261 @@
module.exports.default = exports.default;
} (isStrongPassword$1, isStrongPassword$1.exports));
+ var isStrongPasswordExports = isStrongPassword$1.exports;
+
var isVAT$1 = {};
+ 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); }
+
Object.defineProperty(isVAT$1, "__esModule", {
value: true
});
isVAT$1.default = isVAT;
isVAT$1.vatMatchers = void 0;
- var _assertString = _interopRequireDefault(assertString.exports);
+ var _assertString = _interopRequireDefault(assertStringExports);
+
+ var algorithms = _interopRequireWildcard(algorithms$1);
+
+ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
+
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+ var PT = function PT(str) {
+ var match = str.match(/^(PT)?(\d{9})$/);
+
+ if (!match) {
+ return false;
+ }
+
+ var tin = match[2];
+ var checksum = 11 - algorithms.reverseMultiplyAndSum(tin.split('').slice(0, 8).map(function (a) {
+ return parseInt(a, 10);
+ }), 9) % 11;
+
+ if (checksum > 9) {
+ return parseInt(tin[8], 10) === 0;
+ }
+
+ return checksum === parseInt(tin[8], 10);
+ };
+
var vatMatchers = {
- GB: /^GB((\d{3} \d{4} ([0-8][0-9]|9[0-6]))|(\d{9} \d{3})|(((GD[0-4])|(HA[5-9]))[0-9]{2}))$/,
- IT: /^(IT)?[0-9]{11}$/,
- NL: /^(NL)?[0-9]{9}B[0-9]{2}$/
+ /**
+ * European Union VAT identification numbers
+ */
+ AT: function AT(str) {
+ return /^(AT)?U\d{8}$/.test(str);
+ },
+ BE: function BE(str) {
+ return /^(BE)?\d{10}$/.test(str);
+ },
+ BG: function BG(str) {
+ return /^(BG)?\d{9,10}$/.test(str);
+ },
+ HR: function HR(str) {
+ return /^(HR)?\d{11}$/.test(str);
+ },
+ CY: function CY(str) {
+ return /^(CY)?\w{9}$/.test(str);
+ },
+ CZ: function CZ(str) {
+ return /^(CZ)?\d{8,10}$/.test(str);
+ },
+ DK: function DK(str) {
+ return /^(DK)?\d{8}$/.test(str);
+ },
+ EE: function EE(str) {
+ return /^(EE)?\d{9}$/.test(str);
+ },
+ FI: function FI(str) {
+ return /^(FI)?\d{8}$/.test(str);
+ },
+ FR: function FR(str) {
+ return /^(FR)?\w{2}\d{9}$/.test(str);
+ },
+ DE: function DE(str) {
+ return /^(DE)?\d{9}$/.test(str);
+ },
+ EL: function EL(str) {
+ return /^(EL)?\d{9}$/.test(str);
+ },
+ HU: function HU(str) {
+ return /^(HU)?\d{8}$/.test(str);
+ },
+ IE: function IE(str) {
+ return /^(IE)?\d{7}\w{1}(W)?$/.test(str);
+ },
+ IT: function IT(str) {
+ return /^(IT)?\d{11}$/.test(str);
+ },
+ LV: function LV(str) {
+ return /^(LV)?\d{11}$/.test(str);
+ },
+ LT: function LT(str) {
+ return /^(LT)?\d{9,12}$/.test(str);
+ },
+ LU: function LU(str) {
+ return /^(LU)?\d{8}$/.test(str);
+ },
+ MT: function MT(str) {
+ return /^(MT)?\d{8}$/.test(str);
+ },
+ NL: function NL(str) {
+ return /^(NL)?\d{9}B\d{2}$/.test(str);
+ },
+ PL: function PL(str) {
+ return /^(PL)?(\d{10}|(\d{3}-\d{3}-\d{2}-\d{2})|(\d{3}-\d{2}-\d{2}-\d{3}))$/.test(str);
+ },
+ PT: PT,
+ RO: function RO(str) {
+ return /^(RO)?\d{2,10}$/.test(str);
+ },
+ SK: function SK(str) {
+ return /^(SK)?\d{10}$/.test(str);
+ },
+ SI: function SI(str) {
+ return /^(SI)?\d{8}$/.test(str);
+ },
+ ES: function ES(str) {
+ return /^(ES)?\w\d{7}[A-Z]$/.test(str);
+ },
+ SE: function SE(str) {
+ return /^(SE)?\d{12}$/.test(str);
+ },
+
+ /**
+ * VAT numbers of non-EU countries
+ */
+ AL: function AL(str) {
+ return /^(AL)?\w{9}[A-Z]$/.test(str);
+ },
+ MK: function MK(str) {
+ return /^(MK)?\d{13}$/.test(str);
+ },
+ AU: function AU(str) {
+ return /^(AU)?\d{11}$/.test(str);
+ },
+ BY: function BY(str) {
+ return /^(УНП )?\d{9}$/.test(str);
+ },
+ CA: function CA(str) {
+ return /^(CA)?\d{9}$/.test(str);
+ },
+ IS: function IS(str) {
+ return /^(IS)?\d{5,6}$/.test(str);
+ },
+ IN: function IN(str) {
+ return /^(IN)?\d{15}$/.test(str);
+ },
+ ID: function ID(str) {
+ return /^(ID)?(\d{15}|(\d{2}.\d{3}.\d{3}.\d{1}-\d{3}.\d{3}))$/.test(str);
+ },
+ IL: function IL(str) {
+ return /^(IL)?\d{9}$/.test(str);
+ },
+ KZ: function KZ(str) {
+ return /^(KZ)?\d{9}$/.test(str);
+ },
+ NZ: function NZ(str) {
+ return /^(NZ)?\d{9}$/.test(str);
+ },
+ NG: function NG(str) {
+ return /^(NG)?(\d{12}|(\d{8}-\d{4}))$/.test(str);
+ },
+ NO: function NO(str) {
+ return /^(NO)?\d{9}MVA$/.test(str);
+ },
+ PH: function PH(str) {
+ return /^(PH)?(\d{12}|\d{3} \d{3} \d{3} \d{3})$/.test(str);
+ },
+ RU: function RU(str) {
+ return /^(RU)?(\d{10}|\d{12})$/.test(str);
+ },
+ SM: function SM(str) {
+ return /^(SM)?\d{5}$/.test(str);
+ },
+ SA: function SA(str) {
+ return /^(SA)?\d{15}$/.test(str);
+ },
+ RS: function RS(str) {
+ return /^(RS)?\d{9}$/.test(str);
+ },
+ CH: function CH(str) {
+ return /^(CH)?(\d{6}|\d{9}|(\d{3}.\d{3})|(\d{3}.\d{3}.\d{3}))(TVA|MWST|IVA)$/.test(str);
+ },
+ TR: function TR(str) {
+ return /^(TR)?\d{10}$/.test(str);
+ },
+ UA: function UA(str) {
+ return /^(UA)?\d{12}$/.test(str);
+ },
+ GB: function GB(str) {
+ return /^GB((\d{3} \d{4} ([0-8][0-9]|9[0-6]))|(\d{9} \d{3})|(((GD[0-4])|(HA[5-9]))[0-9]{2}))$/.test(str);
+ },
+ UZ: function UZ(str) {
+ return /^(UZ)?\d{9}$/.test(str);
+ },
+
+ /**
+ * VAT numbers of Latin American countries
+ */
+ AR: function AR(str) {
+ return /^(AR)?\d{11}$/.test(str);
+ },
+ BO: function BO(str) {
+ return /^(BO)?\d{7}$/.test(str);
+ },
+ BR: function BR(str) {
+ return /^(BR)?((\d{2}.\d{3}.\d{3}\/\d{4}-\d{2})|(\d{3}.\d{3}.\d{3}-\d{2}))$/.test(str);
+ },
+ CL: function CL(str) {
+ return /^(CL)?\d{8}-\d{1}$/.test(str);
+ },
+ CO: function CO(str) {
+ return /^(CO)?\d{10}$/.test(str);
+ },
+ CR: function CR(str) {
+ return /^(CR)?\d{9,12}$/.test(str);
+ },
+ EC: function EC(str) {
+ return /^(EC)?\d{13}$/.test(str);
+ },
+ SV: function SV(str) {
+ return /^(SV)?\d{4}-\d{6}-\d{3}-\d{1}$/.test(str);
+ },
+ GT: function GT(str) {
+ return /^(GT)?\d{7}-\d{1}$/.test(str);
+ },
+ HN: function HN(str) {
+ return /^(HN)?$/.test(str);
+ },
+ MX: function MX(str) {
+ return /^(MX)?\w{3,4}\d{6}\w{3}$/.test(str);
+ },
+ NI: function NI(str) {
+ return /^(NI)?\d{3}-\d{6}-\d{4}\w{1}$/.test(str);
+ },
+ PA: function PA(str) {
+ return /^(PA)?$/.test(str);
+ },
+ PY: function PY(str) {
+ return /^(PY)?\d{6,8}-\d{1}$/.test(str);
+ },
+ PE: function PE(str) {
+ return /^(PE)?\d{11}$/.test(str);
+ },
+ DO: function DO(str) {
+ return /^(DO)?(\d{11}|(\d{3}-\d{7}-\d{1})|[1,4,5]{1}\d{8}|([1,4,5]{1})-\d{2}-\d{5}-\d{1})$/.test(str);
+ },
+ UY: function UY(str) {
+ return /^(UY)?\d{12}$/.test(str);
+ },
+ VE: function VE(str) {
+ return /^(VE)?[J,G,V,E]{1}-(\d{9}|(\d{8}-\d{1}))$/.test(str);
+ }
};
isVAT$1.vatMatchers = vatMatchers;
@@ -12574,12 +13660,14 @@
(0, _assertString.default)(countryCode);
if (countryCode in vatMatchers) {
- return vatMatchers[countryCode].test(str);
+ return vatMatchers[countryCode](str);
}
throw new Error("Invalid country code: '".concat(countryCode, "'"));
}
+ validator$1.exports;
+
(function (module, exports) {
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); }
@@ -12589,189 +13677,195 @@
});
exports.default = void 0;
- var _toDate = _interopRequireDefault(toDate.exports);
+ var _toDate = _interopRequireDefault(toDateExports);
+
+ var _toFloat = _interopRequireDefault(toFloatExports);
- var _toFloat = _interopRequireDefault(toFloat.exports);
+ var _toInt = _interopRequireDefault(toIntExports);
- var _toInt = _interopRequireDefault(toInt.exports);
+ var _toBoolean = _interopRequireDefault(toBooleanExports);
- var _toBoolean = _interopRequireDefault(toBoolean.exports);
+ var _equals = _interopRequireDefault(equalsExports);
- var _equals = _interopRequireDefault(equals.exports);
+ var _contains = _interopRequireDefault(containsExports);
- var _contains = _interopRequireDefault(contains$1.exports);
+ var _matches = _interopRequireDefault(matchesExports);
- var _matches = _interopRequireDefault(matches$1.exports);
+ var _isEmail = _interopRequireDefault(isEmailExports);
- var _isEmail = _interopRequireDefault(isEmail$1.exports);
+ var _isURL = _interopRequireDefault(isURLExports);
- var _isURL = _interopRequireDefault(isURL$1.exports);
+ var _isMACAddress = _interopRequireDefault(isMACAddressExports);
- var _isMACAddress = _interopRequireDefault(isMACAddress$1.exports);
+ var _isIP = _interopRequireDefault(isIPExports);
- var _isIP = _interopRequireDefault(isIP$1.exports);
+ var _isIPRange = _interopRequireDefault(isIPRangeExports);
- var _isIPRange = _interopRequireDefault(isIPRange.exports);
+ var _isFQDN = _interopRequireDefault(isFQDNExports);
- var _isFQDN = _interopRequireDefault(isFQDN$1.exports);
+ var _isDate = _interopRequireDefault(isDateExports);
- var _isDate = _interopRequireDefault(isDate$1.exports);
+ var _isTime = _interopRequireDefault(isTimeExports);
- var _isBoolean = _interopRequireDefault(isBoolean$1.exports);
+ var _isBoolean = _interopRequireDefault(isBooleanExports);
- var _isLocale = _interopRequireDefault(isLocale$1.exports);
+ var _isLocale = _interopRequireDefault(isLocaleExports);
var _isAlpha = _interopRequireWildcard(isAlpha$2);
var _isAlphanumeric = _interopRequireWildcard(isAlphanumeric$2);
- var _isNumeric = _interopRequireDefault(isNumeric.exports);
+ var _isNumeric = _interopRequireDefault(isNumericExports);
- var _isPassportNumber = _interopRequireDefault(isPassportNumber$1.exports);
+ var _isPassportNumber = _interopRequireDefault(isPassportNumberExports);
- var _isPort = _interopRequireDefault(isPort$1.exports);
+ var _isPort = _interopRequireDefault(isPortExports);
- var _isLowercase = _interopRequireDefault(isLowercase$1.exports);
+ var _isLowercase = _interopRequireDefault(isLowercaseExports);
- var _isUppercase = _interopRequireDefault(isUppercase$1.exports);
+ var _isUppercase = _interopRequireDefault(isUppercaseExports);
- var _isIMEI = _interopRequireDefault(isIMEI.exports);
+ var _isIMEI = _interopRequireDefault(isIMEIExports);
- var _isAscii = _interopRequireDefault(isAscii$1.exports);
+ var _isAscii = _interopRequireDefault(isAsciiExports);
var _isFullWidth = _interopRequireDefault(isFullWidth$2);
var _isHalfWidth = _interopRequireDefault(isHalfWidth$2);
- var _isVariableWidth = _interopRequireDefault(isVariableWidth$1.exports);
+ var _isVariableWidth = _interopRequireDefault(isVariableWidthExports);
- var _isMultibyte = _interopRequireDefault(isMultibyte$1.exports);
+ var _isMultibyte = _interopRequireDefault(isMultibyteExports);
- var _isSemVer = _interopRequireDefault(isSemVer$1.exports);
+ var _isSemVer = _interopRequireDefault(isSemVerExports);
- var _isSurrogatePair = _interopRequireDefault(isSurrogatePair$1.exports);
+ var _isSurrogatePair = _interopRequireDefault(isSurrogatePairExports);
- var _isInt = _interopRequireDefault(isInt$1.exports);
+ var _isInt = _interopRequireDefault(isIntExports);
var _isFloat = _interopRequireWildcard(isFloat$1);
- var _isDecimal = _interopRequireDefault(isDecimal$1.exports);
+ var _isDecimal = _interopRequireDefault(isDecimalExports);
- var _isHexadecimal = _interopRequireDefault(isHexadecimal$1.exports);
+ var _isHexadecimal = _interopRequireDefault(isHexadecimalExports);
- var _isOctal = _interopRequireDefault(isOctal$1.exports);
+ var _isOctal = _interopRequireDefault(isOctalExports);
- var _isDivisibleBy = _interopRequireDefault(isDivisibleBy$1.exports);
+ var _isDivisibleBy = _interopRequireDefault(isDivisibleByExports);
- var _isHexColor = _interopRequireDefault(isHexColor$1.exports);
+ var _isHexColor = _interopRequireDefault(isHexColorExports);
- var _isRgbColor = _interopRequireDefault(isRgbColor$1.exports);
+ var _isRgbColor = _interopRequireDefault(isRgbColorExports);
- var _isHSL = _interopRequireDefault(isHSL$1.exports);
+ var _isHSL = _interopRequireDefault(isHSLExports);
- var _isISRC = _interopRequireDefault(isISRC$1.exports);
+ var _isISRC = _interopRequireDefault(isISRCExports);
var _isIBAN = _interopRequireWildcard(isIBAN$2);
- var _isBIC = _interopRequireDefault(isBIC$1.exports);
+ var _isBIC = _interopRequireDefault(isBICExports);
- var _isMD = _interopRequireDefault(isMD5.exports);
+ var _isMD = _interopRequireDefault(isMD5Exports);
- var _isHash = _interopRequireDefault(isHash$1.exports);
+ var _isHash = _interopRequireDefault(isHashExports);
- var _isJWT = _interopRequireDefault(isJWT$1.exports);
+ var _isJWT = _interopRequireDefault(isJWTExports);
- var _isJSON = _interopRequireDefault(isJSON$1.exports);
+ var _isJSON = _interopRequireDefault(isJSONExports);
- var _isEmpty = _interopRequireDefault(isEmpty.exports);
+ var _isEmpty = _interopRequireDefault(isEmptyExports);
- var _isLength = _interopRequireDefault(isLength.exports);
+ var _isLength = _interopRequireDefault(isLengthExports);
- var _isByteLength = _interopRequireDefault(isByteLength$1.exports);
+ var _isByteLength = _interopRequireDefault(isByteLengthExports);
- var _isUUID = _interopRequireDefault(isUUID$1.exports);
+ var _isUUID = _interopRequireDefault(isUUIDExports);
- var _isMongoId = _interopRequireDefault(isMongoId$1.exports);
+ var _isMongoId = _interopRequireDefault(isMongoIdExports);
- var _isAfter = _interopRequireDefault(isAfter.exports);
+ var _isAfter = _interopRequireDefault(isAfterExports);
- var _isBefore = _interopRequireDefault(isBefore.exports);
+ var _isBefore = _interopRequireDefault(isBeforeExports);
- var _isIn = _interopRequireDefault(isIn.exports);
+ var _isIn = _interopRequireDefault(isInExports);
- var _isCreditCard = _interopRequireDefault(isCreditCard$1.exports);
+ var _isLuhnNumber = _interopRequireDefault(isLuhnNumberExports);
- var _isIdentityCard = _interopRequireDefault(isIdentityCard$1.exports);
+ var _isCreditCard = _interopRequireDefault(isCreditCardExports);
- var _isEAN = _interopRequireDefault(isEAN$1.exports);
+ var _isIdentityCard = _interopRequireDefault(isIdentityCardExports);
- var _isISIN = _interopRequireDefault(isISIN$1.exports);
+ var _isEAN = _interopRequireDefault(isEANExports);
- var _isISBN = _interopRequireDefault(isISBN$1.exports);
+ var _isISIN = _interopRequireDefault(isISINExports);
- var _isISSN = _interopRequireDefault(isISSN$1.exports);
+ var _isISBN = _interopRequireDefault(isISBNExports);
- var _isTaxID = _interopRequireDefault(isTaxID.exports);
+ var _isISSN = _interopRequireDefault(isISSNExports);
+
+ var _isTaxID = _interopRequireDefault(isTaxIDExports);
var _isMobilePhone = _interopRequireWildcard(isMobilePhone$2);
- var _isEthereumAddress = _interopRequireDefault(isEthereumAddress$1.exports);
+ var _isEthereumAddress = _interopRequireDefault(isEthereumAddressExports);
+
+ var _isCurrency = _interopRequireDefault(isCurrencyExports);
- var _isCurrency = _interopRequireDefault(isCurrency$1.exports);
+ var _isBtcAddress = _interopRequireDefault(isBtcAddressExports);
- var _isBtcAddress = _interopRequireDefault(isBtcAddress$1.exports);
+ var _isISO = _interopRequireDefault(isISO6391Exports);
- var _isISO = _interopRequireDefault(isISO8601$1.exports);
+ var _isISO2 = _interopRequireDefault(isISO8601Exports);
- var _isRFC = _interopRequireDefault(isRFC3339$1.exports);
+ var _isRFC = _interopRequireDefault(isRFC3339Exports);
var _isISO31661Alpha = _interopRequireDefault(isISO31661Alpha2$2);
- var _isISO31661Alpha2 = _interopRequireDefault(isISO31661Alpha3$1.exports);
+ var _isISO31661Alpha2 = _interopRequireDefault(isISO31661Alpha3Exports);
- var _isISO2 = _interopRequireDefault(isISO4217$1);
+ var _isISO3 = _interopRequireDefault(isISO4217$1);
- var _isBase = _interopRequireDefault(isBase32$1.exports);
+ var _isBase = _interopRequireDefault(isBase32Exports);
- var _isBase2 = _interopRequireDefault(isBase58$1.exports);
+ var _isBase2 = _interopRequireDefault(isBase58Exports);
- var _isBase3 = _interopRequireDefault(isBase64$1.exports);
+ var _isBase3 = _interopRequireDefault(isBase64Exports);
- var _isDataURI = _interopRequireDefault(isDataURI$1.exports);
+ var _isDataURI = _interopRequireDefault(isDataURIExports);
- var _isMagnetURI = _interopRequireDefault(isMagnetURI$1.exports);
+ var _isMagnetURI = _interopRequireDefault(isMagnetURIExports);
- var _isMimeType = _interopRequireDefault(isMimeType$1.exports);
+ var _isMimeType = _interopRequireDefault(isMimeTypeExports);
- var _isLatLong = _interopRequireDefault(isLatLong$1.exports);
+ var _isLatLong = _interopRequireDefault(isLatLongExports);
var _isPostalCode = _interopRequireWildcard(isPostalCode$2);
- var _ltrim = _interopRequireDefault(ltrim.exports);
+ var _ltrim = _interopRequireDefault(ltrimExports);
- var _rtrim = _interopRequireDefault(rtrim.exports);
+ var _rtrim = _interopRequireDefault(rtrimExports);
- var _trim = _interopRequireDefault(trim.exports);
+ var _trim = _interopRequireDefault(trimExports);
- var _escape$1 = _interopRequireDefault(_escape.exports);
+ var _escape = _interopRequireDefault(_escapeExports);
- var _unescape$1 = _interopRequireDefault(_unescape.exports);
+ var _unescape = _interopRequireDefault(_unescapeExports);
- var _stripLow = _interopRequireDefault(stripLow.exports);
+ var _stripLow = _interopRequireDefault(stripLowExports);
- var _whitelist = _interopRequireDefault(whitelist.exports);
+ var _whitelist = _interopRequireDefault(whitelistExports);
- var _blacklist = _interopRequireDefault(blacklist.exports);
+ var _blacklist = _interopRequireDefault(blacklistExports);
- var _isWhitelisted = _interopRequireDefault(isWhitelisted.exports);
+ var _isWhitelisted = _interopRequireDefault(isWhitelistedExports);
- var _normalizeEmail = _interopRequireDefault(normalizeEmail.exports);
+ var _normalizeEmail = _interopRequireDefault(normalizeEmailExports);
- var _isSlug = _interopRequireDefault(isSlug.exports);
+ var _isSlug = _interopRequireDefault(isSlugExports);
- var _isLicensePlate = _interopRequireDefault(isLicensePlate.exports);
+ var _isLicensePlate = _interopRequireDefault(isLicensePlateExports);
- var _isStrongPassword = _interopRequireDefault(isStrongPassword$1.exports);
+ var _isStrongPassword = _interopRequireDefault(isStrongPasswordExports);
var _isVAT = _interopRequireDefault(isVAT$1);
@@ -12781,7 +13875,7 @@
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- var version = '13.7.0';
+ var version = '13.9.0';
var validator = {
version: version,
toDate: _toDate.default,
@@ -12841,6 +13935,7 @@
isAfter: _isAfter.default,
isBefore: _isBefore.default,
isIn: _isIn.default,
+ isLuhnNumber: _isLuhnNumber.default,
isCreditCard: _isCreditCard.default,
isIdentityCard: _isIdentityCard.default,
isEAN: _isEAN.default,
@@ -12854,11 +13949,12 @@
isEthereumAddress: _isEthereumAddress.default,
isCurrency: _isCurrency.default,
isBtcAddress: _isBtcAddress.default,
- isISO8601: _isISO.default,
+ isISO6391: _isISO.default,
+ isISO8601: _isISO2.default,
isRFC3339: _isRFC.default,
isISO31661Alpha2: _isISO31661Alpha.default,
isISO31661Alpha3: _isISO31661Alpha2.default,
- isISO4217: _isISO2.default,
+ isISO4217: _isISO3.default,
isBase32: _isBase.default,
isBase58: _isBase2.default,
isBase64: _isBase3.default,
@@ -12869,8 +13965,8 @@
ltrim: _ltrim.default,
rtrim: _rtrim.default,
trim: _trim.default,
- escape: _escape$1.default,
- unescape: _unescape$1.default,
+ escape: _escape.default,
+ unescape: _unescape.default,
stripLow: _stripLow.default,
whitelist: _whitelist.default,
blacklist: _blacklist.default,
@@ -12881,6 +13977,7 @@
isStrongPassword: _isStrongPassword.default,
isTaxID: _isTaxID.default,
isDate: _isDate.default,
+ isTime: _isTime.default,
isLicensePlate: _isLicensePlate.default,
isVAT: _isVAT.default,
ibanLocales: _isIBAN.locales
@@ -12891,7 +13988,8 @@
module.exports.default = exports.default;
} (validator$1, validator$1.exports));
- var validator = /*@__PURE__*/getDefaultExportFromCjs(validator$1.exports);
+ var validatorExports = validator$1.exports;
+ var validator = /*@__PURE__*/getDefaultExportFromCjs(validatorExports);
var IS_STRONG_PASSWORD = 'isStrongPassword';
/**
@@ -13393,7 +14491,7 @@
if (!isObject(value)) {
return false;
}
- if ((options === null || options === void 0 ? void 0 : options.nullable) === true) {
+ if ((options === null || options === void 0 ? void 0 : options.nullable) === false) {
return !Object.values(value).every(function (propertyValue) { return propertyValue === null || propertyValue === undefined; });
}
for (var key in value) {
diff --git a/bundles/class-validator.umd.js.map b/bundles/class-validator.umd.js.map
index 7d325dd..38c7616 100644
--- a/bundles/class-validator.umd.js.map
+++ b/bundles/class-validator.umd.js.map
@@ -1 +1 @@
-{"version":3,"file":"class-validator.umd.js","sources":["../esm5/metadata/ValidationMetadata.js","../esm5/validation-schema/ValidationSchemaToMetadataTransformer.js","../esm5/utils/convert-to-array.util.js","../esm5/utils/get-global.util.js","../esm5/utils/is-promise.util.js","../esm5/metadata/MetadataStorage.js","../esm5/validation/ValidationError.js","../esm5/validation/ValidationTypes.js","../esm5/validation/ValidationUtils.js","../esm5/validation/ValidationExecutor.js","../esm5/validation/Validator.js","../esm5/container.js","../esm5/decorator/common/Allow.js","../esm5/metadata/ConstraintMetadata.js","../esm5/register-decorator.js","../esm5/decorator/common/ValidateBy.js","../esm5/decorator/common/IsDefined.js","../esm5/decorator/common/IsOptional.js","../esm5/decorator/common/Validate.js","../esm5/decorator/common/ValidateIf.js","../esm5/decorator/common/ValidateNested.js","../esm5/decorator/common/ValidatePromise.js","../../node_modules/validator/lib/util/assertString.js","../../node_modules/validator/lib/util/merge.js","../../node_modules/validator/lib/isLatLong.js","../esm5/decorator/common/IsLatLong.js","../esm5/decorator/common/IsLatitude.js","../esm5/decorator/common/IsLongitude.js","../esm5/decorator/common/Equals.js","../esm5/decorator/common/NotEquals.js","../esm5/decorator/common/IsEmpty.js","../esm5/decorator/common/IsNotEmpty.js","../esm5/decorator/common/IsIn.js","../esm5/decorator/common/IsNotIn.js","../../node_modules/validator/lib/alpha.js","../../node_modules/validator/lib/isFloat.js","../../node_modules/validator/lib/toFloat.js","../../node_modules/validator/lib/isDivisibleBy.js","../esm5/decorator/number/IsDivisibleBy.js","../esm5/decorator/number/IsPositive.js","../esm5/decorator/number/IsNegative.js","../esm5/decorator/number/Max.js","../esm5/decorator/number/Min.js","../esm5/decorator/date/MinDate.js","../esm5/decorator/date/MaxDate.js","../../node_modules/validator/lib/util/toString.js","../../node_modules/validator/lib/contains.js","../esm5/decorator/string/Contains.js","../esm5/decorator/string/NotContains.js","../../node_modules/validator/lib/isAlpha.js","../esm5/decorator/string/IsAlpha.js","../../node_modules/validator/lib/isAlphanumeric.js","../esm5/decorator/string/IsAlphanumeric.js","../../node_modules/validator/lib/util/includes.js","../../node_modules/validator/lib/isDecimal.js","../esm5/decorator/string/IsDecimal.js","../../node_modules/validator/lib/isAscii.js","../esm5/decorator/string/IsAscii.js","../../node_modules/validator/lib/isBase64.js","../esm5/decorator/string/IsBase64.js","../../node_modules/validator/lib/isByteLength.js","../esm5/decorator/string/IsByteLength.js","../../node_modules/validator/lib/isCreditCard.js","../esm5/decorator/string/IsCreditCard.js","../../node_modules/validator/lib/isCurrency.js","../esm5/decorator/string/IsCurrency.js","../../node_modules/validator/lib/isFQDN.js","../../node_modules/validator/lib/isIP.js","../../node_modules/validator/lib/isEmail.js","../esm5/decorator/string/IsEmail.js","../esm5/decorator/string/IsFQDN.js","../../node_modules/validator/lib/isFullWidth.js","../esm5/decorator/string/IsFullWidth.js","../../node_modules/validator/lib/isHalfWidth.js","../esm5/decorator/string/IsHalfWidth.js","../../node_modules/validator/lib/isVariableWidth.js","../esm5/decorator/string/IsVariableWidth.js","../../node_modules/validator/lib/isHexColor.js","../esm5/decorator/string/IsHexColor.js","../../node_modules/validator/lib/isHexadecimal.js","../esm5/decorator/string/IsHexadecimal.js","../esm5/decorator/ValidationOptions.js","../../node_modules/validator/lib/isMACAddress.js","../esm5/decorator/string/IsMacAddress.js","../esm5/decorator/string/IsIP.js","../../node_modules/validator/lib/isInt.js","../../node_modules/validator/lib/isPort.js","../esm5/decorator/string/IsPort.js","../../node_modules/validator/lib/isISBN.js","../esm5/decorator/string/IsISBN.js","../../node_modules/validator/lib/isISIN.js","../esm5/decorator/string/IsISIN.js","../../node_modules/validator/lib/isISO8601.js","../esm5/decorator/string/IsISO8601.js","../../node_modules/v
\ No newline at end of file
+{"version":3,"file":"class-validator.umd.js","sources":["../esm5/metadata/ValidationMetadata.js","../esm5/validation-schema/ValidationSchemaToMetadataTransformer.js","../esm5/utils/convert-to-array.util.js","../esm5/utils/get-global.util.js","../esm5/utils/is-promise.util.js","../esm5/metadata/MetadataStorage.js","../esm5/validation/ValidationError.js","../esm5/validation/ValidationTypes.js","../esm5/validation/ValidationUtils.js","../esm5/validation/ValidationExecutor.js","../esm5/validation/Validator.js","../esm5/container.js","../esm5/decorator/common/Allow.js","../esm5/metadata/ConstraintMetadata.js","../esm5/register-decorator.js","../esm5/decorator/common/ValidateBy.js","../esm5/decorator/common/IsDefined.js","../esm5/decorator/common/IsOptional.js","../esm5/decorator/common/Validate.js","../esm5/decorator/common/ValidateIf.js","../esm5/decorator/common/ValidateNested.js","../esm5/decorator/common/ValidatePromise.js","../../node_modules/validator/lib/util/assertString.js","../../node_modules/validator/lib/util/merge.js","../../node_modules/validator/lib/isLatLong.js","../esm5/decorator/common/IsLatLong.js","../esm5/decorator/common/IsLatitude.js","../esm5/decorator/common/IsLongitude.js","../esm5/decorator/common/Equals.js","../esm5/decorator/common/NotEquals.js","../esm5/decorator/common/IsEmpty.js","../esm5/decorator/common/IsNotEmpty.js","../esm5/decorator/common/IsIn.js","../esm5/decorator/common/IsNotIn.js","../../node_modules/validator/lib/alpha.js","../../node_modules/validator/lib/isFloat.js","../../node_modules/validator/lib/toFloat.js","../../node_modules/validator/lib/isDivisibleBy.js","../esm5/decorator/number/IsDivisibleBy.js","../esm5/decorator/number/IsPositive.js","../esm5/decorator/number/IsNegative.js","../esm5/decorator/number/Max.js","../esm5/decorator/number/Min.js","../esm5/decorator/date/MinDate.js","../esm5/decorator/date/MaxDate.js","../../node_modules/validator/lib/util/toString.js","../../node_modules/validator/lib/contains.js","../esm5/decorator/string/Contains.js","../esm5/decorator/string/NotContains.js","../../node_modules/validator/lib/isAlpha.js","../esm5/decorator/string/IsAlpha.js","../../node_modules/validator/lib/isAlphanumeric.js","../esm5/decorator/string/IsAlphanumeric.js","../../node_modules/validator/lib/util/includes.js","../../node_modules/validator/lib/isDecimal.js","../esm5/decorator/string/IsDecimal.js","../../node_modules/validator/lib/isAscii.js","../esm5/decorator/string/IsAscii.js","../../node_modules/validator/lib/isBase64.js","../esm5/decorator/string/IsBase64.js","../../node_modules/validator/lib/isByteLength.js","../esm5/decorator/string/IsByteLength.js","../../node_modules/validator/lib/isLuhnNumber.js","../../node_modules/validator/lib/isCreditCard.js","../esm5/decorator/string/IsCreditCard.js","../../node_modules/validator/lib/isCurrency.js","../esm5/decorator/string/IsCurrency.js","../../node_modules/validator/lib/isFQDN.js","../../node_modules/validator/lib/isIP.js","../../node_modules/validator/lib/isEmail.js","../esm5/decorator/string/IsEmail.js","../esm5/decorator/string/IsFQDN.js","../../node_modules/validator/lib/isFullWidth.js","../esm5/decorator/string/IsFullWidth.js","../../node_modules/validator/lib/isHalfWidth.js","../esm5/decorator/string/IsHalfWidth.js","../../node_modules/validator/lib/isVariableWidth.js","../esm5/decorator/string/IsVariableWidth.js","../../node_modules/validator/lib/isHexColor.js","../esm5/decorator/string/IsHexColor.js","../../node_modules/validator/lib/isHexadecimal.js","../esm5/decorator/string/IsHexadecimal.js","../esm5/decorator/ValidationOptions.js","../../node_modules/validator/lib/isMACAddress.js","../esm5/decorator/string/IsMacAddress.js","../esm5/decorator/string/IsIP.js","../../node_modules/validator/lib/isInt.js","../../node_modules/validator/lib/isPort.js","../esm5/decorator/string/IsPort.js","../../node_modules/validator/lib/isISBN.js","../esm5/decorator/string/IsISBN.js","../../node_modules/validator/lib/isISIN.js","../esm5/decorator/string/IsISIN.js","../../node_modules/validator/lib/isISO8601.js","../esm5/d
\ No newline at end of file
diff --git a/bundles/class-validator.umd.min.js b/bundles/class-validator.umd.min.js
index bbb19e6..d5060be 100644
--- a/bundles/class-validator.umd.min.js
+++ b/bundles/class-validator.umd.min.js
@@ -1,2 +1,2 @@
-!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ClassValidator={})}(this,(function(t){"use strict";var e=function(t){this.groups=[],this.each=!1,this.context=void 0,this.type=t.type,this.name=t.name,this.target=t.target,this.propertyName=t.propertyName,this.constraints=null==t?void 0:t.constraints,this.constraintCls=t.constraintCls,this.validationTypeOptions=t.validationTypeOptions,t.validationOptions&&(this.message=t.validationOptions.message,this.groups=t.validationOptions.groups,this.always=t.validationOptions.always,this.each=t.validationOptions.each,this.context=t.validationOptions.context)},r=function(){function t(){}return t.prototype.transform=function(t){var r=[];return Object.keys(t.properties).forEach((function(n){t.properties[n].forEach((function(a){var o={message:a.message,groups:a.groups,always:a.always,each:a.each},d={type:a.type,name:a.name,target:t.name,propertyName:n,constraints:a.constraints,validationTypeOptions:a.options,validationOptions:o};r.push(new e(d))}))})),r},t}();function n(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:void 0}function a(t){return null!==t&&"object"==typeof t&&"function"==typeof t.then}var o=function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},d=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,a,o=r.call(t),d=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)d.push(n.value)}catch(t){a={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(a)throw a.error}}return d},i=function(t,e,r){if(r||2===arguments.length)for(var n,a=0,o=e.length;a<o;a++)!n&&a in e||(n||(n=Array.prototype.slice.call(e,0,a)),n[a]=e[a]);return t.concat(n||Array.prototype.slice.call(e))},u=function(){function t(){this.validationMetadatas=new Map,this.constraintMetadatas=new Map}return Object.defineProperty(t.prototype,"hasValidationMetaData",{get:function(){return!!this.validationMetadatas.size},enumerable:!1,configurable:!0}),t.prototype.addValidationSchema=function(t){var e=this;(new r).transform(t).forEach((function(t){return e.addValidationMetadata(t)}))},t.prototype.addValidationMetadata=function(t){var e=this.validationMetadatas.get(t.target);e?e.push(t):this.validationMetadatas.set(t.target,[t])},t.prototype.addConstraintMetadata=function(t){var e=this.constraintMetadatas.get(t.target);e?e.push(t):this.constraintMetadatas.set(t.target,[t])},t.prototype.groupByPropertyName=function(t){var e={};return t.forEach((function(t){e[t.propertyName]||(e[t.propertyName]=[]),e[t.propertyName].push(t)})),e},t.prototype.getTargetValidationMetadatas=function(t,e,r,n,a){var u,s,l=function(t){return void 0!==t.always?t.always:(!t.groups||!t.groups.length)&&r},c=function(t){return!(!n||a&&a.length||!t.groups||!t.groups.length)},f=(this.validationMetadatas.get(t)||[]).filter((function(r){return(r.target===t||r.target===e)&&(!!l(r)||!c(r)&&(!(a&&a.length>0)||r.groups&&!!r.groups.find((function(t){return-1!==a.indexOf(t)}))))})),$=[];try{for(var p=o(this.validationMetadatas.entries()),v=p.next();!v.done;v=p.next()){var y=d(v.value,2),m=y[0],h=y[1];t.prototype instanceof m&&$.push.apply($,i([],d(h),!1))}}catch(t){u={error:t}}finally{try{v&&!v.done&&(s=p.return)&&s.call(p)}finally{if(u)throw u.error}}var g=$.filter((function(e){return"string"!=typeof e.target&&(e.target!==t&&((!(e.target instanceof Function)||t.prototype instanceof e.target)&&(!!l(e)||!c(e)&&(!(a&&a.length>0)||e.groups&&!!e.groups.find((function(t){return-1!==a.indexOf(t)}))))))})),b=g.filter((function(t){return!f.find((function(e){return e.propertyName===t.propertyName&&e.type===t.type}))}));return f.concat(b)},t.p
+!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ClassValidator={})}(this,(function(t){"use strict";var e=function(t){this.groups=[],this.each=!1,this.context=void 0,this.type=t.type,this.name=t.name,this.target=t.target,this.propertyName=t.propertyName,this.constraints=null==t?void 0:t.constraints,this.constraintCls=t.constraintCls,this.validationTypeOptions=t.validationTypeOptions,t.validationOptions&&(this.message=t.validationOptions.message,this.groups=t.validationOptions.groups,this.always=t.validationOptions.always,this.each=t.validationOptions.each,this.context=t.validationOptions.context)},d=function(){function t(){}return t.prototype.transform=function(t){var d=[];return Object.keys(t.properties).forEach((function(r){t.properties[r].forEach((function(n){var a={message:n.message,groups:n.groups,always:n.always,each:n.each},o={type:n.type,name:n.name,target:t.name,propertyName:r,constraints:n.constraints,validationTypeOptions:n.options,validationOptions:a};d.push(new e(o))}))})),d},t}();function r(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:void 0}function n(t){return null!==t&&"object"==typeof t&&"function"==typeof t.then}var a=function(t){var e="function"==typeof Symbol&&Symbol.iterator,d=e&&t[e],r=0;if(d)return d.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},o=function(t,e){var d="function"==typeof Symbol&&t[Symbol.iterator];if(!d)return t;var r,n,a=d.call(t),o=[];try{for(;(void 0===e||e-- >0)&&!(r=a.next()).done;)o.push(r.value)}catch(t){n={error:t}}finally{try{r&&!r.done&&(d=a.return)&&d.call(a)}finally{if(n)throw n.error}}return o},i=function(t,e,d){if(d||2===arguments.length)for(var r,n=0,a=e.length;n<a;n++)!r&&n in e||(r||(r=Array.prototype.slice.call(e,0,n)),r[n]=e[n]);return t.concat(r||Array.prototype.slice.call(e))},u=function(){function t(){this.validationMetadatas=new Map,this.constraintMetadatas=new Map}return Object.defineProperty(t.prototype,"hasValidationMetaData",{get:function(){return!!this.validationMetadatas.size},enumerable:!1,configurable:!0}),t.prototype.addValidationSchema=function(t){var e=this;(new d).transform(t).forEach((function(t){return e.addValidationMetadata(t)}))},t.prototype.addValidationMetadata=function(t){var e=this.validationMetadatas.get(t.target);e?e.push(t):this.validationMetadatas.set(t.target,[t])},t.prototype.addConstraintMetadata=function(t){var e=this.constraintMetadatas.get(t.target);e?e.push(t):this.constraintMetadatas.set(t.target,[t])},t.prototype.groupByPropertyName=function(t){var e={};return t.forEach((function(t){e[t.propertyName]||(e[t.propertyName]=[]),e[t.propertyName].push(t)})),e},t.prototype.getTargetValidationMetadatas=function(t,e,d,r,n){var u,s,l=function(t){return void 0!==t.always?t.always:(!t.groups||!t.groups.length)&&d},c=function(t){return!(!r||n&&n.length||!t.groups||!t.groups.length)},f=(this.validationMetadatas.get(t)||[]).filter((function(d){return(d.target===t||d.target===e)&&(!!l(d)||!c(d)&&(!(n&&n.length>0)||d.groups&&!!d.groups.find((function(t){return-1!==n.indexOf(t)}))))})),$=[];try{for(var p=a(this.validationMetadatas.entries()),v=p.next();!v.done;v=p.next()){var y=o(v.value,2),m=y[0],g=y[1];t.prototype instanceof m&&$.push.apply($,i([],o(g),!1))}}catch(t){u={error:t}}finally{try{v&&!v.done&&(s=p.return)&&s.call(p)}finally{if(u)throw u.error}}var h=$.filter((function(e){return"string"!=typeof e.target&&(e.target!==t&&((!(e.target instanceof Function)||t.prototype instanceof e.target)&&(!!l(e)||!c(e)&&(!(n&&n.length>0)||e.groups&&!!e.groups.find((function(t){return-1!==n.indexOf(t)}))))))})),A=h.filter((function(t){return!f.find((function(e){return e.propertyName===t.propertyName&&e.type===t.type}))}));return f.concat(A)},t.p
//# sourceMappingURL=class-validator.umd.min.js.map
diff --git a/bundles/class-validator.umd.min.js.map b/bundles/class-validator.umd.min.js.map
index 184e74b..2e397bf 100644
--- a/bundles/class-validator.umd.min.js.map
+++ b/bundles/class-validator.umd.min.js.map
@@ -1 +1 @@
-{"version":3,"file":"class-validator.umd.min.js","sources":["../esm5/metadata/ValidationMetadata.js","../esm5/validation-schema/ValidationSchemaToMetadataTransformer.js","../esm5/utils/get-global.util.js","../esm5/utils/is-promise.util.js","../esm5/metadata/MetadataStorage.js","../esm5/validation/ValidationError.js","../esm5/validation/ValidationTypes.js","../esm5/validation/ValidationUtils.js","../esm5/container.js","../esm5/validation/ValidationExecutor.js","../esm5/utils/convert-to-array.util.js","../esm5/validation/Validator.js","../esm5/metadata/ConstraintMetadata.js","../esm5/register-decorator.js","../esm5/decorator/common/ValidateBy.js","../esm5/decorator/common/IsDefined.js","../esm5/decorator/common/ValidateNested.js","../../node_modules/validator/lib/util/assertString.js","../../node_modules/validator/lib/util/merge.js","../../node_modules/validator/lib/isLatLong.js","../esm5/decorator/common/IsLatLong.js","../esm5/decorator/common/IsLatitude.js","../esm5/decorator/common/IsLongitude.js","../esm5/decorator/common/Equals.js","../esm5/decorator/common/NotEquals.js","../esm5/decorator/common/IsEmpty.js","../esm5/decorator/common/IsNotEmpty.js","../esm5/decorator/common/IsIn.js","../esm5/decorator/common/IsNotIn.js","../../node_modules/validator/lib/alpha.js","../../node_modules/validator/lib/isFloat.js","../../node_modules/validator/lib/toFloat.js","../../node_modules/validator/lib/isDivisibleBy.js","../esm5/decorator/number/IsDivisibleBy.js","../esm5/decorator/number/IsPositive.js","../esm5/decorator/number/IsNegative.js","../esm5/decorator/number/Max.js","../esm5/decorator/number/Min.js","../esm5/decorator/date/MinDate.js","../esm5/decorator/date/MaxDate.js","../../node_modules/validator/lib/util/toString.js","../../node_modules/validator/lib/contains.js","../esm5/decorator/string/Contains.js","../esm5/decorator/string/NotContains.js","../../node_modules/validator/lib/isAlpha.js","../esm5/decorator/string/IsAlpha.js","../../node_modules/validator/lib/isAlphanumeric.js","../esm5/decorator/string/IsAlphanumeric.js","../../node_modules/validator/lib/util/includes.js","../../node_modules/validator/lib/isDecimal.js","../esm5/decorator/string/IsDecimal.js","../../node_modules/validator/lib/isAscii.js","../esm5/decorator/string/IsAscii.js","../../node_modules/validator/lib/isBase64.js","../esm5/decorator/string/IsBase64.js","../../node_modules/validator/lib/isByteLength.js","../esm5/decorator/string/IsByteLength.js","../../node_modules/validator/lib/isCreditCard.js","../esm5/decorator/string/IsCreditCard.js","../../node_modules/validator/lib/isCurrency.js","../esm5/decorator/string/IsCurrency.js","../../node_modules/validator/lib/isFQDN.js","../../node_modules/validator/lib/isIP.js","../../node_modules/validator/lib/isEmail.js","../esm5/decorator/string/IsEmail.js","../esm5/decorator/string/IsFQDN.js","../../node_modules/validator/lib/isFullWidth.js","../esm5/decorator/string/IsFullWidth.js","../../node_modules/validator/lib/isHalfWidth.js","../esm5/decorator/string/IsHalfWidth.js","../../node_modules/validator/lib/isVariableWidth.js","../esm5/decorator/string/IsVariableWidth.js","../../node_modules/validator/lib/isHexColor.js","../esm5/decorator/string/IsHexColor.js","../../node_modules/validator/lib/isHexadecimal.js","../esm5/decorator/string/IsHexadecimal.js","../esm5/decorator/ValidationOptions.js","../../node_modules/validator/lib/isMACAddress.js","../esm5/decorator/string/IsMacAddress.js","../esm5/decorator/string/IsIP.js","../../node_modules/validator/lib/isInt.js","../../node_modules/validator/lib/isPort.js","../esm5/decorator/string/IsPort.js","../../node_modules/validator/lib/isISBN.js","../esm5/decorator/string/IsISBN.js","../../node_modules/validator/lib/isISIN.js","../esm5/decorator/string/IsISIN.js","../../node_modules/validator/lib/isISO8601.js","../esm5/decorator/string/IsISO8601.js","../../node_modules/validator/lib/isJSON.js","../esm5/decorator/string/IsJSON.js","../../node_modules/validator/lib/isJWT.js","../esm5/decorator/string/IsJWT.js","../../node_modules/validator/lib/isLowercase.js","../esm5
\ No newline at end of file
+{"version":3,"file":"class-validator.umd.min.js","sources":["../esm5/metadata/ValidationMetadata.js","../esm5/validation-schema/ValidationSchemaToMetadataTransformer.js","../esm5/utils/get-global.util.js","../esm5/utils/is-promise.util.js","../esm5/metadata/MetadataStorage.js","../esm5/validation/ValidationError.js","../esm5/validation/ValidationTypes.js","../esm5/validation/ValidationUtils.js","../esm5/container.js","../esm5/validation/ValidationExecutor.js","../esm5/utils/convert-to-array.util.js","../esm5/validation/Validator.js","../esm5/metadata/ConstraintMetadata.js","../esm5/register-decorator.js","../esm5/decorator/common/ValidateBy.js","../esm5/decorator/common/IsDefined.js","../esm5/decorator/common/ValidateNested.js","../../node_modules/validator/lib/util/assertString.js","../../node_modules/validator/lib/util/merge.js","../../node_modules/validator/lib/isLatLong.js","../esm5/decorator/common/IsLatLong.js","../esm5/decorator/common/IsLatitude.js","../esm5/decorator/common/IsLongitude.js","../esm5/decorator/common/Equals.js","../esm5/decorator/common/NotEquals.js","../esm5/decorator/common/IsEmpty.js","../esm5/decorator/common/IsNotEmpty.js","../esm5/decorator/common/IsIn.js","../esm5/decorator/common/IsNotIn.js","../../node_modules/validator/lib/alpha.js","../../node_modules/validator/lib/isFloat.js","../../node_modules/validator/lib/toFloat.js","../../node_modules/validator/lib/isDivisibleBy.js","../esm5/decorator/number/IsDivisibleBy.js","../esm5/decorator/number/IsPositive.js","../esm5/decorator/number/IsNegative.js","../esm5/decorator/number/Max.js","../esm5/decorator/number/Min.js","../esm5/decorator/date/MinDate.js","../esm5/decorator/date/MaxDate.js","../../node_modules/validator/lib/util/toString.js","../../node_modules/validator/lib/contains.js","../esm5/decorator/string/Contains.js","../esm5/decorator/string/NotContains.js","../../node_modules/validator/lib/isAlpha.js","../esm5/decorator/string/IsAlpha.js","../../node_modules/validator/lib/isAlphanumeric.js","../esm5/decorator/string/IsAlphanumeric.js","../../node_modules/validator/lib/util/includes.js","../../node_modules/validator/lib/isDecimal.js","../esm5/decorator/string/IsDecimal.js","../../node_modules/validator/lib/isAscii.js","../esm5/decorator/string/IsAscii.js","../../node_modules/validator/lib/isBase64.js","../esm5/decorator/string/IsBase64.js","../../node_modules/validator/lib/isByteLength.js","../esm5/decorator/string/IsByteLength.js","../../node_modules/validator/lib/isLuhnNumber.js","../../node_modules/validator/lib/isCreditCard.js","../esm5/decorator/string/IsCreditCard.js","../../node_modules/validator/lib/isCurrency.js","../esm5/decorator/string/IsCurrency.js","../../node_modules/validator/lib/isFQDN.js","../../node_modules/validator/lib/isIP.js","../../node_modules/validator/lib/isEmail.js","../esm5/decorator/string/IsEmail.js","../esm5/decorator/string/IsFQDN.js","../../node_modules/validator/lib/isFullWidth.js","../esm5/decorator/string/IsFullWidth.js","../../node_modules/validator/lib/isHalfWidth.js","../esm5/decorator/string/IsHalfWidth.js","../../node_modules/validator/lib/isVariableWidth.js","../esm5/decorator/string/IsVariableWidth.js","../../node_modules/validator/lib/isHexColor.js","../esm5/decorator/string/IsHexColor.js","../../node_modules/validator/lib/isHexadecimal.js","../esm5/decorator/string/IsHexadecimal.js","../esm5/decorator/ValidationOptions.js","../../node_modules/validator/lib/isMACAddress.js","../esm5/decorator/string/IsMacAddress.js","../esm5/decorator/string/IsIP.js","../../node_modules/validator/lib/isInt.js","../../node_modules/validator/lib/isPort.js","../esm5/decorator/string/IsPort.js","../../node_modules/validator/lib/isISBN.js","../esm5/decorator/string/IsISBN.js","../../node_modules/validator/lib/isISIN.js","../esm5/decorator/string/IsISIN.js","../../node_modules/validator/lib/isISO8601.js","../esm5/decorator/string/IsISO8601.js","../../node_modules/validator/lib/isJSON.js","../esm5/decorator/string/IsJSON.js","../../node_modules/validator/lib/isJWT.js","../esm5/decorator/string/IsJWT.js","../../
\ No newline at end of file
diff --git a/cjs/validation/ValidationArguments.js.map b/cjs/validation/ValidationArguments.js.map
index c2b0f6f..7c4e3fb 100644
--- a/cjs/validation/ValidationArguments.js.map
+++ b/cjs/validation/ValidationArguments.js.map
@@ -1 +1 @@
-{"version":3,"file":"ValidationArguments.js","sourceRoot":"","sources":["../../../src/validation/ValidationArguments.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Arguments being sent to message builders - user can create message either by simply returning a string,\n * either by returning a function that accepts MessageArguments and returns a message string built based on these arguments.\n */\nexport interface ValidationArguments {\n /**\n * Validating value.\n */\n value: any;\n\n /**\n * Constraints set by this validation type.\n */\n constraints: any[];\n\n /**\n * Name of the target that is being validated.\n */\n targetName: string;\n\n /**\n * Object that is being validated.\n */\n object: object;\n\n /**\n * Name of the object's property being validated.\n */\n property: string;\n}\n"]}
\ No newline at end of file
+{"version":3,"file":"ValidationArguments.js","sourceRoot":"","sources":["../../../src/validation/ValidationArguments.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Arguments being sent to message builders - user can create message either by simply returning a string,\n * either by returning a function that accepts MessageArguments and returns a message string built based on these arguments.\n */\nexport interface ValidationArguments {\n /**\n * Validating value.\n */\n value: any;\n\n /**\n * Constraints set by this validation type.\n */\n constraints: any[];\n\n /**\n * Name of the target that is being validated.\n */\n targetName: string;\n\n /**\n * Object that is being validated.\n */\n object: object;\n\n /**\n * Instance of the object being validated.\n */\n instance: object;\n\n /**\n * Name of the object's property being validated.\n */\n property: string;\n}\n"]}
\ No newline at end of file
diff --git a/cjs/validation/ValidationExecutor.js b/cjs/validation/ValidationExecutor.js
index a227748..e31daf6 100644
--- a/cjs/validation/ValidationExecutor.js
+++ b/cjs/validation/ValidationExecutor.js
@@ -24,6 +24,7 @@ class ValidationExecutor {
// -------------------------------------------------------------------------
// Private Properties
// -------------------------------------------------------------------------
+ this.instance = undefined;
this.metadataStorage = (0, MetadataStorage_1.getMetadataStorage)();
}
// -------------------------------------------------------------------------
@@ -42,6 +43,10 @@ class ValidationExecutor {
` - There may be multiple class-validator versions installed. You will need to flatten your dependencies to fix the issue.\n` +
` - This validation runs before any file with validation decorator was parsed by NodeJS.`);
}
+ // Keep the instance to the original object
+ if (this.instance === undefined) {
+ this.instance = object;
+ }
const groups = this.validatorOptions ? this.validatorOptions.groups : undefined;
const strictGroups = (this.validatorOptions && this.validatorOptions.strictGroups) || false;
const always = (this.validatorOptions && this.validatorOptions.always) || false;
@@ -187,6 +192,7 @@ class ValidationExecutor {
targetName: object.constructor ? object.constructor.name : undefined,
property: metadata.propertyName,
object: object,
+ instance: this.instance,
value: value,
constraints: metadata.constraints,
};
@@ -303,6 +309,7 @@ class ValidationExecutor {
property: metadata.propertyName,
object: object,
value: value,
+ instance: this.instance,
constraints: metadata.constraints,
};
let message = metadata.message || '';
diff --git a/cjs/validation/ValidationExecutor.js.map b/cjs/validation/ValidationExecutor.js.map
index ec7a70a..dd46067 100644
--- a/cjs/validation/ValidationExecutor.js.map
+++ b/cjs/validation/ValidationExecutor.js.map
@@ -1 +1 @@
-{"version":3,"file":"ValidationExecutor.js","sourceRoot":"","sources":["../../../src/validation/ValidationExecutor.ts"],"names":[],"mappings":";;;AACA,uDAAoD;AAGpD,uDAAoD;AAGpD,uDAAoD;AACpD,oCAAqD;AACrD,iEAAiE;AAEjE;;GAEG;AACH,MAAa,kBAAkB;IAc7B,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YAAoB,SAAoB,EAAU,gBAAmC;QAAjE,cAAS,GAAT,SAAS,CAAW;QAAU,qBAAgB,GAAhB,gBAAgB,CAAmB;QAjBrF,4EAA4E;QAC5E,aAAa;QACb,4EAA4E;QAE5E,qBAAgB,GAAmB,EAAE,CAAC;QACtC,2BAAsB,GAAY,KAAK,CAAC;QAExC,4EAA4E;QAC5E,qBAAqB;QACrB,4EAA4E;QAEpE,oBAAe,GAAG,IAAA,oCAAkB,GAAE,CAAC;IAMyC,CAAC;IAEzF,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E,OAAO,CAAC,MAAc,EAAE,YAAoB,EAAE,gBAAmC;;QAC/E;;;;;WAKG;QACH,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,qBAAqB,IAAI,CAAA,MAAA,IAAI,CAAC,gBAAgB,0CAAE,mBAAmB,MAAK,IAAI,EAAE;YACtG,OAAO,CAAC,IAAI,CACV,wGAAwG;gBACtG,8HAA8H;gBAC9H,0FAA0F,CAC7F,CAAC;SACH;QAED,MAAM,MAAM,GAAG,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAA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AClB,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;aACxD;YAED,IAAI,MAAM,CAAC,I
\ No newline at end of file
+{"version":3,"file":"ValidationExecutor.js","sourceRoot":"","sources":["../../../src/validation/ValidationExecutor.ts"],"names":[],"mappings":";;;AACA,uDAAoD;AAGpD,uDAAoD;AAGpD,uDAAoD;AACpD,oCAAqD;AACrD,iEAAiE;AAEjE;;GAEG;AACH,MAAa,kBAAkB;IAe7B,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YAAoB,SAAoB,EAAU,gBAAmC;QAAjE,cAAS,GAAT,SAAS,CAAW;QAAU,qBAAgB,GAAhB,gBAAgB,CAAmB;QAlBrF,4EAA4E;QAC5E,aAAa;QACb,4EAA4E;QAE5E,qBAAgB,GAAmB,EAAE,CAAC;QACtC,2BAAsB,GAAY,KAAK,CAAC;QAExC,4EAA4E;QAC5E,qBAAqB;QACrB,4EAA4E;QAEpE,aAAQ,GAAQ,SAAS,CAAC;QAC1B,oBAAe,GAAG,IAAA,oCAAkB,GAAE,CAAC;IAMyC,CAAC;IAEzF,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E,OAAO,CAAC,MAAc,EAAE,YAAoB,EAAE,gBAAmC;;QAC/E;;;;;WAKG;QACH,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,qBAAqB,IAAI,CAAA,MAAA,IAAI,CAAC,gBAAgB,0CAAE,mBAAmB,MAAK,IAAI,EAAE,CAAC;YACvG,OAAO,CAAC,IAAI,CACV,wGAAwG;gBACtG,8HAA8H;gBAC9H,0FAA0F,CAC7F,CAAC;QACJ,CAAC;QAED,2CAA2C;QAC3C,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAC,CAAC;YAC/B,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC;QACzB,CAAC;QAED,MAAM,MAAM,GAAG,IAAI,CAAC,gBAAgB,CAAC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validation/ValidationArguments.js.map b/esm2015/validation/ValidationArguments.js.map
index c2b0f6f..7c4e3fb 100644
--- a/esm2015/validation/ValidationArguments.js.map
+++ b/esm2015/validation/ValidationArguments.js.map
@@ -1 +1 @@
-{"version":3,"file":"ValidationArguments.js","sourceRoot":"","sources":["../../../src/validation/ValidationArguments.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Arguments being sent to message builders - user can create message either by simply returning a string,\n * either by returning a function that accepts MessageArguments and returns a message string built based on these arguments.\n */\nexport interface ValidationArguments {\n /**\n * Validating value.\n */\n value: any;\n\n /**\n * Constraints set by this validation type.\n */\n constraints: any[];\n\n /**\n * Name of the target that is being validated.\n */\n targetName: string;\n\n /**\n * Object that is being validated.\n */\n object: object;\n\n /**\n * Name of the object's property being validated.\n */\n property: string;\n}\n"]}
\ No newline at end of file
+{"version":3,"file":"ValidationArguments.js","sourceRoot":"","sources":["../../../src/validation/ValidationArguments.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Arguments being sent to message builders - user can create message either by simply returning a string,\n * either by returning a function that accepts MessageArguments and returns a message string built based on these arguments.\n */\nexport interface ValidationArguments {\n /**\n * Validating value.\n */\n value: any;\n\n /**\n * Constraints set by this validation type.\n */\n constraints: any[];\n\n /**\n * Name of the target that is being validated.\n */\n targetName: string;\n\n /**\n * Object that is being validated.\n */\n object: object;\n\n /**\n * Instance of the object being validated.\n */\n instance: object;\n\n /**\n * Name of the object's property being validated.\n */\n property: string;\n}\n"]}
\ No newline at end of file
diff --git a/esm2015/validation/ValidationExecutor.js b/esm2015/validation/ValidationExecutor.js
index 732f687..cf3b2df 100644
--- a/esm2015/validation/ValidationExecutor.js
+++ b/esm2015/validation/ValidationExecutor.js
@@ -21,6 +21,7 @@ export class ValidationExecutor {
// -------------------------------------------------------------------------
// Private Properties
// -------------------------------------------------------------------------
+ this.instance = undefined;
this.metadataStorage = getMetadataStorage();
}
// -------------------------------------------------------------------------
@@ -39,6 +40,10 @@ export class ValidationExecutor {
` - There may be multiple class-validator versions installed. You will need to flatten your dependencies to fix the issue.\n` +
` - This validation runs before any file with validation decorator was parsed by NodeJS.`);
}
+ // Keep the instance to the original object
+ if (this.instance === undefined) {
+ this.instance = object;
+ }
const groups = this.validatorOptions ? this.validatorOptions.groups : undefined;
const strictGroups = (this.validatorOptions && this.validatorOptions.strictGroups) || false;
const always = (this.validatorOptions && this.validatorOptions.always) || false;
@@ -184,6 +189,7 @@ export class ValidationExecutor {
targetName: object.constructor ? object.constructor.name : undefined,
property: metadata.propertyName,
object: object,
+ instance: this.instance,
value: value,
constraints: metadata.constraints,
};
@@ -300,6 +306,7 @@ export class ValidationExecutor {
property: metadata.propertyName,
object: object,
value: value,
+ instance: this.instance,
constraints: metadata.constraints,
};
let message = metadata.message || '';
diff --git a/esm2015/validation/ValidationExecutor.js.map b/esm2015/validation/ValidationExecutor.js.map
index 6acdcb2..fa61c72 100644
--- a/esm2015/validation/ValidationExecutor.js.map
+++ b/esm2015/validation/ValidationExecutor.js.map
@@ -1 +1 @@
-{"version":3,"file":"ValidationExecutor.js","sourceRoot":"","sources":["../../../src/validation/ValidationExecutor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAEjE;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAc7B,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YAAoB,SAAoB,EAAU,gBAAmC;QAAjE,cAAS,GAAT,SAAS,CAAW;QAAU,qBAAgB,GAAhB,gBAAgB,CAAmB;QAjBrF,4EAA4E;QAC5E,aAAa;QACb,4EAA4E;QAE5E,qBAAgB,GAAmB,EA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C,EAAE,QAAQ,CAAC,CAAC;oBAC1G,eAAe,CAAC,WAAW,GAAG,EAAE,CAAC,eAAe,CAAC,SAAS,CAAC,EAAE,YAAY,QAAQ,mBAAmB,EAAE,CAAC;oBACvG,eAAe,CAAC,QAAQ,GAAG,SAAS,CAAC;oBACrC,gBAAgB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;gBACzC,CAAC,CAAC,CAAC;aACJ;iBAAM;gBACL,+BAA+B;gBAC/B,oBAAoB,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;aACnE;SACF;IACH,CAAC;IAED,gBAAgB,CAAC,MAAyB;QACxC,OAAO,MAAM,CAAC,MAAM,C
\ No newline at end of file
+{"version":3,"file":"ValidationExecutor.js","sourceRoot":"","sources":["../../../src/validation/ValidationExecutor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAEjE;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAe7B,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YAAoB,SAAoB,EAAU,gBAAmC;QAAjE,cAAS,GAAT,SAAS,CAAW;QAAU,qBAAgB,GAAhB,gBAAgB,CAAmB;QAlBrF,4EAA4E;QAC5E,aAAa;QACb,4EAA4E;QAE5E,qBAAgB,GAAmB,EAAE,CAAC;QACtC,2BAAsB,GAAY,KAAK,CAAC;QAExC,4EAA4E;QAC5E,qBAAqB;QACrB,4EAA4E;QAEpE,aAAQ,GAAQ,SAAS,CAAC;QAC1B,oBAAe,GAAG,kBAAkB,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AAe,GAAoB,IAAI,CAAC,uBAAuB,CAAC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAC;oBAC1G,eAAe,CAAC,WAAW,GAAG,EAAE,CAAC,eAAe,CAAC,SAAS,CAAC,EAAE,YAAY,QAAQ,mBAAmB,EAAE,CAAC;oBACvG,eAAe,CAAC,QAAQ,GAAG,SAAS,CAAC;oBACrC,gBAAgB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;gBACzC,CAAC,CAAC,CAA
\ No newline at end of file
diff --git a/esm5/validation/ValidationArguments.js.map b/esm5/validation/ValidationArguments.js.map
index c2b0f6f..7c4e3fb 100644
--- a/esm5/validation/ValidationArguments.js.map
+++ b/esm5/validation/ValidationArguments.js.map
@@ -1 +1 @@
-{"version":3,"file":"ValidationArguments.js","sourceRoot":"","sources":["../../../src/validation/ValidationArguments.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Arguments being sent to message builders - user can create message either by simply returning a string,\n * either by returning a function that accepts MessageArguments and returns a message string built based on these arguments.\n */\nexport interface ValidationArguments {\n /**\n * Validating value.\n */\n value: any;\n\n /**\n * Constraints set by this validation type.\n */\n constraints: any[];\n\n /**\n * Name of the target that is being validated.\n */\n targetName: string;\n\n /**\n * Object that is being validated.\n */\n object: object;\n\n /**\n * Name of the object's property being validated.\n */\n property: string;\n}\n"]}
\ No newline at end of file
+{"version":3,"file":"ValidationArguments.js","sourceRoot":"","sources":["../../../src/validation/ValidationArguments.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Arguments being sent to message builders - user can create message either by simply returning a string,\n * either by returning a function that accepts MessageArguments and returns a message string built based on these arguments.\n */\nexport interface ValidationArguments {\n /**\n * Validating value.\n */\n value: any;\n\n /**\n * Constraints set by this validation type.\n */\n constraints: any[];\n\n /**\n * Name of the target that is being validated.\n */\n targetName: string;\n\n /**\n * Object that is being validated.\n */\n object: object;\n\n /**\n * Instance of the object being validated.\n */\n instance: object;\n\n /**\n * Name of the object's property being validated.\n */\n property: string;\n}\n"]}
\ No newline at end of file
diff --git a/esm5/validation/ValidationExecutor.js b/esm5/validation/ValidationExecutor.js
index 4135ba4..a18dd2f 100644
--- a/esm5/validation/ValidationExecutor.js
+++ b/esm5/validation/ValidationExecutor.js
@@ -37,6 +37,7 @@ var ValidationExecutor = /** @class */ (function () {
// -------------------------------------------------------------------------
// Private Properties
// -------------------------------------------------------------------------
+ this.instance = undefined;
this.metadataStorage = getMetadataStorage();
}
// -------------------------------------------------------------------------
@@ -56,6 +57,10 @@ var ValidationExecutor = /** @class */ (function () {
" - There may be multiple class-validator versions installed. You will need to flatten your dependencies to fix the issue.\n" +
" - This validation runs before any file with validation decorator was parsed by NodeJS.");
}
+ // Keep the instance to the original object
+ if (this.instance === undefined) {
+ this.instance = object;
+ }
var groups = this.validatorOptions ? this.validatorOptions.groups : undefined;
var strictGroups = (this.validatorOptions && this.validatorOptions.strictGroups) || false;
var always = (this.validatorOptions && this.validatorOptions.always) || false;
@@ -205,6 +210,7 @@ var ValidationExecutor = /** @class */ (function () {
targetName: object.constructor ? object.constructor.name : undefined,
property: metadata.propertyName,
object: object,
+ instance: _this.instance,
value: value,
constraints: metadata.constraints,
};
@@ -329,6 +335,7 @@ var ValidationExecutor = /** @class */ (function () {
property: metadata.propertyName,
object: object,
value: value,
+ instance: this.instance,
constraints: metadata.constraints,
};
var message = metadata.message || '';
diff --git a/esm5/validation/ValidationExecutor.js.map b/esm5/validation/ValidationExecutor.js.map
index 659b9ab..9e381fa 100644
--- a/esm5/validation/ValidationExecutor.js.map
+++ b/esm5/validation/ValidationExecutor.js.map
@@ -1 +1 @@
-{"version":3,"file":"ValidationExecutor.js","sourceRoot":"","sources":["../../../src/validation/ValidationExecutor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD,OAAO,EAA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AAI,CAAC,gBAAgB,CAAC,YAAY,CAAC,IAAI,gBAAgB,CAAC,YAAY,CAAC,CAAC,MAAM,KAAK,CAAC;gBAChF,oBAAoB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;QAEH,IAAI,oBAAoB,CAAC,MAAM,GAAG,CAAC,EAAE;YACnC,IAAI,IAAI,CAAC,gBAAgB,IAAI,IAAI,CAAC,gBAAgB,CAAC,oBAAoB,EAAE;gBACvE,eAAe;gBACf,oBAAoB,CAAC,OAAO,CAAC,UAAA,QAAQ;;oBACnC,IAAM,eAAe,GAAoB,KAAI,CAAC,uBAAuB,CAAC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAC;oBAC1G,eAAe,CAAC,WAAW,aAAK,GAAC,eAAe,CAAC,SAAS,IAAG,mBAAY,QAAQ,sBAAmB,KAAE,CAAC;oBACvG,eAAe,CAAC,QAAQ,GAAG,SAAS,CAAC;oBACrC,gBAAgB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;gBACzC,CAAC,CAAC,CAAC;aACJ;iBAAM;gBACL,+BAA+B;gBAC/B,oBAAoB,CAAC,OAAO,CAAC,UAAA,QAAQ,IAAI,OAAA,OAAO,MAAM,CAAC,QAAQ,CAAC,EAAvB,CAAuB,CAAC,CAAC;aACnE;SACF;IAC
\ No newline at end of file
+{"version":3,"file":"ValidationExecutor.js","sourceRoot":"","sources":["../../../src/validation/ValidationExecutor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC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MAAM,CAAC,CAAC,OAAO,CAAC,UAAA,YAAY;YACtC,uCAAuC;YACvC,IAAI,CAAC,gBAAgB,CAAC,YAAY,CAAC,IAAI,gBAAgB,CAAC,YAAY,CAAC,CAAC,MAAM,KAAK,CAAC;gBAChF,oBAAoB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;QAEH,IAAI,oBAAoB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACpC,IAAI,IAAI,CAAC,gBAAgB,IAAI,IAAI,CAAC,gBAAgB,CAAC,oBAAoB,EAAE,CAAC;gBACxE,eAAe;gBACf,oBAAoB,CAAC,OAAO,CAAC,UAAA,QAAQ;;oBACnC,IAAM,eAAe,GAAoB,KAAI,CAAC,uBAAuB,CAAC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAC;oBAC1G,eAAe,CAAC,WAAW,aAAK,GAAC,eAAe,CAAC,SAAS,IAAG,mBAAY,QAAQ,sBAAmB,KAAE,CAAC;oBACvG,eAAe,CAAC,QAAQ,GAAG,SAAS,CAAC;oBACrC,gBAAgB,CAAC,
\ No newline at end of file
diff --git a/types/validation/ValidationArguments.d.ts b/types/validation/ValidationArguments.d.ts
index 6cf8842..f9dff68 100644
--- a/types/validation/ValidationArguments.d.ts
+++ b/types/validation/ValidationArguments.d.ts
@@ -19,6 +19,10 @@ export interface ValidationArguments {
* Object that is being validated.
*/
object: object;
+ /**
+ * Instance of the object being validated.
+ */
+ instance: object;
/**
* Name of the object's property being validated.
*/
diff --git a/types/validation/ValidationExecutor.d.ts b/types/validation/ValidationExecutor.d.ts
index ff5cba7..08dc772 100644
--- a/types/validation/ValidationExecutor.d.ts
+++ b/types/validation/ValidationExecutor.d.ts
@@ -10,6 +10,7 @@ export declare class ValidationExecutor {
private validatorOptions?;
awaitingPromises: Promise<any>[];
ignoreAsyncValidations: boolean;
+ private instance;
private metadataStorage;
constructor(validator: Validator, validatorOptions?: ValidatorOptions);
execute(object: object, targetSchema: string, validationErrors: ValidationError[]): void;