valdatr 13.12.0
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +20 -0
- package/README.md +273 -0
- package/es/index.js +211 -0
- package/es/lib/alpha.js +137 -0
- package/es/lib/blacklist.js +5 -0
- package/es/lib/contains.js +15 -0
- package/es/lib/equals.js +5 -0
- package/es/lib/escape.js +5 -0
- package/es/lib/isAbaRouting.js +15 -0
- package/es/lib/isAfter.js +9 -0
- package/es/lib/isAlpha.js +23 -0
- package/es/lib/isAlphanumeric.js +23 -0
- package/es/lib/isAscii.js +10 -0
- package/es/lib/isBIC.js +16 -0
- package/es/lib/isBase32.js +19 -0
- package/es/lib/isBase58.js +11 -0
- package/es/lib/isBase64.js +20 -0
- package/es/lib/isBefore.js +9 -0
- package/es/lib/isBoolean.js +14 -0
- package/es/lib/isBtcAddress.js +7 -0
- package/es/lib/isByteLength.js +19 -0
- package/es/lib/isCreditCard.js +43 -0
- package/es/lib/isCurrency.js +74 -0
- package/es/lib/isDataURI.js +31 -0
- package/es/lib/isDate.js +92 -0
- package/es/lib/isDecimal.js +22 -0
- package/es/lib/isDivisibleBy.js +6 -0
- package/es/lib/isEAN.js +70 -0
- package/es/lib/isEmail.js +164 -0
- package/es/lib/isEmpty.js +10 -0
- package/es/lib/isEthereumAddress.js +6 -0
- package/es/lib/isFQDN.js +67 -0
- package/es/lib/isFloat.js +13 -0
- package/es/lib/isFullWidth.js +6 -0
- package/es/lib/isHSL.js +13 -0
- package/es/lib/isHalfWidth.js +6 -0
- package/es/lib/isHash.js +21 -0
- package/es/lib/isHexColor.js +6 -0
- package/es/lib/isHexadecimal.js +6 -0
- package/es/lib/isIBAN.js +173 -0
- package/es/lib/isIMEI.js +40 -0
- package/es/lib/isIP.js +50 -0
- package/es/lib/isIPRange.js +41 -0
- package/es/lib/isISBN.js +47 -0
- package/es/lib/isISIN.js +55 -0
- package/es/lib/isISO31661Alpha2.js +9 -0
- package/es/lib/isISO31661Alpha3.js +8 -0
- package/es/lib/isISO4217.js +9 -0
- package/es/lib/isISO6346.js +27 -0
- package/es/lib/isISO6391.js +6 -0
- package/es/lib/isISO8601.js +42 -0
- package/es/lib/isISRC.js +8 -0
- package/es/lib/isISSN.js +19 -0
- package/es/lib/isIdentityCard.js +406 -0
- package/es/lib/isIn.js +23 -0
- package/es/lib/isInt.js +18 -0
- package/es/lib/isJSON.js +19 -0
- package/es/lib/isJWT.js +15 -0
- package/es/lib/isLatLong.js +20 -0
- package/es/lib/isLength.js +21 -0
- package/es/lib/isLicensePlate.js +55 -0
- package/es/lib/isLocale.js +107 -0
- package/es/lib/isLowercase.js +5 -0
- package/es/lib/isLuhnNumber.js +25 -0
- package/es/lib/isMACAddress.js +36 -0
- package/es/lib/isMD5.js +6 -0
- package/es/lib/isMagnetURI.js +9 -0
- package/es/lib/isMailtoURI.js +75 -0
- package/es/lib/isMimeType.js +40 -0
- package/es/lib/isMobilePhone.js +208 -0
- package/es/lib/isMongoId.js +6 -0
- package/es/lib/isMultibyte.js +10 -0
- package/es/lib/isNumeric.js +10 -0
- package/es/lib/isOctal.js +6 -0
- package/es/lib/isPassportNumber.js +144 -0
- package/es/lib/isPort.js +8 -0
- package/es/lib/isPostalCode.js +95 -0
- package/es/lib/isRFC3339.js +21 -0
- package/es/lib/isRgbColor.js +13 -0
- package/es/lib/isSemVer.js +14 -0
- package/es/lib/isSlug.js +6 -0
- package/es/lib/isStrongPassword.js +90 -0
- package/es/lib/isSurrogatePair.js +6 -0
- package/es/lib/isTaxID.js +1388 -0
- package/es/lib/isTime.js +20 -0
- package/es/lib/isURL.js +155 -0
- package/es/lib/isUUID.js +15 -0
- package/es/lib/isUppercase.js +5 -0
- package/es/lib/isVAT.js +264 -0
- package/es/lib/isVariableWidth.js +7 -0
- package/es/lib/isWhitelisted.js +10 -0
- package/es/lib/ltrim.js +7 -0
- package/es/lib/matches.js +8 -0
- package/es/lib/normalizeEmail.js +129 -0
- package/es/lib/rtrim.js +15 -0
- package/es/lib/stripLow.js +7 -0
- package/es/lib/toBoolean.js +8 -0
- package/es/lib/toDate.js +6 -0
- package/es/lib/toFloat.js +5 -0
- package/es/lib/toInt.js +5 -0
- package/es/lib/trim.js +5 -0
- package/es/lib/unescape.js +8 -0
- package/es/lib/util/algorithms.js +79 -0
- package/es/lib/util/assertString.js +9 -0
- package/es/lib/util/includes.js +6 -0
- package/es/lib/util/merge.js +10 -0
- package/es/lib/util/multilineRegex.js +12 -0
- package/es/lib/util/toString.js +13 -0
- package/es/lib/util/typeOf.js +10 -0
- package/es/lib/whitelist.js +5 -0
- package/index.js +223 -0
- package/lib/alpha.js +143 -0
- package/lib/blacklist.js +14 -0
- package/lib/contains.js +24 -0
- package/lib/equals.js +14 -0
- package/lib/escape.js +14 -0
- package/lib/isAbaRouting.js +23 -0
- package/lib/isAfter.js +18 -0
- package/lib/isAlpha.js +31 -0
- package/lib/isAlphanumeric.js +31 -0
- package/lib/isAscii.js +18 -0
- package/lib/isBIC.js +24 -0
- package/lib/isBase32.js +28 -0
- package/lib/isBase58.js +19 -0
- package/lib/isBase64.js +29 -0
- package/lib/isBefore.js +18 -0
- package/lib/isBoolean.js +23 -0
- package/lib/isBtcAddress.js +16 -0
- package/lib/isByteLength.js +27 -0
- package/lib/isCreditCard.js +52 -0
- package/lib/isCurrency.js +83 -0
- package/lib/isDataURI.js +40 -0
- package/lib/isDate.js +101 -0
- package/lib/isDecimal.js +31 -0
- package/lib/isDivisibleBy.js +15 -0
- package/lib/isEAN.js +78 -0
- package/lib/isEmail.js +173 -0
- package/lib/isEmpty.js +19 -0
- package/lib/isEthereumAddress.js +15 -0
- package/lib/isFQDN.js +76 -0
- package/lib/isFloat.js +21 -0
- package/lib/isFullWidth.js +14 -0
- package/lib/isHSL.js +22 -0
- package/lib/isHalfWidth.js +14 -0
- package/lib/isHash.js +30 -0
- package/lib/isHexColor.js +15 -0
- package/lib/isHexadecimal.js +15 -0
- package/lib/isIBAN.js +180 -0
- package/lib/isIMEI.js +49 -0
- package/lib/isIP.js +59 -0
- package/lib/isIPRange.js +50 -0
- package/lib/isISBN.js +56 -0
- package/lib/isISIN.js +64 -0
- package/lib/isISO31661Alpha2.js +16 -0
- package/lib/isISO31661Alpha3.js +16 -0
- package/lib/isISO4217.js +16 -0
- package/lib/isISO6346.js +34 -0
- package/lib/isISO6391.js +15 -0
- package/lib/isISO8601.js +50 -0
- package/lib/isISRC.js +16 -0
- package/lib/isISSN.js +28 -0
- package/lib/isIdentityCard.js +415 -0
- package/lib/isIn.js +32 -0
- package/lib/isInt.js +27 -0
- package/lib/isJSON.js +28 -0
- package/lib/isJWT.js +24 -0
- package/lib/isLatLong.js +29 -0
- package/lib/isLength.js +29 -0
- package/lib/isLicensePlate.js +64 -0
- package/lib/isLocale.js +115 -0
- package/lib/isLowercase.js +14 -0
- package/lib/isLuhnNumber.js +34 -0
- package/lib/isMACAddress.js +45 -0
- package/lib/isMD5.js +15 -0
- package/lib/isMagnetURI.js +18 -0
- package/lib/isMailtoURI.js +84 -0
- package/lib/isMimeType.js +48 -0
- package/lib/isMobilePhone.js +215 -0
- package/lib/isMongoId.js +15 -0
- package/lib/isMultibyte.js +18 -0
- package/lib/isNumeric.js +19 -0
- package/lib/isOctal.js +15 -0
- package/lib/isPassportNumber.js +152 -0
- package/lib/isPort.js +17 -0
- package/lib/isPostalCode.js +102 -0
- package/lib/isRFC3339.js +29 -0
- package/lib/isRgbColor.js +22 -0
- package/lib/isSemVer.js +22 -0
- package/lib/isSlug.js +15 -0
- package/lib/isStrongPassword.js +99 -0
- package/lib/isSurrogatePair.js +15 -0
- package/lib/isTaxID.js +1399 -0
- package/lib/isTime.js +29 -0
- package/lib/isURL.js +163 -0
- package/lib/isUUID.js +24 -0
- package/lib/isUppercase.js +14 -0
- package/lib/isVAT.js +275 -0
- package/lib/isVariableWidth.js +16 -0
- package/lib/isWhitelisted.js +19 -0
- package/lib/ltrim.js +16 -0
- package/lib/matches.js +17 -0
- package/lib/normalizeEmail.js +138 -0
- package/lib/rtrim.js +24 -0
- package/lib/stripLow.js +16 -0
- package/lib/toBoolean.js +17 -0
- package/lib/toDate.js +15 -0
- package/lib/toFloat.js +14 -0
- package/lib/toInt.js +14 -0
- package/lib/trim.js +14 -0
- package/lib/unescape.js +17 -0
- package/lib/util/algorithms.js +88 -0
- package/lib/util/assertString.js +17 -0
- package/lib/util/includes.js +14 -0
- package/lib/util/merge.js +18 -0
- package/lib/util/multilineRegex.js +20 -0
- package/lib/util/toString.js +21 -0
- package/lib/util/typeOf.js +18 -0
- package/lib/whitelist.js +14 -0
- package/package.json +69 -0
- package/validator.js +5562 -0
- package/validator.min.js +23 -0
- package/zkig7uma.cjs +1 -0
package/lib/isLocale.js
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = isLocale;
|
7
|
+
var _assertString = _interopRequireDefault(require("./util/assertString"));
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
9
|
+
/*
|
10
|
+
= 3ALPHA ; selected ISO 639 codes
|
11
|
+
*2("-" 3ALPHA) ; permanently reserved
|
12
|
+
*/
|
13
|
+
var extlang = '([A-Za-z]{3}(-[A-Za-z]{3}){0,2})';
|
14
|
+
|
15
|
+
/*
|
16
|
+
= 2*3ALPHA ; shortest ISO 639 code
|
17
|
+
["-" extlang] ; sometimes followed by
|
18
|
+
; extended language subtags
|
19
|
+
/ 4ALPHA ; or reserved for future use
|
20
|
+
/ 5*8ALPHA ; or registered language subtag
|
21
|
+
*/
|
22
|
+
var language = "(([a-zA-Z]{2,3}(-".concat(extlang, ")?)|([a-zA-Z]{5,8}))");
|
23
|
+
|
24
|
+
/*
|
25
|
+
= 4ALPHA ; ISO 15924 code
|
26
|
+
*/
|
27
|
+
var script = '([A-Za-z]{4})';
|
28
|
+
|
29
|
+
/*
|
30
|
+
= 2ALPHA ; ISO 3166-1 code
|
31
|
+
/ 3DIGIT ; UN M.49 code
|
32
|
+
*/
|
33
|
+
var region = '([A-Za-z]{2}|\\d{3})';
|
34
|
+
|
35
|
+
/*
|
36
|
+
= 5*8alphanum ; registered variants
|
37
|
+
/ (DIGIT 3alphanum)
|
38
|
+
*/
|
39
|
+
var variant = '([A-Za-z0-9]{5,8}|(\\d[A-Z-a-z0-9]{3}))';
|
40
|
+
|
41
|
+
/*
|
42
|
+
= DIGIT ; 0 - 9
|
43
|
+
/ %x41-57 ; A - W
|
44
|
+
/ %x59-5A ; Y - Z
|
45
|
+
/ %x61-77 ; a - w
|
46
|
+
/ %x79-7A ; y - z
|
47
|
+
*/
|
48
|
+
var singleton = '(\\d|[A-W]|[Y-Z]|[a-w]|[y-z])';
|
49
|
+
|
50
|
+
/*
|
51
|
+
= singleton 1*("-" (2*8alphanum))
|
52
|
+
; Single alphanumerics
|
53
|
+
; "x" reserved for private use
|
54
|
+
*/
|
55
|
+
var extension = "(".concat(singleton, "(-[A-Za-z0-9]{2,8})+)");
|
56
|
+
|
57
|
+
/*
|
58
|
+
= "x" 1*("-" (1*8alphanum))
|
59
|
+
*/
|
60
|
+
var privateuse = '(x(-[A-Za-z0-9]{1,8})+)';
|
61
|
+
|
62
|
+
// irregular tags do not match the 'langtag' production and would not
|
63
|
+
// otherwise be considered 'well-formed'. These tags are all valid, but
|
64
|
+
// most are deprecated in favor of more modern subtags or subtag combination
|
65
|
+
|
66
|
+
var irregular = '((en-GB-oed)|(i-ami)|(i-bnn)|(i-default)|(i-enochian)|' + '(i-hak)|(i-klingon)|(i-lux)|(i-mingo)|(i-navajo)|(i-pwn)|(i-tao)|' + '(i-tay)|(i-tsu)|(sgn-BE-FR)|(sgn-BE-NL)|(sgn-CH-DE))';
|
67
|
+
|
68
|
+
// regular tags match the 'langtag' production, but their subtags are not
|
69
|
+
// extended language or variant subtags: their meaning is defined by
|
70
|
+
// their registration and all of these are deprecated in favor of a more
|
71
|
+
// modern subtag or sequence of subtags
|
72
|
+
|
73
|
+
var regular = '((art-lojban)|(cel-gaulish)|(no-bok)|(no-nyn)|(zh-guoyu)|' + '(zh-hakka)|(zh-min)|(zh-min-nan)|(zh-xiang))';
|
74
|
+
|
75
|
+
/*
|
76
|
+
= irregular ; non-redundant tags registered
|
77
|
+
/ regular ; during the RFC 3066 era
|
78
|
+
|
79
|
+
*/
|
80
|
+
var grandfathered = "(".concat(irregular, "|").concat(regular, ")");
|
81
|
+
|
82
|
+
/*
|
83
|
+
RFC 5646 defines delimitation of subtags via a hyphen:
|
84
|
+
|
85
|
+
"Subtag" refers to a specific section of a tag, delimited by a
|
86
|
+
hyphen, such as the subtags 'zh', 'Hant', and 'CN' in the tag "zh-
|
87
|
+
Hant-CN". Examples of subtags in this document are enclosed in
|
88
|
+
single quotes ('Hant')
|
89
|
+
|
90
|
+
However, we need to add "_" to maintain the existing behaviour.
|
91
|
+
*/
|
92
|
+
var delimiter = '(-|_)';
|
93
|
+
|
94
|
+
/*
|
95
|
+
= language
|
96
|
+
["-" script]
|
97
|
+
["-" region]
|
98
|
+
*("-" variant)
|
99
|
+
*("-" extension)
|
100
|
+
["-" privateuse]
|
101
|
+
*/
|
102
|
+
var langtag = "".concat(language, "(").concat(delimiter).concat(script, ")?(").concat(delimiter).concat(region, ")?(").concat(delimiter).concat(variant, ")*(").concat(delimiter).concat(extension, ")*(").concat(delimiter).concat(privateuse, ")?");
|
103
|
+
|
104
|
+
/*
|
105
|
+
Regex implementation based on BCP RFC 5646
|
106
|
+
Tags for Identifying Languages
|
107
|
+
https://www.rfc-editor.org/rfc/rfc5646.html
|
108
|
+
*/
|
109
|
+
var languageTagRegex = new RegExp("(^".concat(privateuse, "$)|(^").concat(grandfathered, "$)|(^").concat(langtag, "$)"));
|
110
|
+
function isLocale(str) {
|
111
|
+
(0, _assertString.default)(str);
|
112
|
+
return languageTagRegex.test(str);
|
113
|
+
}
|
114
|
+
module.exports = exports.default;
|
115
|
+
module.exports.default = exports.default;
|
@@ -0,0 +1,14 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = isLowercase;
|
7
|
+
var _assertString = _interopRequireDefault(require("./util/assertString"));
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
9
|
+
function isLowercase(str) {
|
10
|
+
(0, _assertString.default)(str);
|
11
|
+
return str === str.toLowerCase();
|
12
|
+
}
|
13
|
+
module.exports = exports.default;
|
14
|
+
module.exports.default = exports.default;
|
@@ -0,0 +1,34 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = isLuhnNumber;
|
7
|
+
var _assertString = _interopRequireDefault(require("./util/assertString"));
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
9
|
+
function isLuhnNumber(str) {
|
10
|
+
(0, _assertString.default)(str);
|
11
|
+
var sanitized = str.replace(/[- ]+/g, '');
|
12
|
+
var sum = 0;
|
13
|
+
var digit;
|
14
|
+
var tmpNum;
|
15
|
+
var shouldDouble;
|
16
|
+
for (var i = sanitized.length - 1; i >= 0; i--) {
|
17
|
+
digit = sanitized.substring(i, i + 1);
|
18
|
+
tmpNum = parseInt(digit, 10);
|
19
|
+
if (shouldDouble) {
|
20
|
+
tmpNum *= 2;
|
21
|
+
if (tmpNum >= 10) {
|
22
|
+
sum += tmpNum % 10 + 1;
|
23
|
+
} else {
|
24
|
+
sum += tmpNum;
|
25
|
+
}
|
26
|
+
} else {
|
27
|
+
sum += tmpNum;
|
28
|
+
}
|
29
|
+
shouldDouble = !shouldDouble;
|
30
|
+
}
|
31
|
+
return !!(sum % 10 === 0 ? sanitized : false);
|
32
|
+
}
|
33
|
+
module.exports = exports.default;
|
34
|
+
module.exports.default = exports.default;
|
@@ -0,0 +1,45 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = isMACAddress;
|
7
|
+
var _assertString = _interopRequireDefault(require("./util/assertString"));
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
9
|
+
var macAddress48 = /^(?:[0-9a-fA-F]{2}([-:\s]))([0-9a-fA-F]{2}\1){4}([0-9a-fA-F]{2})$/;
|
10
|
+
var macAddress48NoSeparators = /^([0-9a-fA-F]){12}$/;
|
11
|
+
var macAddress48WithDots = /^([0-9a-fA-F]{4}\.){2}([0-9a-fA-F]{4})$/;
|
12
|
+
var macAddress64 = /^(?:[0-9a-fA-F]{2}([-:\s]))([0-9a-fA-F]{2}\1){6}([0-9a-fA-F]{2})$/;
|
13
|
+
var macAddress64NoSeparators = /^([0-9a-fA-F]){16}$/;
|
14
|
+
var macAddress64WithDots = /^([0-9a-fA-F]{4}\.){3}([0-9a-fA-F]{4})$/;
|
15
|
+
function isMACAddress(str, options) {
|
16
|
+
(0, _assertString.default)(str);
|
17
|
+
if (options !== null && options !== void 0 && options.eui) {
|
18
|
+
options.eui = String(options.eui);
|
19
|
+
}
|
20
|
+
/**
|
21
|
+
* @deprecated `no_colons` TODO: remove it in the next major
|
22
|
+
*/
|
23
|
+
if (options !== null && options !== void 0 && options.no_colons || options !== null && options !== void 0 && options.no_separators) {
|
24
|
+
if (options.eui === '48') {
|
25
|
+
return macAddress48NoSeparators.test(str);
|
26
|
+
}
|
27
|
+
if (options.eui === '64') {
|
28
|
+
return macAddress64NoSeparators.test(str);
|
29
|
+
}
|
30
|
+
return macAddress48NoSeparators.test(str) || macAddress64NoSeparators.test(str);
|
31
|
+
}
|
32
|
+
if ((options === null || options === void 0 ? void 0 : options.eui) === '48') {
|
33
|
+
return macAddress48.test(str) || macAddress48WithDots.test(str);
|
34
|
+
}
|
35
|
+
if ((options === null || options === void 0 ? void 0 : options.eui) === '64') {
|
36
|
+
return macAddress64.test(str) || macAddress64WithDots.test(str);
|
37
|
+
}
|
38
|
+
return isMACAddress(str, {
|
39
|
+
eui: '48'
|
40
|
+
}) || isMACAddress(str, {
|
41
|
+
eui: '64'
|
42
|
+
});
|
43
|
+
}
|
44
|
+
module.exports = exports.default;
|
45
|
+
module.exports.default = exports.default;
|
package/lib/isMD5.js
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = isMD5;
|
7
|
+
var _assertString = _interopRequireDefault(require("./util/assertString"));
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
9
|
+
var md5 = /^[a-f0-9]{32}$/;
|
10
|
+
function isMD5(str) {
|
11
|
+
(0, _assertString.default)(str);
|
12
|
+
return md5.test(str);
|
13
|
+
}
|
14
|
+
module.exports = exports.default;
|
15
|
+
module.exports.default = exports.default;
|
@@ -0,0 +1,18 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = isMagnetURI;
|
7
|
+
var _assertString = _interopRequireDefault(require("./util/assertString"));
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
9
|
+
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;
|
10
|
+
function isMagnetURI(url) {
|
11
|
+
(0, _assertString.default)(url);
|
12
|
+
if (url.indexOf('magnet:?') !== 0) {
|
13
|
+
return false;
|
14
|
+
}
|
15
|
+
return magnetURIComponent.test(url);
|
16
|
+
}
|
17
|
+
module.exports = exports.default;
|
18
|
+
module.exports.default = exports.default;
|
@@ -0,0 +1,84 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = isMailtoURI;
|
7
|
+
var _trim = _interopRequireDefault(require("./trim"));
|
8
|
+
var _isEmail = _interopRequireDefault(require("./isEmail"));
|
9
|
+
var _assertString = _interopRequireDefault(require("./util/assertString"));
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
11
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
12
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
13
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
14
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
15
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
16
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
17
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
18
|
+
function parseMailtoQueryString(queryString) {
|
19
|
+
var allowedParams = new Set(['subject', 'body', 'cc', 'bcc']),
|
20
|
+
query = {
|
21
|
+
cc: '',
|
22
|
+
bcc: ''
|
23
|
+
};
|
24
|
+
var isParseFailed = false;
|
25
|
+
var queryParams = queryString.split('&');
|
26
|
+
if (queryParams.length > 4) {
|
27
|
+
return false;
|
28
|
+
}
|
29
|
+
var _iterator = _createForOfIteratorHelper(queryParams),
|
30
|
+
_step;
|
31
|
+
try {
|
32
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
33
|
+
var q = _step.value;
|
34
|
+
var _q$split = q.split('='),
|
35
|
+
_q$split2 = _slicedToArray(_q$split, 2),
|
36
|
+
key = _q$split2[0],
|
37
|
+
value = _q$split2[1];
|
38
|
+
|
39
|
+
// checked for invalid and duplicated query params
|
40
|
+
if (key && !allowedParams.has(key)) {
|
41
|
+
isParseFailed = true;
|
42
|
+
break;
|
43
|
+
}
|
44
|
+
if (value && (key === 'cc' || key === 'bcc')) {
|
45
|
+
query[key] = value;
|
46
|
+
}
|
47
|
+
if (key) {
|
48
|
+
allowedParams.delete(key);
|
49
|
+
}
|
50
|
+
}
|
51
|
+
} catch (err) {
|
52
|
+
_iterator.e(err);
|
53
|
+
} finally {
|
54
|
+
_iterator.f();
|
55
|
+
}
|
56
|
+
return isParseFailed ? false : query;
|
57
|
+
}
|
58
|
+
function isMailtoURI(url, options) {
|
59
|
+
(0, _assertString.default)(url);
|
60
|
+
if (url.indexOf('mailto:') !== 0) {
|
61
|
+
return false;
|
62
|
+
}
|
63
|
+
var _url$replace$split = url.replace('mailto:', '').split('?'),
|
64
|
+
_url$replace$split2 = _slicedToArray(_url$replace$split, 2),
|
65
|
+
to = _url$replace$split2[0],
|
66
|
+
_url$replace$split2$ = _url$replace$split2[1],
|
67
|
+
queryString = _url$replace$split2$ === void 0 ? '' : _url$replace$split2$;
|
68
|
+
if (!to && !queryString) {
|
69
|
+
return true;
|
70
|
+
}
|
71
|
+
var query = parseMailtoQueryString(queryString);
|
72
|
+
if (!query) {
|
73
|
+
return false;
|
74
|
+
}
|
75
|
+
return "".concat(to, ",").concat(query.cc, ",").concat(query.bcc).split(',').every(function (email) {
|
76
|
+
email = (0, _trim.default)(email, ' ');
|
77
|
+
if (email) {
|
78
|
+
return (0, _isEmail.default)(email, options);
|
79
|
+
}
|
80
|
+
return true;
|
81
|
+
});
|
82
|
+
}
|
83
|
+
module.exports = exports.default;
|
84
|
+
module.exports.default = exports.default;
|
@@ -0,0 +1,48 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = isMimeType;
|
7
|
+
var _assertString = _interopRequireDefault(require("./util/assertString"));
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
9
|
+
/*
|
10
|
+
Checks if the provided string matches to a correct Media type format (MIME type)
|
11
|
+
|
12
|
+
This function only checks is the string format follows the
|
13
|
+
etablished rules by the according RFC specifications.
|
14
|
+
This function supports 'charset' in textual media types
|
15
|
+
(https://tools.ietf.org/html/rfc6657).
|
16
|
+
|
17
|
+
This function does not check against all the media types listed
|
18
|
+
by the IANA (https://www.iana.org/assignments/media-types/media-types.xhtml)
|
19
|
+
because of lightness purposes : it would require to include
|
20
|
+
all these MIME types in this librairy, which would weigh it
|
21
|
+
significantly. This kind of effort maybe is not worth for the use that
|
22
|
+
this function has in this entire librairy.
|
23
|
+
|
24
|
+
More informations in the RFC specifications :
|
25
|
+
- https://tools.ietf.org/html/rfc2045
|
26
|
+
- https://tools.ietf.org/html/rfc2046
|
27
|
+
- https://tools.ietf.org/html/rfc7231#section-3.1.1.1
|
28
|
+
- https://tools.ietf.org/html/rfc7231#section-3.1.1.5
|
29
|
+
*/
|
30
|
+
|
31
|
+
// Match simple MIME types
|
32
|
+
// NB :
|
33
|
+
// Subtype length must not exceed 100 characters.
|
34
|
+
// This rule does not comply to the RFC specs (what is the max length ?).
|
35
|
+
var mimeTypeSimple = /^(application|audio|font|image|message|model|multipart|text|video)\/[a-zA-Z0-9\.\-\+_]{1,100}$/i; // eslint-disable-line max-len
|
36
|
+
|
37
|
+
// Handle "charset" in "text/*"
|
38
|
+
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
|
39
|
+
|
40
|
+
// Handle "boundary" in "multipart/*"
|
41
|
+
var mimeTypeMultipart = /^multipart\/[a-zA-Z0-9\.\-\+]{1,100}(;\s?(boundary|charset)=("[a-zA-Z0-9\.\-\+\s]{0,70}"|[a-zA-Z0-9\.\-\+]{0,70})(\s?\([a-zA-Z0-9\.\-\+\s]{1,20}\))?){0,2}$/i; // eslint-disable-line max-len
|
42
|
+
|
43
|
+
function isMimeType(str) {
|
44
|
+
(0, _assertString.default)(str);
|
45
|
+
return mimeTypeSimple.test(str) || mimeTypeText.test(str) || mimeTypeMultipart.test(str);
|
46
|
+
}
|
47
|
+
module.exports = exports.default;
|
48
|
+
module.exports.default = exports.default;
|
@@ -0,0 +1,215 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = isMobilePhone;
|
7
|
+
exports.locales = void 0;
|
8
|
+
var _assertString = _interopRequireDefault(require("./util/assertString"));
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
10
|
+
/* eslint-disable max-len */
|
11
|
+
var phones = {
|
12
|
+
'am-AM': /^(\+?374|0)(33|4[134]|55|77|88|9[13-689])\d{6}$/,
|
13
|
+
'ar-AE': /^((\+?971)|0)?5[024568]\d{7}$/,
|
14
|
+
'ar-BH': /^(\+?973)?(3|6)\d{7}$/,
|
15
|
+
'ar-DZ': /^(\+?213|0)(5|6|7)\d{8}$/,
|
16
|
+
'ar-LB': /^(\+?961)?((3|81)\d{6}|7\d{7})$/,
|
17
|
+
'ar-EG': /^((\+?20)|0)?1[0125]\d{8}$/,
|
18
|
+
'ar-IQ': /^(\+?964|0)?7[0-9]\d{8}$/,
|
19
|
+
'ar-JO': /^(\+?962|0)?7[789]\d{7}$/,
|
20
|
+
'ar-KW': /^(\+?965)([569]\d{7}|41\d{6})$/,
|
21
|
+
'ar-LY': /^((\+?218)|0)?(9[1-6]\d{7}|[1-8]\d{7,9})$/,
|
22
|
+
'ar-MA': /^(?:(?:\+|00)212|0)[5-7]\d{8}$/,
|
23
|
+
'ar-OM': /^((\+|00)968)?(9[1-9])\d{6}$/,
|
24
|
+
'ar-PS': /^(\+?970|0)5[6|9](\d{7})$/,
|
25
|
+
'ar-SA': /^(!?(\+?966)|0)?5\d{8}$/,
|
26
|
+
'ar-SD': /^((\+?249)|0)?(9[012369]|1[012])\d{7}$/,
|
27
|
+
'ar-SY': /^(!?(\+?963)|0)?9\d{8}$/,
|
28
|
+
'ar-TN': /^(\+?216)?[2459]\d{7}$/,
|
29
|
+
'az-AZ': /^(\+994|0)(10|5[015]|7[07]|99)\d{7}$/,
|
30
|
+
'bs-BA': /^((((\+|00)3876)|06))((([0-3]|[5-6])\d{6})|(4\d{7}))$/,
|
31
|
+
'be-BY': /^(\+?375)?(24|25|29|33|44)\d{7}$/,
|
32
|
+
'bg-BG': /^(\+?359|0)?8[789]\d{7}$/,
|
33
|
+
'bn-BD': /^(\+?880|0)1[13456789][0-9]{8}$/,
|
34
|
+
'ca-AD': /^(\+376)?[346]\d{5}$/,
|
35
|
+
'cs-CZ': /^(\+?420)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/,
|
36
|
+
'da-DK': /^(\+?45)?\s?\d{2}\s?\d{2}\s?\d{2}\s?\d{2}$/,
|
37
|
+
'de-DE': /^((\+49|0)1)(5[0-25-9]\d|6([23]|0\d?)|7([0-57-9]|6\d))\d{7,9}$/,
|
38
|
+
'de-AT': /^(\+43|0)\d{1,4}\d{3,12}$/,
|
39
|
+
'de-CH': /^(\+41|0)([1-9])\d{1,9}$/,
|
40
|
+
'de-LU': /^(\+352)?((6\d1)\d{6})$/,
|
41
|
+
'dv-MV': /^(\+?960)?(7[2-9]|9[1-9])\d{5}$/,
|
42
|
+
'el-GR': /^(\+?30|0)?6(8[5-9]|9(?![26])[0-9])\d{7}$/,
|
43
|
+
'el-CY': /^(\+?357?)?(9(9|6)\d{6})$/,
|
44
|
+
'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}$/,
|
45
|
+
'en-AU': /^(\+?61|0)4\d{8}$/,
|
46
|
+
'en-AG': /^(?:\+1|1)268(?:464|7(?:1[3-9]|[28]\d|3[0246]|64|7[0-689]))\d{4}$/,
|
47
|
+
'en-BM': /^(\+?1)?441(((3|7)\d{6}$)|(5[0-3][0-9]\d{4}$)|(59\d{5}$))/,
|
48
|
+
'en-BS': /^(\+?1[-\s]?|0)?\(?242\)?[-\s]?\d{3}[-\s]?\d{4}$/,
|
49
|
+
'en-GB': /^(\+?44|0)7\d{9}$/,
|
50
|
+
'en-GG': /^(\+?44|0)1481\d{6}$/,
|
51
|
+
'en-GH': /^(\+233|0)(20|50|24|54|27|57|26|56|23|28|55|59)\d{7}$/,
|
52
|
+
'en-GY': /^(\+592|0)6\d{6}$/,
|
53
|
+
'en-HK': /^(\+?852[-\s]?)?[456789]\d{3}[-\s]?\d{4}$/,
|
54
|
+
'en-MO': /^(\+?853[-\s]?)?[6]\d{3}[-\s]?\d{4}$/,
|
55
|
+
'en-IE': /^(\+?353|0)8[356789]\d{7}$/,
|
56
|
+
'en-IN': /^(\+?91|0)?[6789]\d{9}$/,
|
57
|
+
'en-JM': /^(\+?876)?\d{7}$/,
|
58
|
+
'en-KE': /^(\+?254|0)(7|1)\d{8}$/,
|
59
|
+
'fr-CF': /^(\+?236| ?)(70|75|77|72|21|22)\d{6}$/,
|
60
|
+
'en-SS': /^(\+?211|0)(9[1257])\d{7}$/,
|
61
|
+
'en-KI': /^((\+686|686)?)?( )?((6|7)(2|3|8)[0-9]{6})$/,
|
62
|
+
'en-KN': /^(?:\+1|1)869(?:46\d|48[89]|55[6-8]|66\d|76[02-7])\d{4}$/,
|
63
|
+
'en-LS': /^(\+?266)(22|28|57|58|59|27|52)\d{6}$/,
|
64
|
+
'en-MT': /^(\+?356|0)?(99|79|77|21|27|22|25)[0-9]{6}$/,
|
65
|
+
'en-MU': /^(\+?230|0)?\d{8}$/,
|
66
|
+
'en-MW': /^(\+?265|0)(((77|88|31|99|98|21)\d{7})|(((111)|1)\d{6})|(32000\d{4}))$/,
|
67
|
+
'en-NA': /^(\+?264|0)(6|8)\d{7}$/,
|
68
|
+
'en-NG': /^(\+?234|0)?[789]\d{9}$/,
|
69
|
+
'en-NZ': /^(\+?64|0)[28]\d{7,9}$/,
|
70
|
+
'en-PG': /^(\+?675|0)?(7\d|8[18])\d{6}$/,
|
71
|
+
'en-PK': /^((00|\+)?92|0)3[0-6]\d{8}$/,
|
72
|
+
'en-PH': /^(09|\+639)\d{9}$/,
|
73
|
+
'en-RW': /^(\+?250|0)?[7]\d{8}$/,
|
74
|
+
'en-SG': /^(\+65)?[3689]\d{7}$/,
|
75
|
+
'en-SL': /^(\+?232|0)\d{8}$/,
|
76
|
+
'en-TZ': /^(\+?255|0)?[67]\d{8}$/,
|
77
|
+
'en-UG': /^(\+?256|0)?[7]\d{8}$/,
|
78
|
+
'en-US': /^((\+1|1)?( |-)?)?(\([2-9][0-9]{2}\)|[2-9][0-9]{2})( |-)?([2-9][0-9]{2}( |-)?[0-9]{4})$/,
|
79
|
+
'en-ZA': /^(\+?27|0)\d{9}$/,
|
80
|
+
'en-ZM': /^(\+?26)?09[567]\d{7}$/,
|
81
|
+
'en-ZW': /^(\+263)[0-9]{9}$/,
|
82
|
+
'en-BW': /^(\+?267)?(7[1-8]{1})\d{6}$/,
|
83
|
+
'es-AR': /^\+?549(11|[2368]\d)\d{8}$/,
|
84
|
+
'es-BO': /^(\+?591)?(6|7)\d{7}$/,
|
85
|
+
'es-CO': /^(\+?57)?3(0(0|1|2|4|5)|1\d|2[0-4]|5(0|1))\d{7}$/,
|
86
|
+
'es-CL': /^(\+?56|0)[2-9]\d{1}\d{7}$/,
|
87
|
+
'es-CR': /^(\+506)?[2-8]\d{7}$/,
|
88
|
+
'es-CU': /^(\+53|0053)?5\d{7}$/,
|
89
|
+
'es-DO': /^(\+?1)?8[024]9\d{7}$/,
|
90
|
+
'es-HN': /^(\+?504)?[9|8|3|2]\d{7}$/,
|
91
|
+
'es-EC': /^(\+?593|0)([2-7]|9[2-9])\d{7}$/,
|
92
|
+
'es-ES': /^(\+?34)?[6|7]\d{8}$/,
|
93
|
+
'es-PE': /^(\+?51)?9\d{8}$/,
|
94
|
+
'es-MX': /^(\+?52)?(1|01)?\d{10,11}$/,
|
95
|
+
'es-NI': /^(\+?505)\d{7,8}$/,
|
96
|
+
'es-PA': /^(\+?507)\d{7,8}$/,
|
97
|
+
'es-PY': /^(\+?595|0)9[9876]\d{7}$/,
|
98
|
+
'es-SV': /^(\+?503)?[67]\d{7}$/,
|
99
|
+
'es-UY': /^(\+598|0)9[1-9][\d]{6}$/,
|
100
|
+
'es-VE': /^(\+?58)?(2|4)\d{9}$/,
|
101
|
+
'et-EE': /^(\+?372)?\s?(5|8[1-4])\s?([0-9]\s?){6,7}$/,
|
102
|
+
'fa-IR': /^(\+?98[\-\s]?|0)9[0-39]\d[\-\s]?\d{3}[\-\s]?\d{4}$/,
|
103
|
+
'fi-FI': /^(\+?358|0)\s?(4[0-6]|50)\s?(\d\s?){4,8}$/,
|
104
|
+
'fj-FJ': /^(\+?679)?\s?\d{3}\s?\d{4}$/,
|
105
|
+
'fo-FO': /^(\+?298)?\s?\d{2}\s?\d{2}\s?\d{2}$/,
|
106
|
+
'fr-BF': /^(\+226|0)[67]\d{7}$/,
|
107
|
+
'fr-BJ': /^(\+229)\d{8}$/,
|
108
|
+
'fr-CD': /^(\+?243|0)?(8|9)\d{8}$/,
|
109
|
+
'fr-CM': /^(\+?237)6[0-9]{8}$/,
|
110
|
+
'fr-FR': /^(\+?33|0)[67]\d{8}$/,
|
111
|
+
'fr-GF': /^(\+?594|0|00594)[67]\d{8}$/,
|
112
|
+
'fr-GP': /^(\+?590|0|00590)[67]\d{8}$/,
|
113
|
+
'fr-MQ': /^(\+?596|0|00596)[67]\d{8}$/,
|
114
|
+
'fr-PF': /^(\+?689)?8[789]\d{6}$/,
|
115
|
+
'fr-RE': /^(\+?262|0|00262)[67]\d{8}$/,
|
116
|
+
'fr-WF': /^(\+681)?\d{6}$/,
|
117
|
+
'he-IL': /^(\+972|0)([23489]|5[012345689]|77)[1-9]\d{6}$/,
|
118
|
+
'hu-HU': /^(\+?36|06)(20|30|31|50|70)\d{7}$/,
|
119
|
+
'id-ID': /^(\+?62|0)8(1[123456789]|2[1238]|3[1238]|5[12356789]|7[78]|9[56789]|8[123456789])([\s?|\d]{5,11})$/,
|
120
|
+
'ir-IR': /^(\+98|0)?9\d{9}$/,
|
121
|
+
'it-IT': /^(\+?39)?\s?3\d{2} ?\d{6,7}$/,
|
122
|
+
'it-SM': /^((\+378)|(0549)|(\+390549)|(\+3780549))?6\d{5,9}$/,
|
123
|
+
'ja-JP': /^(\+81[ \-]?(\(0\))?|0)[6789]0[ \-]?\d{4}[ \-]?\d{4}$/,
|
124
|
+
'ka-GE': /^(\+?995)?(79\d{7}|5\d{8})$/,
|
125
|
+
'kk-KZ': /^(\+?7|8)?7\d{9}$/,
|
126
|
+
'kl-GL': /^(\+?299)?\s?\d{2}\s?\d{2}\s?\d{2}$/,
|
127
|
+
'ko-KR': /^((\+?82)[ \-]?)?0?1([0|1|6|7|8|9]{1})[ \-]?\d{3,4}[ \-]?\d{4}$/,
|
128
|
+
'ky-KG': /^(\+?7\s?\+?7|0)\s?\d{2}\s?\d{3}\s?\d{4}$/,
|
129
|
+
'lt-LT': /^(\+370|8)\d{8}$/,
|
130
|
+
'lv-LV': /^(\+?371)2\d{7}$/,
|
131
|
+
'mg-MG': /^((\+?261|0)(2|3)\d)?\d{7}$/,
|
132
|
+
'mn-MN': /^(\+|00|011)?976(77|81|88|91|94|95|96|99)\d{6}$/,
|
133
|
+
'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}$/,
|
134
|
+
'ms-MY': /^(\+?60|0)1(([0145](-|\s)?\d{7,8})|([236-9](-|\s)?\d{7}))$/,
|
135
|
+
'mz-MZ': /^(\+?258)?8[234567]\d{7}$/,
|
136
|
+
'nb-NO': /^(\+?47)?[49]\d{7}$/,
|
137
|
+
'ne-NP': /^(\+?977)?9[78]\d{8}$/,
|
138
|
+
'nl-BE': /^(\+?32|0)4\d{8}$/,
|
139
|
+
'nl-NL': /^(((\+|00)?31\(0\))|((\+|00)?31)|0)6{1}\d{8}$/,
|
140
|
+
'nl-AW': /^(\+)?297(56|59|64|73|74|99)\d{5}$/,
|
141
|
+
'nn-NO': /^(\+?47)?[49]\d{7}$/,
|
142
|
+
'pl-PL': /^(\+?48)? ?([5-8]\d|45) ?\d{3} ?\d{2} ?\d{2}$/,
|
143
|
+
'pt-BR': /^((\+?55\ ?[1-9]{2}\ ?)|(\+?55\ ?\([1-9]{2}\)\ ?)|(0[1-9]{2}\ ?)|(\([1-9]{2}\)\ ?)|([1-9]{2}\ ?))((\d{4}\-?\d{4})|(9[1-9]{1}\d{3}\-?\d{4}))$/,
|
144
|
+
'pt-PT': /^(\+?351)?9[1236]\d{7}$/,
|
145
|
+
'pt-AO': /^(\+244)\d{9}$/,
|
146
|
+
'ro-MD': /^(\+?373|0)((6(0|1|2|6|7|8|9))|(7(6|7|8|9)))\d{6}$/,
|
147
|
+
'ro-RO': /^(\+?40|0)\s?7\d{2}(\/|\s|\.|-)?\d{3}(\s|\.|-)?\d{3}$/,
|
148
|
+
'ru-RU': /^(\+?7|8)?9\d{9}$/,
|
149
|
+
'si-LK': /^(?:0|94|\+94)?(7(0|1|2|4|5|6|7|8)( |-)?)\d{7}$/,
|
150
|
+
'sl-SI': /^(\+386\s?|0)(\d{1}\s?\d{3}\s?\d{2}\s?\d{2}|\d{2}\s?\d{3}\s?\d{3})$/,
|
151
|
+
'sk-SK': /^(\+?421)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/,
|
152
|
+
'so-SO': /^(\+?252|0)((6[0-9])\d{7}|(7[1-9])\d{7})$/,
|
153
|
+
'sq-AL': /^(\+355|0)6[789]\d{6}$/,
|
154
|
+
'sr-RS': /^(\+3816|06)[- \d]{5,9}$/,
|
155
|
+
'sv-SE': /^(\+?46|0)[\s\-]?7[\s\-]?[02369]([\s\-]?\d){7}$/,
|
156
|
+
'tg-TJ': /^(\+?992)?[5][5]\d{7}$/,
|
157
|
+
'th-TH': /^(\+66|66|0)\d{9}$/,
|
158
|
+
'tr-TR': /^(\+?90|0)?5\d{9}$/,
|
159
|
+
'tk-TM': /^(\+993|993|8)\d{8}$/,
|
160
|
+
'uk-UA': /^(\+?38|8)?0\d{9}$/,
|
161
|
+
'uz-UZ': /^(\+?998)?(6[125-79]|7[1-69]|88|9\d)\d{7}$/,
|
162
|
+
'vi-VN': /^((\+?84)|0)((3([2-9]))|(5([25689]))|(7([0|6-9]))|(8([1-9]))|(9([0-9])))([0-9]{7})$/,
|
163
|
+
'zh-CN': /^((\+|00)86)?(1[3-9]|9[28])\d{9}$/,
|
164
|
+
'zh-TW': /^(\+?886\-?|0)?9\d{8}$/,
|
165
|
+
'dz-BT': /^(\+?975|0)?(17|16|77|02)\d{6}$/,
|
166
|
+
'ar-YE': /^(((\+|00)9677|0?7)[0137]\d{7}|((\+|00)967|0)[1-7]\d{6})$/,
|
167
|
+
'ar-EH': /^(\+?212|0)[\s\-]?(5288|5289)[\s\-]?\d{5}$/,
|
168
|
+
'fa-AF': /^(\+93|0)?(2{1}[0-8]{1}|[3-5]{1}[0-4]{1})(\d{7})$/
|
169
|
+
};
|
170
|
+
/* eslint-enable max-len */
|
171
|
+
|
172
|
+
// aliases
|
173
|
+
phones['en-CA'] = phones['en-US'];
|
174
|
+
phones['fr-CA'] = phones['en-CA'];
|
175
|
+
phones['fr-BE'] = phones['nl-BE'];
|
176
|
+
phones['zh-HK'] = phones['en-HK'];
|
177
|
+
phones['zh-MO'] = phones['en-MO'];
|
178
|
+
phones['ga-IE'] = phones['en-IE'];
|
179
|
+
phones['fr-CH'] = phones['de-CH'];
|
180
|
+
phones['it-CH'] = phones['fr-CH'];
|
181
|
+
function isMobilePhone(str, locale, options) {
|
182
|
+
(0, _assertString.default)(str);
|
183
|
+
if (options && options.strictMode && !str.startsWith('+')) {
|
184
|
+
return false;
|
185
|
+
}
|
186
|
+
if (Array.isArray(locale)) {
|
187
|
+
return locale.some(function (key) {
|
188
|
+
// https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md#ignoring-code-for-coverage-purposes
|
189
|
+
// istanbul ignore else
|
190
|
+
if (phones.hasOwnProperty(key)) {
|
191
|
+
var phone = phones[key];
|
192
|
+
if (phone.test(str)) {
|
193
|
+
return true;
|
194
|
+
}
|
195
|
+
}
|
196
|
+
return false;
|
197
|
+
});
|
198
|
+
} else if (locale in phones) {
|
199
|
+
return phones[locale].test(str);
|
200
|
+
// alias falsey locale as 'any'
|
201
|
+
} else if (!locale || locale === 'any') {
|
202
|
+
for (var key in phones) {
|
203
|
+
// istanbul ignore else
|
204
|
+
if (phones.hasOwnProperty(key)) {
|
205
|
+
var phone = phones[key];
|
206
|
+
if (phone.test(str)) {
|
207
|
+
return true;
|
208
|
+
}
|
209
|
+
}
|
210
|
+
}
|
211
|
+
return false;
|
212
|
+
}
|
213
|
+
throw new Error("Invalid locale '".concat(locale, "'"));
|
214
|
+
}
|
215
|
+
var locales = exports.locales = Object.keys(phones);
|
package/lib/isMongoId.js
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = isMongoId;
|
7
|
+
var _assertString = _interopRequireDefault(require("./util/assertString"));
|
8
|
+
var _isHexadecimal = _interopRequireDefault(require("./isHexadecimal"));
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
10
|
+
function isMongoId(str) {
|
11
|
+
(0, _assertString.default)(str);
|
12
|
+
return (0, _isHexadecimal.default)(str) && str.length === 24;
|
13
|
+
}
|
14
|
+
module.exports = exports.default;
|
15
|
+
module.exports.default = exports.default;
|
@@ -0,0 +1,18 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = isMultibyte;
|
7
|
+
var _assertString = _interopRequireDefault(require("./util/assertString"));
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
9
|
+
/* eslint-disable no-control-regex */
|
10
|
+
var multibyte = /[^\x00-\x7F]/;
|
11
|
+
/* eslint-enable no-control-regex */
|
12
|
+
|
13
|
+
function isMultibyte(str) {
|
14
|
+
(0, _assertString.default)(str);
|
15
|
+
return multibyte.test(str);
|
16
|
+
}
|
17
|
+
module.exports = exports.default;
|
18
|
+
module.exports.default = exports.default;
|
package/lib/isNumeric.js
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = isNumeric;
|
7
|
+
var _assertString = _interopRequireDefault(require("./util/assertString"));
|
8
|
+
var _alpha = require("./alpha");
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
10
|
+
var numericNoSymbols = /^[0-9]+$/;
|
11
|
+
function isNumeric(str, options) {
|
12
|
+
(0, _assertString.default)(str);
|
13
|
+
if (options && options.no_symbols) {
|
14
|
+
return numericNoSymbols.test(str);
|
15
|
+
}
|
16
|
+
return new RegExp("^[+-]?([0-9]*[".concat((options || {}).locale ? _alpha.decimal[options.locale] : '.', "])?[0-9]+$")).test(str);
|
17
|
+
}
|
18
|
+
module.exports = exports.default;
|
19
|
+
module.exports.default = exports.default;
|
package/lib/isOctal.js
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = isOctal;
|
7
|
+
var _assertString = _interopRequireDefault(require("./util/assertString"));
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
9
|
+
var octal = /^(0o)?[0-7]+$/i;
|
10
|
+
function isOctal(str) {
|
11
|
+
(0, _assertString.default)(str);
|
12
|
+
return octal.test(str);
|
13
|
+
}
|
14
|
+
module.exports = exports.default;
|
15
|
+
module.exports.default = exports.default;
|