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
package/es/lib/alpha.js
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
export var alpha = {
|
|
2
|
+
'en-US': /^[A-Z]+$/i,
|
|
3
|
+
'az-AZ': /^[A-VXYZÇƏĞİıÖŞÜ]+$/i,
|
|
4
|
+
'bg-BG': /^[А-Я]+$/i,
|
|
5
|
+
'cs-CZ': /^[A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]+$/i,
|
|
6
|
+
'da-DK': /^[A-ZÆØÅ]+$/i,
|
|
7
|
+
'de-DE': /^[A-ZÄÖÜß]+$/i,
|
|
8
|
+
'el-GR': /^[Α-ώ]+$/i,
|
|
9
|
+
'es-ES': /^[A-ZÁÉÍÑÓÚÜ]+$/i,
|
|
10
|
+
'fa-IR': /^[ابپتثجچحخدذرزژسشصضطظعغفقکگلمنوهی]+$/i,
|
|
11
|
+
'fi-FI': /^[A-ZÅÄÖ]+$/i,
|
|
12
|
+
'fr-FR': /^[A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i,
|
|
13
|
+
'it-IT': /^[A-ZÀÉÈÌÎÓÒÙ]+$/i,
|
|
14
|
+
'ja-JP': /^[ぁ-んァ-ヶヲ-゚一-龠ー・。、]+$/i,
|
|
15
|
+
'nb-NO': /^[A-ZÆØÅ]+$/i,
|
|
16
|
+
'nl-NL': /^[A-ZÁÉËÏÓÖÜÚ]+$/i,
|
|
17
|
+
'nn-NO': /^[A-ZÆØÅ]+$/i,
|
|
18
|
+
'hu-HU': /^[A-ZÁÉÍÓÖŐÚÜŰ]+$/i,
|
|
19
|
+
'pl-PL': /^[A-ZĄĆĘŚŁŃÓŻŹ]+$/i,
|
|
20
|
+
'pt-PT': /^[A-ZÃÁÀÂÄÇÉÊËÍÏÕÓÔÖÚÜ]+$/i,
|
|
21
|
+
'ru-RU': /^[А-ЯЁ]+$/i,
|
|
22
|
+
'kk-KZ': /^[А-ЯЁ\u04D8\u04B0\u0406\u04A2\u0492\u04AE\u049A\u04E8\u04BA]+$/i,
|
|
23
|
+
'sl-SI': /^[A-ZČĆĐŠŽ]+$/i,
|
|
24
|
+
'sk-SK': /^[A-ZÁČĎÉÍŇÓŠŤÚÝŽĹŔĽÄÔ]+$/i,
|
|
25
|
+
'sr-RS@latin': /^[A-ZČĆŽŠĐ]+$/i,
|
|
26
|
+
'sr-RS': /^[А-ЯЂЈЉЊЋЏ]+$/i,
|
|
27
|
+
'sv-SE': /^[A-ZÅÄÖ]+$/i,
|
|
28
|
+
'th-TH': /^[ก-๐\s]+$/i,
|
|
29
|
+
'tr-TR': /^[A-ZÇĞİıÖŞÜ]+$/i,
|
|
30
|
+
'uk-UA': /^[А-ЩЬЮЯЄIЇҐі]+$/i,
|
|
31
|
+
'vi-VN': /^[A-ZÀÁẠẢÃÂẦẤẬẨẪĂẰẮẶẲẴĐÈÉẸẺẼÊỀẾỆỂỄÌÍỊỈĨÒÓỌỎÕÔỒỐỘỔỖƠỜỚỢỞỠÙÚỤỦŨƯỪỨỰỬỮỲÝỴỶỸ]+$/i,
|
|
32
|
+
'ko-KR': /^[ㄱ-ㅎㅏ-ㅣ가-힣]*$/,
|
|
33
|
+
'ku-IQ': /^[ئابپتجچحخدرڕزژسشعغفڤقکگلڵمنوۆھەیێيطؤثآإأكضصةظذ]+$/i,
|
|
34
|
+
ar: /^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/,
|
|
35
|
+
he: /^[א-ת]+$/,
|
|
36
|
+
fa: /^['آاءأؤئبپتثجچحخدذرزژسشصضطظعغفقکگلمنوهةی']+$/i,
|
|
37
|
+
bn: /^['ঀঁংঃঅআইঈউঊঋঌএঐওঔকখগঘঙচছজঝঞটঠডঢণতথদধনপফবভমযরলশষসহ়ঽািীুূৃৄেৈোৌ্ৎৗড়ঢ়য়ৠৡৢৣৰৱ৲৳৴৵৶৷৸৹৺৻']+$/,
|
|
38
|
+
eo: /^[ABCĈD-GĜHĤIJĴK-PRSŜTUŬVZ]+$/i,
|
|
39
|
+
'hi-IN': /^[\u0900-\u0961]+[\u0972-\u097F]*$/i,
|
|
40
|
+
'si-LK': /^[\u0D80-\u0DFF]+$/,
|
|
41
|
+
'ta-IN': /^[\u0B80-\u0BFF]+$/i,
|
|
42
|
+
'te-IN': /^[\u0C00-\u0C7F]+$/i,
|
|
43
|
+
'kn-IN': /^[\u0C80-\u0CFF]+$/i,
|
|
44
|
+
'ml-IN': /^[\u0D00-\u0D7F]+$/i,
|
|
45
|
+
'gu-IN': /^[\u0A80-\u0AFF]+$/i,
|
|
46
|
+
'pa-IN': /^[\u0A00-\u0A7F]+$/i,
|
|
47
|
+
'or-IN': /^[\u0B00-\u0B7F]+$/i
|
|
48
|
+
};
|
|
49
|
+
export var alphanumeric = {
|
|
50
|
+
'en-US': /^[0-9A-Z]+$/i,
|
|
51
|
+
'az-AZ': /^[0-9A-VXYZÇƏĞİıÖŞÜ]+$/i,
|
|
52
|
+
'bg-BG': /^[0-9А-Я]+$/i,
|
|
53
|
+
'cs-CZ': /^[0-9A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]+$/i,
|
|
54
|
+
'da-DK': /^[0-9A-ZÆØÅ]+$/i,
|
|
55
|
+
'de-DE': /^[0-9A-ZÄÖÜß]+$/i,
|
|
56
|
+
'el-GR': /^[0-9Α-ω]+$/i,
|
|
57
|
+
'es-ES': /^[0-9A-ZÁÉÍÑÓÚÜ]+$/i,
|
|
58
|
+
'fi-FI': /^[0-9A-ZÅÄÖ]+$/i,
|
|
59
|
+
'fr-FR': /^[0-9A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i,
|
|
60
|
+
'it-IT': /^[0-9A-ZÀÉÈÌÎÓÒÙ]+$/i,
|
|
61
|
+
'ja-JP': /^[0-90-9ぁ-んァ-ヶヲ-゚一-龠ー・。、]+$/i,
|
|
62
|
+
'hu-HU': /^[0-9A-ZÁÉÍÓÖŐÚÜŰ]+$/i,
|
|
63
|
+
'nb-NO': /^[0-9A-ZÆØÅ]+$/i,
|
|
64
|
+
'nl-NL': /^[0-9A-ZÁÉËÏÓÖÜÚ]+$/i,
|
|
65
|
+
'nn-NO': /^[0-9A-ZÆØÅ]+$/i,
|
|
66
|
+
'pl-PL': /^[0-9A-ZĄĆĘŚŁŃÓŻŹ]+$/i,
|
|
67
|
+
'pt-PT': /^[0-9A-ZÃÁÀÂÄÇÉÊËÍÏÕÓÔÖÚÜ]+$/i,
|
|
68
|
+
'ru-RU': /^[0-9А-ЯЁ]+$/i,
|
|
69
|
+
'kk-KZ': /^[0-9А-ЯЁ\u04D8\u04B0\u0406\u04A2\u0492\u04AE\u049A\u04E8\u04BA]+$/i,
|
|
70
|
+
'sl-SI': /^[0-9A-ZČĆĐŠŽ]+$/i,
|
|
71
|
+
'sk-SK': /^[0-9A-ZÁČĎÉÍŇÓŠŤÚÝŽĹŔĽÄÔ]+$/i,
|
|
72
|
+
'sr-RS@latin': /^[0-9A-ZČĆŽŠĐ]+$/i,
|
|
73
|
+
'sr-RS': /^[0-9А-ЯЂЈЉЊЋЏ]+$/i,
|
|
74
|
+
'sv-SE': /^[0-9A-ZÅÄÖ]+$/i,
|
|
75
|
+
'th-TH': /^[ก-๙\s]+$/i,
|
|
76
|
+
'tr-TR': /^[0-9A-ZÇĞİıÖŞÜ]+$/i,
|
|
77
|
+
'uk-UA': /^[0-9А-ЩЬЮЯЄIЇҐі]+$/i,
|
|
78
|
+
'ko-KR': /^[0-9ㄱ-ㅎㅏ-ㅣ가-힣]*$/,
|
|
79
|
+
'ku-IQ': /^[٠١٢٣٤٥٦٧٨٩0-9ئابپتجچحخدرڕزژسشعغفڤقکگلڵمنوۆھەیێيطؤثآإأكضصةظذ]+$/i,
|
|
80
|
+
'vi-VN': /^[0-9A-ZÀÁẠẢÃÂẦẤẬẨẪĂẰẮẶẲẴĐÈÉẸẺẼÊỀẾỆỂỄÌÍỊỈĨÒÓỌỎÕÔỒỐỘỔỖƠỜỚỢỞỠÙÚỤỦŨƯỪỨỰỬỮỲÝỴỶỸ]+$/i,
|
|
81
|
+
ar: /^[٠١٢٣٤٥٦٧٨٩0-9ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/,
|
|
82
|
+
he: /^[0-9א-ת]+$/,
|
|
83
|
+
fa: /^['0-9آاءأؤئبپتثجچحخدذرزژسشصضطظعغفقکگلمنوهةی۱۲۳۴۵۶۷۸۹۰']+$/i,
|
|
84
|
+
bn: /^['ঀঁংঃঅআইঈউঊঋঌএঐওঔকখগঘঙচছজঝঞটঠডঢণতথদধনপফবভমযরলশষসহ়ঽািীুূৃৄেৈোৌ্ৎৗড়ঢ়য়ৠৡৢৣ০১২৩৪৫৬৭৮৯ৰৱ৲৳৴৵৶৷৸৹৺৻']+$/,
|
|
85
|
+
eo: /^[0-9ABCĈD-GĜHĤIJĴK-PRSŜTUŬVZ]+$/i,
|
|
86
|
+
'hi-IN': /^[\u0900-\u0963]+[\u0966-\u097F]*$/i,
|
|
87
|
+
'si-LK': /^[0-9\u0D80-\u0DFF]+$/,
|
|
88
|
+
'ta-IN': /^[0-9\u0B80-\u0BFF.]+$/i,
|
|
89
|
+
'te-IN': /^[0-9\u0C00-\u0C7F.]+$/i,
|
|
90
|
+
'kn-IN': /^[0-9\u0C80-\u0CFF.]+$/i,
|
|
91
|
+
'ml-IN': /^[0-9\u0D00-\u0D7F.]+$/i,
|
|
92
|
+
'gu-IN': /^[0-9\u0A80-\u0AFF.]+$/i,
|
|
93
|
+
'pa-IN': /^[0-9\u0A00-\u0A7F.]+$/i,
|
|
94
|
+
'or-IN': /^[0-9\u0B00-\u0B7F.]+$/i
|
|
95
|
+
};
|
|
96
|
+
export var decimal = {
|
|
97
|
+
'en-US': '.',
|
|
98
|
+
ar: '٫'
|
|
99
|
+
};
|
|
100
|
+
export var englishLocales = ['AU', 'GB', 'HK', 'IN', 'NZ', 'ZA', 'ZM'];
|
|
101
|
+
for (var locale, i = 0; i < englishLocales.length; i++) {
|
|
102
|
+
locale = "en-".concat(englishLocales[i]);
|
|
103
|
+
alpha[locale] = alpha['en-US'];
|
|
104
|
+
alphanumeric[locale] = alphanumeric['en-US'];
|
|
105
|
+
decimal[locale] = decimal['en-US'];
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Source: http://www.localeplanet.com/java/
|
|
109
|
+
export var arabicLocales = ['AE', 'BH', 'DZ', 'EG', 'IQ', 'JO', 'KW', 'LB', 'LY', 'MA', 'QM', 'QA', 'SA', 'SD', 'SY', 'TN', 'YE'];
|
|
110
|
+
for (var _locale, _i = 0; _i < arabicLocales.length; _i++) {
|
|
111
|
+
_locale = "ar-".concat(arabicLocales[_i]);
|
|
112
|
+
alpha[_locale] = alpha.ar;
|
|
113
|
+
alphanumeric[_locale] = alphanumeric.ar;
|
|
114
|
+
decimal[_locale] = decimal.ar;
|
|
115
|
+
}
|
|
116
|
+
export var farsiLocales = ['IR', 'AF'];
|
|
117
|
+
for (var _locale2, _i2 = 0; _i2 < farsiLocales.length; _i2++) {
|
|
118
|
+
_locale2 = "fa-".concat(farsiLocales[_i2]);
|
|
119
|
+
alphanumeric[_locale2] = alphanumeric.fa;
|
|
120
|
+
decimal[_locale2] = decimal.ar;
|
|
121
|
+
}
|
|
122
|
+
export var bengaliLocales = ['BD', 'IN'];
|
|
123
|
+
for (var _locale3, _i3 = 0; _i3 < bengaliLocales.length; _i3++) {
|
|
124
|
+
_locale3 = "bn-".concat(bengaliLocales[_i3]);
|
|
125
|
+
alpha[_locale3] = alpha.bn;
|
|
126
|
+
alphanumeric[_locale3] = alphanumeric.bn;
|
|
127
|
+
decimal[_locale3] = decimal['en-US'];
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Source: https://en.wikipedia.org/wiki/Decimal_mark
|
|
131
|
+
export var dotDecimal = ['ar-EG', 'ar-LB', 'ar-LY'];
|
|
132
|
+
export var commaDecimal = ['bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en-ZM', 'eo', 'es-ES', 'fr-CA', 'fr-FR', 'gu-IN', 'hi-IN', 'hu-HU', 'id-ID', 'it-IT', 'kk-KZ', 'kn-IN', 'ku-IQ', 'ml-IN', 'nb-NO', 'nl-NL', 'nn-NO', 'or-IN', 'pa-IN', 'pl-PL', 'pt-PT', 'ru-RU', 'si-LK', 'sl-SI', 'sr-RS', 'sr-RS@latin', 'sv-SE', 'ta-IN', 'te-IN', 'tr-TR', 'uk-UA', 'vi-VN'];
|
|
133
|
+
for (var _i4 = 0; _i4 < dotDecimal.length; _i4++) {
|
|
134
|
+
decimal[dotDecimal[_i4]] = decimal['en-US'];
|
|
135
|
+
}
|
|
136
|
+
for (var _i5 = 0; _i5 < commaDecimal.length; _i5++) {
|
|
137
|
+
decimal[commaDecimal[_i5]] = ',';
|
|
138
|
+
}
|
|
139
|
+
alpha['fr-CA'] = alpha['fr-FR'];
|
|
140
|
+
alphanumeric['fr-CA'] = alphanumeric['fr-FR'];
|
|
141
|
+
alpha['pt-BR'] = alpha['pt-PT'];
|
|
142
|
+
alphanumeric['pt-BR'] = alphanumeric['pt-PT'];
|
|
143
|
+
decimal['pt-BR'] = decimal['pt-PT'];
|
|
144
|
+
|
|
145
|
+
// see #862
|
|
146
|
+
alpha['pl-Pl'] = alpha['pl-PL'];
|
|
147
|
+
alphanumeric['pl-Pl'] = alphanumeric['pl-PL'];
|
|
148
|
+
decimal['pl-Pl'] = decimal['pl-PL'];
|
|
149
|
+
|
|
150
|
+
// see #1455
|
|
151
|
+
alpha['fa-AF'] = alpha.fa;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import assertString from './util/assertString';
|
|
2
|
+
import toString from './util/toString';
|
|
3
|
+
import merge from './util/merge';
|
|
4
|
+
var defaultContainsOptions = {
|
|
5
|
+
ignoreCase: false,
|
|
6
|
+
minOccurrences: 1
|
|
7
|
+
};
|
|
8
|
+
export default function contains(str, elem, options) {
|
|
9
|
+
assertString(str);
|
|
10
|
+
options = merge(options, defaultContainsOptions);
|
|
11
|
+
if (options.ignoreCase) {
|
|
12
|
+
return str.toLowerCase().split(toString(elem).toLowerCase()).length > options.minOccurrences;
|
|
13
|
+
}
|
|
14
|
+
return str.split(toString(elem)).length > options.minOccurrences;
|
|
15
|
+
}
|
package/es/lib/equals.js
ADDED
package/es/lib/escape.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import assertString from './util/assertString';
|
|
2
|
+
export default function escape(str) {
|
|
3
|
+
assertString(str);
|
|
4
|
+
return str.replace(/&/g, '&').replace(/"/g, '"').replace(/'/g, ''').replace(/</g, '<').replace(/>/g, '>').replace(/\//g, '/').replace(/\\/g, '\').replace(/`/g, '`');
|
|
5
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import assertString from './util/assertString';
|
|
2
|
+
|
|
3
|
+
// http://www.brainjar.com/js/validation/
|
|
4
|
+
// https://www.aba.com/news-research/research-analysis/routing-number-policy-procedures
|
|
5
|
+
// series reserved for future use are excluded
|
|
6
|
+
var isRoutingReg = /^(?!(1[3-9])|(20)|(3[3-9])|(4[0-9])|(5[0-9])|(60)|(7[3-9])|(8[1-9])|(9[0-2])|(9[3-9]))[0-9]{9}$/;
|
|
7
|
+
export default function isAbaRouting(str) {
|
|
8
|
+
assertString(str);
|
|
9
|
+
if (!isRoutingReg.test(str)) return false;
|
|
10
|
+
var checkSumVal = 0;
|
|
11
|
+
for (var i = 0; i < str.length; i++) {
|
|
12
|
+
if (i % 3 === 0) checkSumVal += str[i] * 3;else if (i % 3 === 1) checkSumVal += str[i] * 7;else checkSumVal += str[i] * 1;
|
|
13
|
+
}
|
|
14
|
+
return checkSumVal % 10 === 0;
|
|
15
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
import toDate from './toDate';
|
|
3
|
+
export default function isAfter(date, options) {
|
|
4
|
+
// For backwards compatibility:
|
|
5
|
+
// isAfter(str [, date]), i.e. `options` could be used as argument for the legacy `date`
|
|
6
|
+
var comparisonDate = (_typeof(options) === 'object' ? options.comparisonDate : options) || Date().toString();
|
|
7
|
+
var comparison = toDate(comparisonDate);
|
|
8
|
+
var original = toDate(date);
|
|
9
|
+
return !!(original && comparison && original > comparison);
|
|
10
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import assertString from './util/assertString';
|
|
2
|
+
import { alpha } from './alpha';
|
|
3
|
+
export default function isAlpha(_str) {
|
|
4
|
+
var locale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'en-US';
|
|
5
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
6
|
+
assertString(_str);
|
|
7
|
+
var str = _str;
|
|
8
|
+
var ignore = options.ignore;
|
|
9
|
+
if (ignore) {
|
|
10
|
+
if (ignore instanceof RegExp) {
|
|
11
|
+
str = str.replace(ignore, '');
|
|
12
|
+
} else if (typeof ignore === 'string') {
|
|
13
|
+
str = str.replace(new RegExp("[".concat(ignore.replace(/[-[\]{}()*+?.,\\^$|#\\s]/g, '\\$&'), "]"), 'g'), ''); // escape regex for ignore
|
|
14
|
+
} else {
|
|
15
|
+
throw new Error('ignore should be instance of a String or RegExp');
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
if (locale in alpha) {
|
|
19
|
+
return alpha[locale].test(str);
|
|
20
|
+
}
|
|
21
|
+
throw new Error("Invalid locale '".concat(locale, "'"));
|
|
22
|
+
}
|
|
23
|
+
export var locales = Object.keys(alpha);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import assertString from './util/assertString';
|
|
2
|
+
import { alphanumeric } from './alpha';
|
|
3
|
+
export default function isAlphanumeric(_str) {
|
|
4
|
+
var locale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'en-US';
|
|
5
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
6
|
+
assertString(_str);
|
|
7
|
+
var str = _str;
|
|
8
|
+
var ignore = options.ignore;
|
|
9
|
+
if (ignore) {
|
|
10
|
+
if (ignore instanceof RegExp) {
|
|
11
|
+
str = str.replace(ignore, '');
|
|
12
|
+
} else if (typeof ignore === 'string') {
|
|
13
|
+
str = str.replace(new RegExp("[".concat(ignore.replace(/[-[\]{}()*+?.,\\^$|#\\s]/g, '\\$&'), "]"), 'g'), ''); // escape regex for ignore
|
|
14
|
+
} else {
|
|
15
|
+
throw new Error('ignore should be instance of a String or RegExp');
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
if (locale in alphanumeric) {
|
|
19
|
+
return alphanumeric[locale].test(str);
|
|
20
|
+
}
|
|
21
|
+
throw new Error("Invalid locale '".concat(locale, "'"));
|
|
22
|
+
}
|
|
23
|
+
export var locales = Object.keys(alphanumeric);
|
package/es/lib/isBIC.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import assertString from './util/assertString';
|
|
2
|
+
import { CountryCodes } from './isISO31661Alpha2';
|
|
3
|
+
|
|
4
|
+
// https://en.wikipedia.org/wiki/ISO_9362
|
|
5
|
+
var isBICReg = /^[A-Za-z]{6}[A-Za-z0-9]{2}([A-Za-z0-9]{3})?$/;
|
|
6
|
+
export default function isBIC(str) {
|
|
7
|
+
assertString(str);
|
|
8
|
+
|
|
9
|
+
// toUpperCase() should be removed when a new major version goes out that changes
|
|
10
|
+
// the regex to [A-Z] (per the spec).
|
|
11
|
+
var countryCode = str.slice(4, 6).toUpperCase();
|
|
12
|
+
if (!CountryCodes.has(countryCode) && countryCode !== 'XK') {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
return isBICReg.test(str);
|
|
16
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import assertString from './util/assertString';
|
|
2
|
+
import merge from './util/merge';
|
|
3
|
+
var base32 = /^[A-Z2-7]+=*$/;
|
|
4
|
+
var crockfordBase32 = /^[A-HJKMNP-TV-Z0-9]+$/;
|
|
5
|
+
var defaultBase32Options = {
|
|
6
|
+
crockford: false
|
|
7
|
+
};
|
|
8
|
+
export default function isBase32(str, options) {
|
|
9
|
+
assertString(str);
|
|
10
|
+
options = merge(options, defaultBase32Options);
|
|
11
|
+
if (options.crockford) {
|
|
12
|
+
return crockfordBase32.test(str);
|
|
13
|
+
}
|
|
14
|
+
return str.length % 8 === 0 && base32.test(str);
|
|
15
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import assertString from './util/assertString';
|
|
2
|
+
|
|
3
|
+
// Accepted chars - 123456789ABCDEFGH JKLMN PQRSTUVWXYZabcdefghijk mnopqrstuvwxyz
|
|
4
|
+
var base58Reg = /^[A-HJ-NP-Za-km-z1-9]*$/;
|
|
5
|
+
export default function isBase58(str) {
|
|
6
|
+
assertString(str);
|
|
7
|
+
return base58Reg.test(str);
|
|
8
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import assertString from './util/assertString';
|
|
2
|
+
import merge from './util/merge';
|
|
3
|
+
var base64WithPadding = /^[A-Za-z0-9+/]+={0,2}$/;
|
|
4
|
+
var base64WithoutPadding = /^[A-Za-z0-9+/]+$/;
|
|
5
|
+
var base64UrlWithPadding = /^[A-Za-z0-9_-]+={0,2}$/;
|
|
6
|
+
var base64UrlWithoutPadding = /^[A-Za-z0-9_-]+$/;
|
|
7
|
+
export default function isBase64(str, options) {
|
|
8
|
+
var _options;
|
|
9
|
+
assertString(str);
|
|
10
|
+
options = merge(options, {
|
|
11
|
+
urlSafe: false,
|
|
12
|
+
padding: !((_options = options) !== null && _options !== void 0 && _options.urlSafe)
|
|
13
|
+
});
|
|
14
|
+
if (str === '') return true;
|
|
15
|
+
if (options.padding && str.length % 4 !== 0) return false;
|
|
16
|
+
var regex;
|
|
17
|
+
if (options.urlSafe) {
|
|
18
|
+
regex = options.padding ? base64UrlWithPadding : base64UrlWithoutPadding;
|
|
19
|
+
} else {
|
|
20
|
+
regex = options.padding ? base64WithPadding : base64WithoutPadding;
|
|
21
|
+
}
|
|
22
|
+
return (!options.padding || str.length % 4 === 0) && regex.test(str);
|
|
23
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
import toDate from './toDate';
|
|
3
|
+
export default function isBefore(date, options) {
|
|
4
|
+
// For backwards compatibility:
|
|
5
|
+
// isBefore(str [, date]), i.e. `options` could be used as argument for the legacy `date`
|
|
6
|
+
var comparisonDate = (_typeof(options) === 'object' ? options.comparisonDate : options) || Date().toString();
|
|
7
|
+
var comparison = toDate(comparisonDate);
|
|
8
|
+
var original = toDate(date);
|
|
9
|
+
return !!(original && comparison && original < comparison);
|
|
10
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import assertString from './util/assertString';
|
|
2
|
+
import includes from './util/includesArray';
|
|
3
|
+
var defaultOptions = {
|
|
4
|
+
loose: false
|
|
5
|
+
};
|
|
6
|
+
var strictBooleans = ['true', 'false', '1', '0'];
|
|
7
|
+
var looseBooleans = [].concat(strictBooleans, ['yes', 'no']);
|
|
8
|
+
export default function isBoolean(str) {
|
|
9
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultOptions;
|
|
10
|
+
assertString(str);
|
|
11
|
+
if (options.loose) {
|
|
12
|
+
return includes(looseBooleans, str.toLowerCase());
|
|
13
|
+
}
|
|
14
|
+
return includes(strictBooleans, str);
|
|
15
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import assertString from './util/assertString';
|
|
2
|
+
var bech32 = /^(bc1|tb1|bc1p|tb1p)[ac-hj-np-z02-9]{39,58}$/;
|
|
3
|
+
var base58 = /^(1|2|3|m)[A-HJ-NP-Za-km-z1-9]{25,39}$/;
|
|
4
|
+
export default function isBtcAddress(str) {
|
|
5
|
+
assertString(str);
|
|
6
|
+
return bech32.test(str) || base58.test(str);
|
|
7
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
import assertString from './util/assertString';
|
|
3
|
+
|
|
4
|
+
/* eslint-disable prefer-rest-params */
|
|
5
|
+
export default function isByteLength(str, options) {
|
|
6
|
+
assertString(str);
|
|
7
|
+
var min;
|
|
8
|
+
var max;
|
|
9
|
+
if (_typeof(options) === 'object') {
|
|
10
|
+
min = options.min || 0;
|
|
11
|
+
max = options.max;
|
|
12
|
+
} else {
|
|
13
|
+
// backwards compatibility: isByteLength(str, min [, max])
|
|
14
|
+
min = arguments[1];
|
|
15
|
+
max = arguments[2];
|
|
16
|
+
}
|
|
17
|
+
var len = encodeURI(str).split(/%..|./).length - 1;
|
|
18
|
+
return len >= min && (typeof max === 'undefined' || len <= max);
|
|
19
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import assertString from './util/assertString';
|
|
2
|
+
import isLuhnValid from './isLuhnNumber';
|
|
3
|
+
var cards = {
|
|
4
|
+
amex: /^3[47][0-9]{13}$/,
|
|
5
|
+
dinersclub: /^3(?:0[0-5]|[68][0-9])[0-9]{11}$/,
|
|
6
|
+
discover: /^6(?:011|5[0-9][0-9])[0-9]{12,15}$/,
|
|
7
|
+
jcb: /^(?:2131|1800|35\d{3})\d{11}$/,
|
|
8
|
+
mastercard: /^5[1-5][0-9]{2}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}$/,
|
|
9
|
+
// /^[25][1-7][0-9]{14}$/;
|
|
10
|
+
unionpay: /^(6[27][0-9]{14}|^(81[0-9]{14,17}))$/,
|
|
11
|
+
visa: /^(?:4[0-9]{12})(?:[0-9]{3,6})?$/
|
|
12
|
+
};
|
|
13
|
+
var allCards = function () {
|
|
14
|
+
var tmpCardsArray = [];
|
|
15
|
+
for (var cardProvider in cards) {
|
|
16
|
+
// istanbul ignore else
|
|
17
|
+
if (cards.hasOwnProperty(cardProvider)) {
|
|
18
|
+
tmpCardsArray.push(cards[cardProvider]);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return tmpCardsArray;
|
|
22
|
+
}();
|
|
23
|
+
export default function isCreditCard(card) {
|
|
24
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
25
|
+
assertString(card);
|
|
26
|
+
var provider = options.provider;
|
|
27
|
+
var sanitized = card.replace(/[- ]+/g, '');
|
|
28
|
+
if (provider && provider.toLowerCase() in cards) {
|
|
29
|
+
// specific provider in the list
|
|
30
|
+
if (!cards[provider.toLowerCase()].test(sanitized)) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
} else if (provider && !(provider.toLowerCase() in cards)) {
|
|
34
|
+
/* specific provider not in the list */
|
|
35
|
+
throw new Error("".concat(provider, " is not a valid credit card provider."));
|
|
36
|
+
} else if (!allCards.some(function (cardProvider) {
|
|
37
|
+
return cardProvider.test(sanitized);
|
|
38
|
+
})) {
|
|
39
|
+
// no specific provider
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
return isLuhnValid(card);
|
|
43
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import merge from './util/merge';
|
|
2
|
+
import assertString from './util/assertString';
|
|
3
|
+
function currencyRegex(options) {
|
|
4
|
+
var decimal_digits = "\\d{".concat(options.digits_after_decimal[0], "}");
|
|
5
|
+
options.digits_after_decimal.forEach(function (digit, index) {
|
|
6
|
+
if (index !== 0) decimal_digits = "".concat(decimal_digits, "|\\d{").concat(digit, "}");
|
|
7
|
+
});
|
|
8
|
+
var symbol = "(".concat(options.symbol.replace(/\W/, function (m) {
|
|
9
|
+
return "\\".concat(m);
|
|
10
|
+
}), ")").concat(options.require_symbol ? '' : '?'),
|
|
11
|
+
negative = '-?',
|
|
12
|
+
whole_dollar_amount_without_sep = '[1-9]\\d*',
|
|
13
|
+
whole_dollar_amount_with_sep = "[1-9]\\d{0,2}(\\".concat(options.thousands_separator, "\\d{3})*"),
|
|
14
|
+
valid_whole_dollar_amounts = ['0', whole_dollar_amount_without_sep, whole_dollar_amount_with_sep],
|
|
15
|
+
whole_dollar_amount = "(".concat(valid_whole_dollar_amounts.join('|'), ")?"),
|
|
16
|
+
decimal_amount = "(\\".concat(options.decimal_separator, "(").concat(decimal_digits, "))").concat(options.require_decimal ? '' : '?');
|
|
17
|
+
var pattern = whole_dollar_amount + (options.allow_decimal || options.require_decimal ? decimal_amount : '');
|
|
18
|
+
|
|
19
|
+
// default is negative sign before symbol, but there are two other options (besides parens)
|
|
20
|
+
if (options.allow_negatives && !options.parens_for_negatives) {
|
|
21
|
+
if (options.negative_sign_after_digits) {
|
|
22
|
+
pattern += negative;
|
|
23
|
+
} else if (options.negative_sign_before_digits) {
|
|
24
|
+
pattern = negative + pattern;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// South African Rand, for example, uses R 123 (space) and R-123 (no space)
|
|
29
|
+
if (options.allow_negative_sign_placeholder) {
|
|
30
|
+
pattern = "( (?!\\-))?".concat(pattern);
|
|
31
|
+
} else if (options.allow_space_after_symbol) {
|
|
32
|
+
pattern = " ?".concat(pattern);
|
|
33
|
+
} else if (options.allow_space_after_digits) {
|
|
34
|
+
pattern += '( (?!$))?';
|
|
35
|
+
}
|
|
36
|
+
if (options.symbol_after_digits) {
|
|
37
|
+
pattern += symbol;
|
|
38
|
+
} else {
|
|
39
|
+
pattern = symbol + pattern;
|
|
40
|
+
}
|
|
41
|
+
if (options.allow_negatives) {
|
|
42
|
+
if (options.parens_for_negatives) {
|
|
43
|
+
pattern = "(\\(".concat(pattern, "\\)|").concat(pattern, ")");
|
|
44
|
+
} else if (!(options.negative_sign_before_digits || options.negative_sign_after_digits)) {
|
|
45
|
+
pattern = negative + pattern;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// ensure there's a dollar and/or decimal amount, and that
|
|
50
|
+
// it doesn't start with a space or a negative sign followed by a space
|
|
51
|
+
return new RegExp("^(?!-? )(?=.*\\d)".concat(pattern, "$"));
|
|
52
|
+
}
|
|
53
|
+
var default_currency_options = {
|
|
54
|
+
symbol: '$',
|
|
55
|
+
require_symbol: false,
|
|
56
|
+
allow_space_after_symbol: false,
|
|
57
|
+
symbol_after_digits: false,
|
|
58
|
+
allow_negatives: true,
|
|
59
|
+
parens_for_negatives: false,
|
|
60
|
+
negative_sign_before_digits: false,
|
|
61
|
+
negative_sign_after_digits: false,
|
|
62
|
+
allow_negative_sign_placeholder: false,
|
|
63
|
+
thousands_separator: ',',
|
|
64
|
+
decimal_separator: '.',
|
|
65
|
+
allow_decimal: true,
|
|
66
|
+
require_decimal: false,
|
|
67
|
+
digits_after_decimal: [2],
|
|
68
|
+
allow_space_after_digits: false
|
|
69
|
+
};
|
|
70
|
+
export default function isCurrency(str, options) {
|
|
71
|
+
assertString(str);
|
|
72
|
+
options = merge(options, default_currency_options);
|
|
73
|
+
return currencyRegex(options).test(str);
|
|
74
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import assertString from './util/assertString';
|
|
2
|
+
var validMediaType = /^[a-z]+\/[a-z0-9\-\+\._]+$/i;
|
|
3
|
+
var validAttribute = /^[a-z\-]+=[a-z0-9\-]+$/i;
|
|
4
|
+
var validData = /^[a-z0-9!\$&'\(\)\*\+,;=\-\._~:@\/\?%\s]*$/i;
|
|
5
|
+
export default function isDataURI(str) {
|
|
6
|
+
assertString(str);
|
|
7
|
+
var data = str.split(',');
|
|
8
|
+
if (data.length < 2) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
var attributes = data.shift().trim().split(';');
|
|
12
|
+
var schemeAndMediaType = attributes.shift();
|
|
13
|
+
if (schemeAndMediaType.slice(0, 5) !== 'data:') {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
var mediaType = schemeAndMediaType.slice(5);
|
|
17
|
+
if (mediaType !== '' && !validMediaType.test(mediaType)) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
for (var i = 0; i < attributes.length; i++) {
|
|
21
|
+
if (!(i === attributes.length - 1 && attributes[i].toLowerCase() === 'base64') && !validAttribute.test(attributes[i])) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
for (var _i = 0; _i < data.length; _i++) {
|
|
26
|
+
if (!validData.test(data[_i])) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return true;
|
|
31
|
+
}
|
package/es/lib/isDate.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
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 merge from './util/merge';
|
|
9
|
+
var default_date_options = {
|
|
10
|
+
format: 'YYYY/MM/DD',
|
|
11
|
+
delimiters: ['/', '-'],
|
|
12
|
+
strictMode: false
|
|
13
|
+
};
|
|
14
|
+
function isValidFormat(format) {
|
|
15
|
+
return /(^(y{4}|y{2})[.\/-](m{1,2})[.\/-](d{1,2})$)|(^(m{1,2})[.\/-](d{1,2})[.\/-]((y{4}|y{2})$))|(^(d{1,2})[.\/-](m{1,2})[.\/-]((y{4}|y{2})$))/gi.test(format);
|
|
16
|
+
}
|
|
17
|
+
function zip(date, format) {
|
|
18
|
+
var zippedArr = [],
|
|
19
|
+
len = Math.max(date.length, format.length);
|
|
20
|
+
for (var i = 0; i < len; i++) {
|
|
21
|
+
zippedArr.push([date[i], format[i]]);
|
|
22
|
+
}
|
|
23
|
+
return zippedArr;
|
|
24
|
+
}
|
|
25
|
+
export default function isDate(input, options) {
|
|
26
|
+
if (typeof options === 'string') {
|
|
27
|
+
// Allow backward compatibility for old format isDate(input [, format])
|
|
28
|
+
options = merge({
|
|
29
|
+
format: options
|
|
30
|
+
}, default_date_options);
|
|
31
|
+
} else {
|
|
32
|
+
options = merge(options, default_date_options);
|
|
33
|
+
}
|
|
34
|
+
if (typeof input === 'string' && isValidFormat(options.format)) {
|
|
35
|
+
if (options.strictMode && input.length !== options.format.length) return false;
|
|
36
|
+
var formatDelimiter = options.delimiters.find(function (delimiter) {
|
|
37
|
+
return options.format.indexOf(delimiter) !== -1;
|
|
38
|
+
});
|
|
39
|
+
var dateDelimiter = options.strictMode ? formatDelimiter : options.delimiters.find(function (delimiter) {
|
|
40
|
+
return input.indexOf(delimiter) !== -1;
|
|
41
|
+
});
|
|
42
|
+
var dateAndFormat = zip(input.split(dateDelimiter), options.format.toLowerCase().split(formatDelimiter));
|
|
43
|
+
var dateObj = {};
|
|
44
|
+
var _iterator = _createForOfIteratorHelper(dateAndFormat),
|
|
45
|
+
_step;
|
|
46
|
+
try {
|
|
47
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
48
|
+
var _step$value = _slicedToArray(_step.value, 2),
|
|
49
|
+
dateWord = _step$value[0],
|
|
50
|
+
formatWord = _step$value[1];
|
|
51
|
+
if (!dateWord || !formatWord || dateWord.length !== formatWord.length) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
dateObj[formatWord.charAt(0)] = dateWord;
|
|
55
|
+
}
|
|
56
|
+
} catch (err) {
|
|
57
|
+
_iterator.e(err);
|
|
58
|
+
} finally {
|
|
59
|
+
_iterator.f();
|
|
60
|
+
}
|
|
61
|
+
var fullYear = dateObj.y;
|
|
62
|
+
|
|
63
|
+
// Check if the year starts with a hyphen
|
|
64
|
+
if (fullYear.startsWith('-')) {
|
|
65
|
+
return false; // Hyphen before year is not allowed
|
|
66
|
+
}
|
|
67
|
+
if (dateObj.y.length === 2) {
|
|
68
|
+
var parsedYear = parseInt(dateObj.y, 10);
|
|
69
|
+
if (isNaN(parsedYear)) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
var currentYearLastTwoDigits = new Date().getFullYear() % 100;
|
|
73
|
+
if (parsedYear < currentYearLastTwoDigits) {
|
|
74
|
+
fullYear = "20".concat(dateObj.y);
|
|
75
|
+
} else {
|
|
76
|
+
fullYear = "19".concat(dateObj.y);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
var month = dateObj.m;
|
|
80
|
+
if (dateObj.m.length === 1) {
|
|
81
|
+
month = "0".concat(dateObj.m);
|
|
82
|
+
}
|
|
83
|
+
var day = dateObj.d;
|
|
84
|
+
if (dateObj.d.length === 1) {
|
|
85
|
+
day = "0".concat(dateObj.d);
|
|
86
|
+
}
|
|
87
|
+
return new Date("".concat(fullYear, "-").concat(month, "-").concat(day, "T00:00:00.000Z")).getUTCDate() === +dateObj.d;
|
|
88
|
+
}
|
|
89
|
+
if (!options.strictMode) {
|
|
90
|
+
return Object.prototype.toString.call(input) === '[object Date]' && isFinite(input);
|
|
91
|
+
}
|
|
92
|
+
return false;
|
|
93
|
+
}
|