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