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
@@ -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(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _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(arr) { if (Array.isArray(arr)) return arr; }
|
5
|
+
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; } } }; }
|
6
|
+
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); }
|
7
|
+
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; }
|
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
|
+
etablished 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 librairy, 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 librairy.
|
17
|
+
|
18
|
+
More informations 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,208 @@
|
|
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)?(9[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
|
+
'bs-BA': /^((((\+|00)3876)|06))((([0-3]|[5-6])\d{6})|(4\d{7}))$/,
|
24
|
+
'be-BY': /^(\+?375)?(24|25|29|33|44)\d{7}$/,
|
25
|
+
'bg-BG': /^(\+?359|0)?8[789]\d{7}$/,
|
26
|
+
'bn-BD': /^(\+?880|0)1[13456789][0-9]{8}$/,
|
27
|
+
'ca-AD': /^(\+376)?[346]\d{5}$/,
|
28
|
+
'cs-CZ': /^(\+?420)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/,
|
29
|
+
'da-DK': /^(\+?45)?\s?\d{2}\s?\d{2}\s?\d{2}\s?\d{2}$/,
|
30
|
+
'de-DE': /^((\+49|0)1)(5[0-25-9]\d|6([23]|0\d?)|7([0-57-9]|6\d))\d{7,9}$/,
|
31
|
+
'de-AT': /^(\+43|0)\d{1,4}\d{3,12}$/,
|
32
|
+
'de-CH': /^(\+41|0)([1-9])\d{1,9}$/,
|
33
|
+
'de-LU': /^(\+352)?((6\d1)\d{6})$/,
|
34
|
+
'dv-MV': /^(\+?960)?(7[2-9]|9[1-9])\d{5}$/,
|
35
|
+
'el-GR': /^(\+?30|0)?6(8[5-9]|9(?![26])[0-9])\d{7}$/,
|
36
|
+
'el-CY': /^(\+?357?)?(9(9|6)\d{6})$/,
|
37
|
+
'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}$/,
|
38
|
+
'en-AU': /^(\+?61|0)4\d{8}$/,
|
39
|
+
'en-AG': /^(?:\+1|1)268(?:464|7(?:1[3-9]|[28]\d|3[0246]|64|7[0-689]))\d{4}$/,
|
40
|
+
'en-BM': /^(\+?1)?441(((3|7)\d{6}$)|(5[0-3][0-9]\d{4}$)|(59\d{5}$))/,
|
41
|
+
'en-BS': /^(\+?1[-\s]?|0)?\(?242\)?[-\s]?\d{3}[-\s]?\d{4}$/,
|
42
|
+
'en-GB': /^(\+?44|0)7\d{9}$/,
|
43
|
+
'en-GG': /^(\+?44|0)1481\d{6}$/,
|
44
|
+
'en-GH': /^(\+233|0)(20|50|24|54|27|57|26|56|23|28|55|59)\d{7}$/,
|
45
|
+
'en-GY': /^(\+592|0)6\d{6}$/,
|
46
|
+
'en-HK': /^(\+?852[-\s]?)?[456789]\d{3}[-\s]?\d{4}$/,
|
47
|
+
'en-MO': /^(\+?853[-\s]?)?[6]\d{3}[-\s]?\d{4}$/,
|
48
|
+
'en-IE': /^(\+?353|0)8[356789]\d{7}$/,
|
49
|
+
'en-IN': /^(\+?91|0)?[6789]\d{9}$/,
|
50
|
+
'en-JM': /^(\+?876)?\d{7}$/,
|
51
|
+
'en-KE': /^(\+?254|0)(7|1)\d{8}$/,
|
52
|
+
'fr-CF': /^(\+?236| ?)(70|75|77|72|21|22)\d{6}$/,
|
53
|
+
'en-SS': /^(\+?211|0)(9[1257])\d{7}$/,
|
54
|
+
'en-KI': /^((\+686|686)?)?( )?((6|7)(2|3|8)[0-9]{6})$/,
|
55
|
+
'en-KN': /^(?:\+1|1)869(?:46\d|48[89]|55[6-8]|66\d|76[02-7])\d{4}$/,
|
56
|
+
'en-LS': /^(\+?266)(22|28|57|58|59|27|52)\d{6}$/,
|
57
|
+
'en-MT': /^(\+?356|0)?(99|79|77|21|27|22|25)[0-9]{6}$/,
|
58
|
+
'en-MU': /^(\+?230|0)?\d{8}$/,
|
59
|
+
'en-MW': /^(\+?265|0)(((77|88|31|99|98|21)\d{7})|(((111)|1)\d{6})|(32000\d{4}))$/,
|
60
|
+
'en-NA': /^(\+?264|0)(6|8)\d{7}$/,
|
61
|
+
'en-NG': /^(\+?234|0)?[789]\d{9}$/,
|
62
|
+
'en-NZ': /^(\+?64|0)[28]\d{7,9}$/,
|
63
|
+
'en-PG': /^(\+?675|0)?(7\d|8[18])\d{6}$/,
|
64
|
+
'en-PK': /^((00|\+)?92|0)3[0-6]\d{8}$/,
|
65
|
+
'en-PH': /^(09|\+639)\d{9}$/,
|
66
|
+
'en-RW': /^(\+?250|0)?[7]\d{8}$/,
|
67
|
+
'en-SG': /^(\+65)?[3689]\d{7}$/,
|
68
|
+
'en-SL': /^(\+?232|0)\d{8}$/,
|
69
|
+
'en-TZ': /^(\+?255|0)?[67]\d{8}$/,
|
70
|
+
'en-UG': /^(\+?256|0)?[7]\d{8}$/,
|
71
|
+
'en-US': /^((\+1|1)?( |-)?)?(\([2-9][0-9]{2}\)|[2-9][0-9]{2})( |-)?([2-9][0-9]{2}( |-)?[0-9]{4})$/,
|
72
|
+
'en-ZA': /^(\+?27|0)\d{9}$/,
|
73
|
+
'en-ZM': /^(\+?26)?09[567]\d{7}$/,
|
74
|
+
'en-ZW': /^(\+263)[0-9]{9}$/,
|
75
|
+
'en-BW': /^(\+?267)?(7[1-8]{1})\d{6}$/,
|
76
|
+
'es-AR': /^\+?549(11|[2368]\d)\d{8}$/,
|
77
|
+
'es-BO': /^(\+?591)?(6|7)\d{7}$/,
|
78
|
+
'es-CO': /^(\+?57)?3(0(0|1|2|4|5)|1\d|2[0-4]|5(0|1))\d{7}$/,
|
79
|
+
'es-CL': /^(\+?56|0)[2-9]\d{1}\d{7}$/,
|
80
|
+
'es-CR': /^(\+506)?[2-8]\d{7}$/,
|
81
|
+
'es-CU': /^(\+53|0053)?5\d{7}$/,
|
82
|
+
'es-DO': /^(\+?1)?8[024]9\d{7}$/,
|
83
|
+
'es-HN': /^(\+?504)?[9|8|3|2]\d{7}$/,
|
84
|
+
'es-EC': /^(\+?593|0)([2-7]|9[2-9])\d{7}$/,
|
85
|
+
'es-ES': /^(\+?34)?[6|7]\d{8}$/,
|
86
|
+
'es-PE': /^(\+?51)?9\d{8}$/,
|
87
|
+
'es-MX': /^(\+?52)?(1|01)?\d{10,11}$/,
|
88
|
+
'es-NI': /^(\+?505)\d{7,8}$/,
|
89
|
+
'es-PA': /^(\+?507)\d{7,8}$/,
|
90
|
+
'es-PY': /^(\+?595|0)9[9876]\d{7}$/,
|
91
|
+
'es-SV': /^(\+?503)?[67]\d{7}$/,
|
92
|
+
'es-UY': /^(\+598|0)9[1-9][\d]{6}$/,
|
93
|
+
'es-VE': /^(\+?58)?(2|4)\d{9}$/,
|
94
|
+
'et-EE': /^(\+?372)?\s?(5|8[1-4])\s?([0-9]\s?){6,7}$/,
|
95
|
+
'fa-IR': /^(\+?98[\-\s]?|0)9[0-39]\d[\-\s]?\d{3}[\-\s]?\d{4}$/,
|
96
|
+
'fi-FI': /^(\+?358|0)\s?(4[0-6]|50)\s?(\d\s?){4,8}$/,
|
97
|
+
'fj-FJ': /^(\+?679)?\s?\d{3}\s?\d{4}$/,
|
98
|
+
'fo-FO': /^(\+?298)?\s?\d{2}\s?\d{2}\s?\d{2}$/,
|
99
|
+
'fr-BF': /^(\+226|0)[67]\d{7}$/,
|
100
|
+
'fr-BJ': /^(\+229)\d{8}$/,
|
101
|
+
'fr-CD': /^(\+?243|0)?(8|9)\d{8}$/,
|
102
|
+
'fr-CM': /^(\+?237)6[0-9]{8}$/,
|
103
|
+
'fr-FR': /^(\+?33|0)[67]\d{8}$/,
|
104
|
+
'fr-GF': /^(\+?594|0|00594)[67]\d{8}$/,
|
105
|
+
'fr-GP': /^(\+?590|0|00590)[67]\d{8}$/,
|
106
|
+
'fr-MQ': /^(\+?596|0|00596)[67]\d{8}$/,
|
107
|
+
'fr-PF': /^(\+?689)?8[789]\d{6}$/,
|
108
|
+
'fr-RE': /^(\+?262|0|00262)[67]\d{8}$/,
|
109
|
+
'fr-WF': /^(\+681)?\d{6}$/,
|
110
|
+
'he-IL': /^(\+972|0)([23489]|5[012345689]|77)[1-9]\d{6}$/,
|
111
|
+
'hu-HU': /^(\+?36|06)(20|30|31|50|70)\d{7}$/,
|
112
|
+
'id-ID': /^(\+?62|0)8(1[123456789]|2[1238]|3[1238]|5[12356789]|7[78]|9[56789]|8[123456789])([\s?|\d]{5,11})$/,
|
113
|
+
'ir-IR': /^(\+98|0)?9\d{9}$/,
|
114
|
+
'it-IT': /^(\+?39)?\s?3\d{2} ?\d{6,7}$/,
|
115
|
+
'it-SM': /^((\+378)|(0549)|(\+390549)|(\+3780549))?6\d{5,9}$/,
|
116
|
+
'ja-JP': /^(\+81[ \-]?(\(0\))?|0)[6789]0[ \-]?\d{4}[ \-]?\d{4}$/,
|
117
|
+
'ka-GE': /^(\+?995)?(79\d{7}|5\d{8})$/,
|
118
|
+
'kk-KZ': /^(\+?7|8)?7\d{9}$/,
|
119
|
+
'kl-GL': /^(\+?299)?\s?\d{2}\s?\d{2}\s?\d{2}$/,
|
120
|
+
'ko-KR': /^((\+?82)[ \-]?)?0?1([0|1|6|7|8|9]{1})[ \-]?\d{3,4}[ \-]?\d{4}$/,
|
121
|
+
'ky-KG': /^(\+?7\s?\+?7|0)\s?\d{2}\s?\d{3}\s?\d{4}$/,
|
122
|
+
'lt-LT': /^(\+370|8)\d{8}$/,
|
123
|
+
'lv-LV': /^(\+?371)2\d{7}$/,
|
124
|
+
'mg-MG': /^((\+?261|0)(2|3)\d)?\d{7}$/,
|
125
|
+
'mn-MN': /^(\+|00|011)?976(77|81|88|91|94|95|96|99)\d{6}$/,
|
126
|
+
'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}$/,
|
127
|
+
'ms-MY': /^(\+?60|0)1(([0145](-|\s)?\d{7,8})|([236-9](-|\s)?\d{7}))$/,
|
128
|
+
'mz-MZ': /^(\+?258)?8[234567]\d{7}$/,
|
129
|
+
'nb-NO': /^(\+?47)?[49]\d{7}$/,
|
130
|
+
'ne-NP': /^(\+?977)?9[78]\d{8}$/,
|
131
|
+
'nl-BE': /^(\+?32|0)4\d{8}$/,
|
132
|
+
'nl-NL': /^(((\+|00)?31\(0\))|((\+|00)?31)|0)6{1}\d{8}$/,
|
133
|
+
'nl-AW': /^(\+)?297(56|59|64|73|74|99)\d{5}$/,
|
134
|
+
'nn-NO': /^(\+?47)?[49]\d{7}$/,
|
135
|
+
'pl-PL': /^(\+?48)? ?([5-8]\d|45) ?\d{3} ?\d{2} ?\d{2}$/,
|
136
|
+
'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}))$/,
|
137
|
+
'pt-PT': /^(\+?351)?9[1236]\d{7}$/,
|
138
|
+
'pt-AO': /^(\+244)\d{9}$/,
|
139
|
+
'ro-MD': /^(\+?373|0)((6(0|1|2|6|7|8|9))|(7(6|7|8|9)))\d{6}$/,
|
140
|
+
'ro-RO': /^(\+?40|0)\s?7\d{2}(\/|\s|\.|-)?\d{3}(\s|\.|-)?\d{3}$/,
|
141
|
+
'ru-RU': /^(\+?7|8)?9\d{9}$/,
|
142
|
+
'si-LK': /^(?:0|94|\+94)?(7(0|1|2|4|5|6|7|8)( |-)?)\d{7}$/,
|
143
|
+
'sl-SI': /^(\+386\s?|0)(\d{1}\s?\d{3}\s?\d{2}\s?\d{2}|\d{2}\s?\d{3}\s?\d{3})$/,
|
144
|
+
'sk-SK': /^(\+?421)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/,
|
145
|
+
'so-SO': /^(\+?252|0)((6[0-9])\d{7}|(7[1-9])\d{7})$/,
|
146
|
+
'sq-AL': /^(\+355|0)6[789]\d{6}$/,
|
147
|
+
'sr-RS': /^(\+3816|06)[- \d]{5,9}$/,
|
148
|
+
'sv-SE': /^(\+?46|0)[\s\-]?7[\s\-]?[02369]([\s\-]?\d){7}$/,
|
149
|
+
'tg-TJ': /^(\+?992)?[5][5]\d{7}$/,
|
150
|
+
'th-TH': /^(\+66|66|0)\d{9}$/,
|
151
|
+
'tr-TR': /^(\+?90|0)?5\d{9}$/,
|
152
|
+
'tk-TM': /^(\+993|993|8)\d{8}$/,
|
153
|
+
'uk-UA': /^(\+?38|8)?0\d{9}$/,
|
154
|
+
'uz-UZ': /^(\+?998)?(6[125-79]|7[1-69]|88|9\d)\d{7}$/,
|
155
|
+
'vi-VN': /^((\+?84)|0)((3([2-9]))|(5([25689]))|(7([0|6-9]))|(8([1-9]))|(9([0-9])))([0-9]{7})$/,
|
156
|
+
'zh-CN': /^((\+|00)86)?(1[3-9]|9[28])\d{9}$/,
|
157
|
+
'zh-TW': /^(\+?886\-?|0)?9\d{8}$/,
|
158
|
+
'dz-BT': /^(\+?975|0)?(17|16|77|02)\d{6}$/,
|
159
|
+
'ar-YE': /^(((\+|00)9677|0?7)[0137]\d{7}|((\+|00)967|0)[1-7]\d{6})$/,
|
160
|
+
'ar-EH': /^(\+?212|0)[\s\-]?(5288|5289)[\s\-]?\d{5}$/,
|
161
|
+
'fa-AF': /^(\+93|0)?(2{1}[0-8]{1}|[3-5]{1}[0-4]{1})(\d{7})$/
|
162
|
+
};
|
163
|
+
/* eslint-enable max-len */
|
164
|
+
|
165
|
+
// aliases
|
166
|
+
phones['en-CA'] = phones['en-US'];
|
167
|
+
phones['fr-CA'] = phones['en-CA'];
|
168
|
+
phones['fr-BE'] = phones['nl-BE'];
|
169
|
+
phones['zh-HK'] = phones['en-HK'];
|
170
|
+
phones['zh-MO'] = phones['en-MO'];
|
171
|
+
phones['ga-IE'] = phones['en-IE'];
|
172
|
+
phones['fr-CH'] = phones['de-CH'];
|
173
|
+
phones['it-CH'] = phones['fr-CH'];
|
174
|
+
export default function isMobilePhone(str, locale, options) {
|
175
|
+
assertString(str);
|
176
|
+
if (options && options.strictMode && !str.startsWith('+')) {
|
177
|
+
return false;
|
178
|
+
}
|
179
|
+
if (Array.isArray(locale)) {
|
180
|
+
return locale.some(function (key) {
|
181
|
+
// https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md#ignoring-code-for-coverage-purposes
|
182
|
+
// istanbul ignore else
|
183
|
+
if (phones.hasOwnProperty(key)) {
|
184
|
+
var phone = phones[key];
|
185
|
+
if (phone.test(str)) {
|
186
|
+
return true;
|
187
|
+
}
|
188
|
+
}
|
189
|
+
return false;
|
190
|
+
});
|
191
|
+
} else if (locale in phones) {
|
192
|
+
return phones[locale].test(str);
|
193
|
+
// alias falsey locale as 'any'
|
194
|
+
} else if (!locale || locale === 'any') {
|
195
|
+
for (var key in phones) {
|
196
|
+
// istanbul ignore else
|
197
|
+
if (phones.hasOwnProperty(key)) {
|
198
|
+
var phone = phones[key];
|
199
|
+
if (phone.test(str)) {
|
200
|
+
return true;
|
201
|
+
}
|
202
|
+
}
|
203
|
+
}
|
204
|
+
return false;
|
205
|
+
}
|
206
|
+
throw new Error("Invalid locale '".concat(locale, "'"));
|
207
|
+
}
|
208
|
+
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
|
+
}
|