validator
Advanced tools
Comparing version
@@ -42,3 +42,3 @@ import toDate from './lib/toDate'; | ||
import isISRC from './lib/isISRC'; | ||
import isIBAN from './lib/isIBAN'; | ||
import isIBAN, { locales as ibanLocales } from './lib/isIBAN'; | ||
import isBIC from './lib/isBIC'; | ||
@@ -72,2 +72,3 @@ import isMD5 from './lib/isMD5'; | ||
import isISO31661Alpha3 from './lib/isISO31661Alpha3'; | ||
import isISO4217 from './lib/isISO4217'; | ||
import isBase32 from './lib/isBase32'; | ||
@@ -95,3 +96,3 @@ import isBase58 from './lib/isBase58'; | ||
import isVAT from './lib/isVAT'; | ||
var version = '13.6.0'; | ||
var version = '13.7.0'; | ||
var validator = { | ||
@@ -173,2 +174,3 @@ version: version, | ||
isISO31661Alpha3: isISO31661Alpha3, | ||
isISO4217: isISO4217, | ||
isBase32: isBase32, | ||
@@ -197,4 +199,5 @@ isBase58: isBase58, | ||
isLicensePlate: isLicensePlate, | ||
isVAT: isVAT | ||
isVAT: isVAT, | ||
ibanLocales: ibanLocales | ||
}; | ||
export default validator; |
@@ -11,2 +11,3 @@ export var alpha = { | ||
'fa-IR': /^[ابپتثجچحخدذرزژسشصضطظعغفقکگلمنوهی]+$/i, | ||
'fi-FI': /^[A-ZÅÄÖ]+$/i, | ||
'fr-FR': /^[A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i, | ||
@@ -33,3 +34,4 @@ 'it-IT': /^[A-ZÀÉÈÌÎÓÒÙ]+$/i, | ||
he: /^[א-ת]+$/, | ||
fa: /^['آاءأؤئبپتثجچحخدذرزژسشصضطظعغفقکگلمنوهةی']+$/i | ||
fa: /^['آاءأؤئبپتثجچحخدذرزژسشصضطظعغفقکگلمنوهةی']+$/i, | ||
'hi-IN': /^[\u0900-\u0961]+[\u0972-\u097F]*$/i | ||
}; | ||
@@ -45,2 +47,3 @@ export var alphanumeric = { | ||
'es-ES': /^[0-9A-ZÁÉÍÑÓÚÜ]+$/i, | ||
'fi-FI': /^[0-9A-ZÅÄÖ]+$/i, | ||
'fr-FR': /^[0-9A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i, | ||
@@ -67,3 +70,4 @@ 'it-IT': /^[0-9A-ZÀÉÈÌÎÓÒÙ]+$/i, | ||
he: /^[0-9א-ת]+$/, | ||
fa: /^['0-9آاءأؤئبپتثجچحخدذرزژسشصضطظعغفقکگلمنوهةی۱۲۳۴۵۶۷۸۹۰']+$/i | ||
fa: /^['0-9آاءأؤئبپتثجچحخدذرزژسشصضطظعغفقکگلمنوهةی۱۲۳۴۵۶۷۸۹۰']+$/i, | ||
'hi-IN': /^[\u0900-\u0963]+[\u0966-\u097F]*$/i | ||
}; | ||
@@ -103,3 +107,3 @@ export var decimal = { | ||
export var dotDecimal = ['ar-EG', 'ar-LB', 'ar-LY']; | ||
export var commaDecimal = ['bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en-ZM', 'es-ES', 'fr-CA', 'fr-FR', 'id-ID', 'it-IT', 'ku-IQ', 'hu-HU', 'nb-NO', 'nn-NO', 'nl-NL', 'pl-PL', 'pt-PT', 'ru-RU', 'sl-SI', 'sr-RS@latin', 'sr-RS', 'sv-SE', 'tr-TR', 'uk-UA', 'vi-VN']; | ||
export var commaDecimal = ['bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en-ZM', 'es-ES', 'fr-CA', 'fr-FR', 'id-ID', 'it-IT', 'ku-IQ', 'hi-IN', 'hu-HU', 'nb-NO', 'nn-NO', 'nl-NL', 'pl-PL', 'pt-PT', 'ru-RU', 'sl-SI', 'sr-RS@latin', 'sr-RS', 'sv-SE', 'tr-TR', 'uk-UA', 'vi-VN']; | ||
@@ -106,0 +110,0 @@ for (var _i3 = 0; _i3 < dotDecimal.length; _i3++) { |
@@ -5,3 +5,4 @@ import assertString from './util/assertString'; | ||
var defaulContainsOptions = { | ||
ignoreCase: false | ||
ignoreCase: false, | ||
minOccurrences: 1 | ||
}; | ||
@@ -11,3 +12,8 @@ export default function contains(str, elem, options) { | ||
options = merge(options, defaulContainsOptions); | ||
return options.ignoreCase ? str.toLowerCase().indexOf(toString(elem).toLowerCase()) >= 0 : str.indexOf(toString(elem)) >= 0; | ||
if (options.ignoreCase) { | ||
return str.toLowerCase().split(toString(elem).toLowerCase()).length > options.minOccurrences; | ||
} | ||
return str.split(toString(elem)).length > options.minOccurrences; | ||
} |
@@ -9,3 +9,3 @@ import assertString from './util/assertString'; | ||
if (CountryCodes.indexOf(str.slice(4, 6).toUpperCase()) < 0) { | ||
if (!CountryCodes.has(str.slice(4, 6).toUpperCase())) { | ||
return false; | ||
@@ -12,0 +12,0 @@ } |
import assertString from './util/assertString'; | ||
var defaultOptions = { | ||
loose: false | ||
}; | ||
var strictBooleans = ['true', 'false', '1', '0']; | ||
var looseBooleans = [].concat(strictBooleans, ['yes', 'no']); | ||
export default function isBoolean(str) { | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultOptions; | ||
assertString(str); | ||
return ['true', 'false', '1', '0'].indexOf(str) >= 0; | ||
if (options.loose) { | ||
return looseBooleans.includes(str.toLowerCase()); | ||
} | ||
return strictBooleans.includes(str); | ||
} |
import assertString from './util/assertString'; | ||
/* eslint-disable max-len */ | ||
var creditCard = /^(?:4[0-9]{12}(?:[0-9]{3,6})?|5[1-5][0-9]{14}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12,15}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11}|6[27][0-9]{14})$/; | ||
var creditCard = /^(?:4[0-9]{12}(?:[0-9]{3,6})?|5[1-5][0-9]{14}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12,15}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11}|6[27][0-9]{14}|^(81[0-9]{14,17}))$/; | ||
/* eslint-enable max-len */ | ||
@@ -6,0 +6,0 @@ |
@@ -23,3 +23,3 @@ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } | ||
function isValidFormat(format) { | ||
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); | ||
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); | ||
} | ||
@@ -26,0 +26,0 @@ |
@@ -12,3 +12,4 @@ import assertString from './util/assertString'; | ||
blacklisted_chars: '', | ||
ignore_max_length: false | ||
ignore_max_length: false, | ||
host_blacklist: [] | ||
}; | ||
@@ -97,5 +98,10 @@ /* eslint-disable max-len */ | ||
var domain = parts.pop(); | ||
var user = parts.join('@'); | ||
var lower_domain = domain.toLowerCase(); | ||
if (options.host_blacklist.includes(lower_domain)) { | ||
return false; | ||
} | ||
var user = parts.join('@'); | ||
if (options.domain_specific_validation && (lower_domain === 'gmail.com' || lower_domain === 'googlemail.com')) { | ||
@@ -113,3 +119,3 @@ /* | ||
if (!isByteLength(username.replace('.', ''), { | ||
if (!isByteLength(username.replace(/\./g, ''), { | ||
min: 6, | ||
@@ -116,0 +122,0 @@ max: 30 |
@@ -7,3 +7,4 @@ import assertString from './util/assertString'; | ||
allow_trailing_dot: false, | ||
allow_numeric_tld: false | ||
allow_numeric_tld: false, | ||
allow_wildcard: false | ||
}; | ||
@@ -18,3 +19,9 @@ export default function isFQDN(str, options) { | ||
} | ||
/* Remove the optional wildcard before checking validity */ | ||
if (options.allow_wildcard === true && str.indexOf('*.') === 0) { | ||
str = str.substring(2); | ||
} | ||
var parts = str.split('.'); | ||
@@ -29,8 +36,8 @@ var tld = parts[parts.length - 1]; | ||
if (!/^([a-z\u00a1-\uffff]{2,}|xn[a-z0-9-]{2,})$/i.test(tld)) { | ||
if (!/^([a-z\u00A1-\u00A8\u00AA-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}|xn[a-z0-9-]{2,})$/i.test(tld)) { | ||
return false; | ||
} // disallow spaces && special characers | ||
} // disallow spaces | ||
if (/[\s\u2002-\u200B\u202F\u205F\u3000\uFEFF\uDB40\uDC20\u00A9\uFFFD]/.test(tld)) { | ||
if (/\s/.test(tld)) { | ||
return false; | ||
@@ -37,0 +44,0 @@ } |
@@ -137,2 +137,3 @@ import assertString from './util/assertString'; | ||
return hasValidIbanFormat(str) && hasValidIbanChecksum(str); | ||
} | ||
} | ||
export var locales = Object.keys(ibanRegexThroughCountryCode); |
import assertString from './util/assertString'; | ||
import isInt from './isInt'; | ||
var validators = { | ||
PL: function PL(str) { | ||
assertString(str); | ||
var weightOfDigits = { | ||
1: 1, | ||
2: 3, | ||
3: 7, | ||
4: 9, | ||
5: 1, | ||
6: 3, | ||
7: 7, | ||
8: 9, | ||
9: 1, | ||
10: 3, | ||
11: 0 | ||
}; | ||
if (str != null && str.length === 11 && isInt(str, { | ||
allow_leading_zeroes: true | ||
})) { | ||
var digits = str.split('').slice(0, -1); | ||
var sum = digits.reduce(function (acc, digit, index) { | ||
return acc + Number(digit) * weightOfDigits[index + 1]; | ||
}, 0); | ||
var modulo = sum % 10; | ||
var lastDigit = Number(str.charAt(str.length - 1)); | ||
if (modulo === 0 && lastDigit === 0 || lastDigit === 10 - modulo) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
}, | ||
ES: function ES(str) { | ||
@@ -25,2 +59,20 @@ assertString(str); | ||
}, | ||
FI: function FI(str) { | ||
// https://dvv.fi/en/personal-identity-code#:~:text=control%20character%20for%20a-,personal,-identity%20code%20calculated | ||
assertString(str); | ||
if (str.length !== 11) { | ||
return false; | ||
} | ||
if (!str.match(/^\d{6}[\-A\+]\d{3}[0-9ABCDEFHJKLMNPRSTUVWXY]{1}$/)) { | ||
return false; | ||
} | ||
var checkDigits = '0123456789ABCDEFHJKLMNPRSTUVWXY'; | ||
var idAsNumber = parseInt(str.slice(0, 6), 10) * 1000 + parseInt(str.slice(7, 10), 10); | ||
var remainder = idAsNumber % 31; | ||
var checkDigit = checkDigits[remainder]; | ||
return checkDigit === str.slice(10, 11); | ||
}, | ||
IN: function IN(str) { | ||
@@ -78,2 +130,19 @@ var DNI = /^[1-9]\d{3}\s?\d{4}\s?\d{4}$/; // multiplication table | ||
}, | ||
TH: function TH(str) { | ||
if (!str.match(/^[1-8]\d{12}$/)) return false; // validate check digit | ||
var sum = 0; | ||
for (var i = 0; i < 12; i++) { | ||
sum += parseInt(str[i], 10) * (13 - i); | ||
} | ||
return str[12] === ((11 - sum % 11) % 10).toString(); | ||
}, | ||
LK: function LK(str) { | ||
var old_nic = /^[1-9]\d{8}[vx]$/i; | ||
var new_nic = /^[1-9]\d{11}$/i; | ||
if (str.length === 10 && old_nic.test(str)) return true;else if (str.length === 12 && new_nic.test(str)) return true; | ||
return false; | ||
}, | ||
'he-IL': function heIL(str) { | ||
@@ -80,0 +149,0 @@ var DNI = /^\d{9}$/; // sanitize user input |
import assertString from './util/assertString'; // from https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 | ||
var validISO31661Alpha2CountriesCodes = ['AD', 'AE', 'AF', 'AG', 'AI', 'AL', 'AM', 'AO', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AW', 'AX', 'AZ', 'BA', 'BB', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ', 'BL', 'BM', 'BN', 'BO', 'BQ', 'BR', 'BS', 'BT', 'BV', 'BW', 'BY', 'BZ', 'CA', 'CC', 'CD', 'CF', 'CG', 'CH', 'CI', 'CK', 'CL', 'CM', 'CN', 'CO', 'CR', 'CU', 'CV', 'CW', 'CX', 'CY', 'CZ', 'DE', 'DJ', 'DK', 'DM', 'DO', 'DZ', 'EC', 'EE', 'EG', 'EH', 'ER', 'ES', 'ET', 'FI', 'FJ', 'FK', 'FM', 'FO', 'FR', 'GA', 'GB', 'GD', 'GE', 'GF', 'GG', 'GH', 'GI', 'GL', 'GM', 'GN', 'GP', 'GQ', 'GR', 'GS', 'GT', 'GU', 'GW', 'GY', 'HK', 'HM', 'HN', 'HR', 'HT', 'HU', 'ID', 'IE', 'IL', 'IM', 'IN', 'IO', 'IQ', 'IR', 'IS', 'IT', 'JE', 'JM', 'JO', 'JP', 'KE', 'KG', 'KH', 'KI', 'KM', 'KN', 'KP', 'KR', 'KW', 'KY', 'KZ', 'LA', 'LB', 'LC', 'LI', 'LK', 'LR', 'LS', 'LT', 'LU', 'LV', 'LY', 'MA', 'MC', 'MD', 'ME', 'MF', 'MG', 'MH', 'MK', 'ML', 'MM', 'MN', 'MO', 'MP', 'MQ', 'MR', 'MS', 'MT', 'MU', 'MV', 'MW', 'MX', 'MY', 'MZ', 'NA', 'NC', 'NE', 'NF', 'NG', 'NI', 'NL', 'NO', 'NP', 'NR', 'NU', 'NZ', 'OM', 'PA', 'PE', 'PF', 'PG', 'PH', 'PK', 'PL', 'PM', 'PN', 'PR', 'PS', 'PT', 'PW', 'PY', 'QA', 'RE', 'RO', 'RS', 'RU', 'RW', 'SA', 'SB', 'SC', 'SD', 'SE', 'SG', 'SH', 'SI', 'SJ', 'SK', 'SL', 'SM', 'SN', 'SO', 'SR', 'SS', 'ST', 'SV', 'SX', 'SY', 'SZ', 'TC', 'TD', 'TF', 'TG', 'TH', 'TJ', 'TK', 'TL', 'TM', 'TN', 'TO', 'TR', 'TT', 'TV', 'TW', 'TZ', 'UA', 'UG', 'UM', 'US', 'UY', 'UZ', 'VA', 'VC', 'VE', 'VG', 'VI', 'VN', 'VU', 'WF', 'WS', 'YE', 'YT', 'ZA', 'ZM', 'ZW']; | ||
var validISO31661Alpha2CountriesCodes = new Set(['AD', 'AE', 'AF', 'AG', 'AI', 'AL', 'AM', 'AO', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AW', 'AX', 'AZ', 'BA', 'BB', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ', 'BL', 'BM', 'BN', 'BO', 'BQ', 'BR', 'BS', 'BT', 'BV', 'BW', 'BY', 'BZ', 'CA', 'CC', 'CD', 'CF', 'CG', 'CH', 'CI', 'CK', 'CL', 'CM', 'CN', 'CO', 'CR', 'CU', 'CV', 'CW', 'CX', 'CY', 'CZ', 'DE', 'DJ', 'DK', 'DM', 'DO', 'DZ', 'EC', 'EE', 'EG', 'EH', 'ER', 'ES', 'ET', 'FI', 'FJ', 'FK', 'FM', 'FO', 'FR', 'GA', 'GB', 'GD', 'GE', 'GF', 'GG', 'GH', 'GI', 'GL', 'GM', 'GN', 'GP', 'GQ', 'GR', 'GS', 'GT', 'GU', 'GW', 'GY', 'HK', 'HM', 'HN', 'HR', 'HT', 'HU', 'ID', 'IE', 'IL', 'IM', 'IN', 'IO', 'IQ', 'IR', 'IS', 'IT', 'JE', 'JM', 'JO', 'JP', 'KE', 'KG', 'KH', 'KI', 'KM', 'KN', 'KP', 'KR', 'KW', 'KY', 'KZ', 'LA', 'LB', 'LC', 'LI', 'LK', 'LR', 'LS', 'LT', 'LU', 'LV', 'LY', 'MA', 'MC', 'MD', 'ME', 'MF', 'MG', 'MH', 'MK', 'ML', 'MM', 'MN', 'MO', 'MP', 'MQ', 'MR', 'MS', 'MT', 'MU', 'MV', 'MW', 'MX', 'MY', 'MZ', 'NA', 'NC', 'NE', 'NF', 'NG', 'NI', 'NL', 'NO', 'NP', 'NR', 'NU', 'NZ', 'OM', 'PA', 'PE', 'PF', 'PG', 'PH', 'PK', 'PL', 'PM', 'PN', 'PR', 'PS', 'PT', 'PW', 'PY', 'QA', 'RE', 'RO', 'RS', 'RU', 'RW', 'SA', 'SB', 'SC', 'SD', 'SE', 'SG', 'SH', 'SI', 'SJ', 'SK', 'SL', 'SM', 'SN', 'SO', 'SR', 'SS', 'ST', 'SV', 'SX', 'SY', 'SZ', 'TC', 'TD', 'TF', 'TG', 'TH', 'TJ', 'TK', 'TL', 'TM', 'TN', 'TO', 'TR', 'TT', 'TV', 'TW', 'TZ', 'UA', 'UG', 'UM', 'US', 'UY', 'UZ', 'VA', 'VC', 'VE', 'VG', 'VI', 'VN', 'VU', 'WF', 'WS', 'YE', 'YT', 'ZA', 'ZM', 'ZW']); | ||
export default function isISO31661Alpha2(str) { | ||
assertString(str); | ||
return validISO31661Alpha2CountriesCodes.indexOf(str.toUpperCase()) >= 0; | ||
return validISO31661Alpha2CountriesCodes.has(str.toUpperCase()); | ||
} | ||
export var CountryCodes = validISO31661Alpha2CountriesCodes; |
@@ -1,8 +0,7 @@ | ||
import assertString from './util/assertString'; | ||
import includes from './util/includes'; // from https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3 | ||
import assertString from './util/assertString'; // from https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3 | ||
var validISO31661Alpha3CountriesCodes = ['AFG', 'ALA', 'ALB', 'DZA', 'ASM', 'AND', 'AGO', 'AIA', 'ATA', 'ATG', 'ARG', 'ARM', 'ABW', 'AUS', 'AUT', 'AZE', 'BHS', 'BHR', 'BGD', 'BRB', 'BLR', 'BEL', 'BLZ', 'BEN', 'BMU', 'BTN', 'BOL', 'BES', 'BIH', 'BWA', 'BVT', 'BRA', 'IOT', 'BRN', 'BGR', 'BFA', 'BDI', 'KHM', 'CMR', 'CAN', 'CPV', 'CYM', 'CAF', 'TCD', 'CHL', 'CHN', 'CXR', 'CCK', 'COL', 'COM', 'COG', 'COD', 'COK', 'CRI', 'CIV', 'HRV', 'CUB', 'CUW', 'CYP', 'CZE', 'DNK', 'DJI', 'DMA', 'DOM', 'ECU', 'EGY', 'SLV', 'GNQ', 'ERI', 'EST', 'ETH', 'FLK', 'FRO', 'FJI', 'FIN', 'FRA', 'GUF', 'PYF', 'ATF', 'GAB', 'GMB', 'GEO', 'DEU', 'GHA', 'GIB', 'GRC', 'GRL', 'GRD', 'GLP', 'GUM', 'GTM', 'GGY', 'GIN', 'GNB', 'GUY', 'HTI', 'HMD', 'VAT', 'HND', 'HKG', 'HUN', 'ISL', 'IND', 'IDN', 'IRN', 'IRQ', 'IRL', 'IMN', 'ISR', 'ITA', 'JAM', 'JPN', 'JEY', 'JOR', 'KAZ', 'KEN', 'KIR', 'PRK', 'KOR', 'KWT', 'KGZ', 'LAO', 'LVA', 'LBN', 'LSO', 'LBR', 'LBY', 'LIE', 'LTU', 'LUX', 'MAC', 'MKD', 'MDG', 'MWI', 'MYS', 'MDV', 'MLI', 'MLT', 'MHL', 'MTQ', 'MRT', 'MUS', 'MYT', 'MEX', 'FSM', 'MDA', 'MCO', 'MNG', 'MNE', 'MSR', 'MAR', 'MOZ', 'MMR', 'NAM', 'NRU', 'NPL', 'NLD', 'NCL', 'NZL', 'NIC', 'NER', 'NGA', 'NIU', 'NFK', 'MNP', 'NOR', 'OMN', 'PAK', 'PLW', 'PSE', 'PAN', 'PNG', 'PRY', 'PER', 'PHL', 'PCN', 'POL', 'PRT', 'PRI', 'QAT', 'REU', 'ROU', 'RUS', 'RWA', 'BLM', 'SHN', 'KNA', 'LCA', 'MAF', 'SPM', 'VCT', 'WSM', 'SMR', 'STP', 'SAU', 'SEN', 'SRB', 'SYC', 'SLE', 'SGP', 'SXM', 'SVK', 'SVN', 'SLB', 'SOM', 'ZAF', 'SGS', 'SSD', 'ESP', 'LKA', 'SDN', 'SUR', 'SJM', 'SWZ', 'SWE', 'CHE', 'SYR', 'TWN', 'TJK', 'TZA', 'THA', 'TLS', 'TGO', 'TKL', 'TON', 'TTO', 'TUN', 'TUR', 'TKM', 'TCA', 'TUV', 'UGA', 'UKR', 'ARE', 'GBR', 'USA', 'UMI', 'URY', 'UZB', 'VUT', 'VEN', 'VNM', 'VGB', 'VIR', 'WLF', 'ESH', 'YEM', 'ZMB', 'ZWE']; | ||
var validISO31661Alpha3CountriesCodes = new Set(['AFG', 'ALA', 'ALB', 'DZA', 'ASM', 'AND', 'AGO', 'AIA', 'ATA', 'ATG', 'ARG', 'ARM', 'ABW', 'AUS', 'AUT', 'AZE', 'BHS', 'BHR', 'BGD', 'BRB', 'BLR', 'BEL', 'BLZ', 'BEN', 'BMU', 'BTN', 'BOL', 'BES', 'BIH', 'BWA', 'BVT', 'BRA', 'IOT', 'BRN', 'BGR', 'BFA', 'BDI', 'KHM', 'CMR', 'CAN', 'CPV', 'CYM', 'CAF', 'TCD', 'CHL', 'CHN', 'CXR', 'CCK', 'COL', 'COM', 'COG', 'COD', 'COK', 'CRI', 'CIV', 'HRV', 'CUB', 'CUW', 'CYP', 'CZE', 'DNK', 'DJI', 'DMA', 'DOM', 'ECU', 'EGY', 'SLV', 'GNQ', 'ERI', 'EST', 'ETH', 'FLK', 'FRO', 'FJI', 'FIN', 'FRA', 'GUF', 'PYF', 'ATF', 'GAB', 'GMB', 'GEO', 'DEU', 'GHA', 'GIB', 'GRC', 'GRL', 'GRD', 'GLP', 'GUM', 'GTM', 'GGY', 'GIN', 'GNB', 'GUY', 'HTI', 'HMD', 'VAT', 'HND', 'HKG', 'HUN', 'ISL', 'IND', 'IDN', 'IRN', 'IRQ', 'IRL', 'IMN', 'ISR', 'ITA', 'JAM', 'JPN', 'JEY', 'JOR', 'KAZ', 'KEN', 'KIR', 'PRK', 'KOR', 'KWT', 'KGZ', 'LAO', 'LVA', 'LBN', 'LSO', 'LBR', 'LBY', 'LIE', 'LTU', 'LUX', 'MAC', 'MKD', 'MDG', 'MWI', 'MYS', 'MDV', 'MLI', 'MLT', 'MHL', 'MTQ', 'MRT', 'MUS', 'MYT', 'MEX', 'FSM', 'MDA', 'MCO', 'MNG', 'MNE', 'MSR', 'MAR', 'MOZ', 'MMR', 'NAM', 'NRU', 'NPL', 'NLD', 'NCL', 'NZL', 'NIC', 'NER', 'NGA', 'NIU', 'NFK', 'MNP', 'NOR', 'OMN', 'PAK', 'PLW', 'PSE', 'PAN', 'PNG', 'PRY', 'PER', 'PHL', 'PCN', 'POL', 'PRT', 'PRI', 'QAT', 'REU', 'ROU', 'RUS', 'RWA', 'BLM', 'SHN', 'KNA', 'LCA', 'MAF', 'SPM', 'VCT', 'WSM', 'SMR', 'STP', 'SAU', 'SEN', 'SRB', 'SYC', 'SLE', 'SGP', 'SXM', 'SVK', 'SVN', 'SLB', 'SOM', 'ZAF', 'SGS', 'SSD', 'ESP', 'LKA', 'SDN', 'SUR', 'SJM', 'SWZ', 'SWE', 'CHE', 'SYR', 'TWN', 'TJK', 'TZA', 'THA', 'TLS', 'TGO', 'TKL', 'TON', 'TTO', 'TUN', 'TUR', 'TKM', 'TCA', 'TUV', 'UGA', 'UKR', 'ARE', 'GBR', 'USA', 'UMI', 'URY', 'UZB', 'VUT', 'VEN', 'VNM', 'VGB', 'VIR', 'WLF', 'ESH', 'YEM', 'ZMB', 'ZWE']); | ||
export default function isISO31661Alpha3(str) { | ||
assertString(str); | ||
return includes(validISO31661Alpha3CountriesCodes, str.toUpperCase()); | ||
return validISO31661Alpha3CountriesCodes.has(str.toUpperCase()); | ||
} |
import assertString from './util/assertString'; | ||
var validators = { | ||
'cs-CZ': function csCZ(str) { | ||
return /^(([ABCDEFHKIJKLMNPRSTUVXYZ]|[0-9])-?){5,8}$/.test(str); | ||
}, | ||
'de-DE': function deDE(str) { | ||
@@ -9,2 +12,5 @@ return /^((AW|UL|AK|GA|AÖ|LF|AZ|AM|AS|ZE|AN|AB|A|KG|KH|BA|EW|BZ|HY|KM|BT|HP|B|BC|BI|BO|FN|TT|ÜB|BN|AH|BS|FR|HB|ZZ|BB|BK|BÖ|OC|OK|CW|CE|C|CO|LH|CB|KW|LC|LN|DA|DI|DE|DH|SY|NÖ|DO|DD|DU|DN|D|EI|EA|EE|FI|EM|EL|EN|PF|ED|EF|ER|AU|ZP|E|ES|NT|EU|FL|FO|FT|FF|F|FS|FD|FÜ|GE|G|GI|GF|GS|ZR|GG|GP|GR|NY|ZI|GÖ|GZ|GT|HA|HH|HM|HU|WL|HZ|WR|RN|HK|HD|HN|HS|GK|HE|HF|RZ|HI|HG|HO|HX|IK|IL|IN|J|JL|KL|KA|KS|KF|KE|KI|KT|KO|KN|KR|KC|KU|K|LD|LL|LA|L|OP|LM|LI|LB|LU|LÖ|HL|LG|MD|GN|MZ|MA|ML|MR|MY|AT|DM|MC|NZ|RM|RG|MM|ME|MB|MI|FG|DL|HC|MW|RL|MK|MG|MÜ|WS|MH|M|MS|NU|NB|ND|NM|NK|NW|NR|NI|NF|DZ|EB|OZ|TG|TO|N|OA|GM|OB|CA|EH|FW|OF|OL|OE|OG|BH|LR|OS|AA|GD|OH|KY|NP|WK|PB|PA|PE|PI|PS|P|PM|PR|RA|RV|RE|R|H|SB|WN|RS|RD|RT|BM|NE|GV|RP|SU|GL|RO|GÜ|RH|EG|RW|PN|SK|MQ|RU|SZ|RI|SL|SM|SC|HR|FZ|VS|SW|SN|CR|SE|SI|SO|LP|SG|NH|SP|IZ|ST|BF|TE|HV|OD|SR|S|AC|DW|ZW|TF|TS|TR|TÜ|UM|PZ|TP|UE|UN|UH|MN|KK|VB|V|AE|PL|RC|VG|GW|PW|VR|VK|KB|WA|WT|BE|WM|WE|AP|MO|WW|FB|WZ|WI|WB|JE|WF|WO|W|WÜ|BL|Z|GC)[- ]?[A-Z]{1,2}[- ]?\d{1,4}|(AIC|FDB|ABG|SLN|SAW|KLZ|BUL|ESB|NAB|SUL|WST|ABI|AZE|BTF|KÖT|DKB|FEU|ROT|ALZ|SMÜ|WER|AUR|NOR|DÜW|BRK|HAB|TÖL|WOR|BAD|BAR|BER|BIW|EBS|KEM|MÜB|PEG|BGL|BGD|REI|WIL|BKS|BIR|WAT|BOR|BOH|BOT|BRB|BLK|HHM|NEB|NMB|WSF|LEO|HDL|WMS|WZL|BÜS|CHA|KÖZ|ROD|WÜM|CLP|NEC|COC|ZEL|COE|CUX|DAH|LDS|DEG|DEL|RSL|DLG|DGF|LAN|HEI|MED|DON|KIB|ROK|JÜL|MON|SLE|EBE|EIC|HIG|WBS|BIT|PRÜ|LIB|EMD|WIT|ERH|HÖS|ERZ|ANA|ASZ|MAB|MEK|STL|SZB|FDS|HCH|HOR|WOL|FRG|GRA|WOS|FRI|FFB|GAP|GER|BRL|CLZ|GTH|NOH|HGW|GRZ|LÖB|NOL|WSW|DUD|HMÜ|OHA|KRU|HAL|HAM|HBS|QLB|HVL|NAU|HAS|EBN|GEO|HOH|HDH|ERK|HER|WAN|HEF|ROF|HBN|ALF|HSK|USI|NAI|REH|SAN|KÜN|ÖHR|HOL|WAR|ARN|BRG|GNT|HOG|WOH|KEH|MAI|PAR|RID|ROL|KLE|GEL|KUS|KYF|ART|SDH|LDK|DIL|MAL|VIB|LER|BNA|GHA|GRM|MTL|WUR|LEV|LIF|STE|WEL|LIP|VAI|LUP|HGN|LBZ|LWL|PCH|STB|DAN|MKK|SLÜ|MSP|TBB|MGH|MTK|BIN|MSH|EIL|HET|SGH|BID|MYK|MSE|MST|MÜR|WRN|MEI|GRH|RIE|MZG|MIL|OBB|BED|FLÖ|MOL|FRW|SEE|SRB|AIB|MOS|BCH|ILL|SOB|NMS|NEA|SEF|UFF|NEW|VOH|NDH|TDO|NWM|GDB|GVM|WIS|NOM|EIN|GAN|LAU|HEB|OHV|OSL|SFB|ERB|LOS|BSK|KEL|BSB|MEL|WTL|OAL|FÜS|MOD|OHZ|OPR|BÜR|PAF|PLÖ|CAS|GLA|REG|VIT|ECK|SIM|GOA|EMS|DIZ|GOH|RÜD|SWA|NES|KÖN|MET|LRO|BÜZ|DBR|ROS|TET|HRO|ROW|BRV|HIP|PAN|GRI|SHK|EIS|SRO|SOK|LBS|SCZ|MER|QFT|SLF|SLS|HOM|SLK|ASL|BBG|SBK|SFT|SHG|MGN|MEG|ZIG|SAD|NEN|OVI|SHA|BLB|SIG|SON|SPN|FOR|GUB|SPB|IGB|WND|STD|STA|SDL|OBG|HST|BOG|SHL|PIR|FTL|SEB|SÖM|SÜW|TIR|SAB|TUT|ANG|SDT|LÜN|LSZ|MHL|VEC|VER|VIE|OVL|ANK|OVP|SBG|UEM|UER|WLG|GMN|NVP|RDG|RÜG|DAU|FKB|WAF|WAK|SLZ|WEN|SOG|APD|WUG|GUN|ESW|WIZ|WES|DIN|BRA|BÜD|WHV|HWI|GHC|WTM|WOB|WUN|MAK|SEL|OCH|HOT|WDA)[- ]?(([A-Z][- ]?\d{1,4})|([A-Z]{2}[- ]?\d{1,3})))[- ]?(E|H)?$/.test(str); | ||
}, | ||
'fi-FI': function fiFI(str) { | ||
return /^(?=.{4,7})(([A-Z]{1,3}|[0-9]{1,3})[\s-]?([A-Z]{1,3}|[0-9]{1,5}))$/.test(str); | ||
}, | ||
'pt-PT': function ptPT(str) { | ||
@@ -11,0 +17,0 @@ return /^([A-Z]{2}|[0-9]{2})[ -·]?([A-Z]{2}|[0-9]{2})[ -·]?([A-Z]{2}|[0-9]{2})$/.test(str); |
import assertString from './util/assertString'; | ||
var magnetURI = /^magnet:\?xt=urn:[a-z0-9]+:[a-z0-9]{32,40}&dn=.+&tr=.+$/i; | ||
var magnetURI = /^magnet:\?xt(?:\.1)?=urn:(?:aich|bitprint|btih|ed2k|ed2khash|kzhash|md5|sha1|tree:tiger):[a-z0-9]{32}(?:[a-z0-9]{8})?($|&)/i; | ||
export default function isMagnetURI(url) { | ||
@@ -4,0 +4,0 @@ assertString(url); |
@@ -17,2 +17,3 @@ import assertString from './util/assertString'; | ||
'ar-OM': /^((\+|00)968)?(9[1-9])\d{6}$/, | ||
'ar-PS': /^(\+?970|0)5[6|9](\d{7})$/, | ||
'ar-SA': /^(!?(\+?966)|0)?5\d{8}$/, | ||
@@ -29,11 +30,14 @@ 'ar-SY': /^(!?(\+?963)|0)?9\d{8}$/, | ||
'da-DK': /^(\+?45)?\s?\d{2}\s?\d{2}\s?\d{2}\s?\d{2}$/, | ||
'de-DE': /^(\+49)?0?[1|3]([0|5][0-45-9]\d|6([23]|0\d?)|7([0-57-9]|6\d))\d{7}$/, | ||
'de-DE': /^((\+49|0)[1|3])([0|5][0-45-9]\d|6([23]|0\d?)|7([0-57-9]|6\d))\d{7,9}$/, | ||
'de-AT': /^(\+43|0)\d{1,4}\d{3,12}$/, | ||
'de-CH': /^(\+41|0)([1-9])\d{1,9}$/, | ||
'de-LU': /^(\+352)?((6\d1)\d{6})$/, | ||
'dv-MV': /^(\+?960)?(7[2-9]|91|9[3-9])\d{7}$/, | ||
'el-GR': /^(\+?30|0)?(69\d{8})$/, | ||
'en-AU': /^(\+?61|0)4\d{8}$/, | ||
'en-BM': /^(\+?1)?441(((3|7)\d{6}$)|(5[0-3][0-9]\d{4}$)|(59\d{5}))/, | ||
'en-GB': /^(\+?44|0)7\d{9}$/, | ||
'en-GG': /^(\+?44|0)1481\d{6}$/, | ||
'en-GH': /^(\+233|0)(20|50|24|54|27|57|26|56|23|28|55|59)\d{7}$/, | ||
'en-GY': /^(\+592|0)6\d{6}$/, | ||
'en-HK': /^(\+?852[-\s]?)?[456789]\d{3}[-\s]?\d{4}$/, | ||
@@ -44,7 +48,9 @@ 'en-MO': /^(\+?853[-\s]?)?[6]\d{3}[-\s]?\d{4}$/, | ||
'en-KE': /^(\+?254|0)(7|1)\d{8}$/, | ||
'en-KI': /^((\+686|686)?)?( )?((6|7)(2|3|8)[0-9]{6})$/, | ||
'en-MT': /^(\+?356|0)?(99|79|77|21|27|22|25)[0-9]{6}$/, | ||
'en-MU': /^(\+?230|0)?\d{8}$/, | ||
'en-NA': /^(\+?264|0)(6|8)\d{7}$/, | ||
'en-NG': /^(\+?234|0)?[789]\d{9}$/, | ||
'en-NZ': /^(\+?64|0)[28]\d{7,9}$/, | ||
'en-PK': /^((\+92)|(0092))-{0,1}\d{3}-{0,1}\d{7}$|^\d{11}$|^\d{4}-\d{7}$/, | ||
'en-PK': /^((00|\+)?92|0)3[0-6]\d{8}$/, | ||
'en-PH': /^(09|\+639)\d{9}$/, | ||
@@ -60,2 +66,3 @@ 'en-RW': /^(\+?250|0)?[7]\d{8}$/, | ||
'en-ZW': /^(\+263)[0-9]{9}$/, | ||
'en-BW': /^(\+?267)?(7[1-8]{1})\d{6}$/, | ||
'es-AR': /^\+?549(11|[2368]\d)\d{8}$/, | ||
@@ -66,2 +73,3 @@ 'es-BO': /^(\+?591)?(6|7)\d{7}$/, | ||
'es-CR': /^(\+506)?[2-8]\d{7}$/, | ||
'es-CU': /^(\+53|0053)?5\d{7}/, | ||
'es-DO': /^(\+?1)?8[024]9\d{7}$/, | ||
@@ -75,3 +83,5 @@ 'es-HN': /^(\+?504)?[9|8]\d{7}$/, | ||
'es-PY': /^(\+?595|0)9[9876]\d{7}$/, | ||
'es-SV': /^(\+?503)?[67]\d{7}$/, | ||
'es-UY': /^(\+598|0)9[1-9][\d]{6}$/, | ||
'es-VE': /^(\+?58)?(2|4)\d{9}$/, | ||
'et-EE': /^(\+?372)?\s?(5|8[1-4])\s?([0-9]\s?){6,7}$/, | ||
@@ -82,2 +92,4 @@ 'fa-IR': /^(\+?98[\-\s]?|0)9[0-39]\d[\-\s]?\d{3}[\-\s]?\d{4}$/, | ||
'fo-FO': /^(\+?298)?\s?\d{2}\s?\d{2}\s?\d{2}$/, | ||
'fr-BF': /^(\+226|0)[67]\d{7}$/, | ||
'fr-CM': /^(\+?237)6[0-9]{8}$/, | ||
'fr-FR': /^(\+?33|0)[67]\d{8}$/, | ||
@@ -87,5 +99,6 @@ 'fr-GF': /^(\+?594|0|00594)[67]\d{8}$/, | ||
'fr-MQ': /^(\+?596|0|00596)[67]\d{8}$/, | ||
'fr-PF': /^(\+?689)?8[789]\d{6}$/, | ||
'fr-RE': /^(\+?262|0|00262)[67]\d{8}$/, | ||
'he-IL': /^(\+972|0)([23489]|5[012345689]|77)[1-9]\d{6}$/, | ||
'hu-HU': /^(\+?36)(20|30|70)\d{7}$/, | ||
'hu-HU': /^(\+?36|06)(20|30|31|50|70)\d{7}$/, | ||
'id-ID': /^(\+?62|0)8(1[123456789]|2[1238]|3[1238]|5[12356789]|7[78]|9[56789]|8[123456789])([\s?|\d]{5,11})$/, | ||
@@ -105,3 +118,3 @@ 'it-IT': /^(\+?39)?\s?3\d{2} ?\d{6,7}$/, | ||
'ne-NP': /^(\+?977)?9[78]\d{8}$/, | ||
'nl-BE': /^(\+?32|0)4?\d{8}$/, | ||
'nl-BE': /^(\+?32|0)4\d{8}$/, | ||
'nl-NL': /^(((\+|00)?31\(0\))|((\+|00)?31)|0)6{1}\d{8}$/, | ||
@@ -115,3 +128,3 @@ 'nn-NO': /^(\+?47)?[49]\d{7}$/, | ||
'ru-RU': /^(\+?7|8)?9\d{9}$/, | ||
'si-LK': /^(?:0|94|\+94)?(7(0|1|2|5|6|7|8)( |-)?\d)\d{6}$/, | ||
'si-LK': /^(?:0|94|\+94)?(7(0|1|2|4|5|6|7|8)( |-)?)\d{7}$/, | ||
'sl-SI': /^(\+386\s?|0)(\d{1}\s?\d{3}\s?\d{2}\s?\d{2}|\d{2}\s?\d{3}\s?\d{3})$/, | ||
@@ -122,9 +135,12 @@ 'sk-SK': /^(\+?421)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/, | ||
'sv-SE': /^(\+?46|0)[\s\-]?7[\s\-]?[02369]([\s\-]?\d){7}$/, | ||
'tg-TJ': /^(\+?992)?[5][5]\d{7}$/, | ||
'th-TH': /^(\+66|66|0)\d{9}$/, | ||
'tr-TR': /^(\+?90|0)?5\d{9}$/, | ||
'tk-TM': /^(\+993|993|8)\d{8}$/, | ||
'uk-UA': /^(\+?38|8)?0\d{9}$/, | ||
'uz-UZ': /^(\+?998)?(6[125-79]|7[1-69]|88|9\d)\d{7}$/, | ||
'vi-VN': /^(\+?84|0)((3([2-9]))|(5([2689]))|(7([0|6-9]))|(8([1-9]))|(9([0-9])))([0-9]{7})$/, | ||
'zh-CN': /^((\+|00)86)?1([3456789][0-9]|4[579]|6[67]|7[01235678]|9[012356789])[0-9]{8}$/, | ||
'zh-TW': /^(\+?886\-?|0)?9\d{8}$/ | ||
'vi-VN': /^((\+?84)|0)((3([2-9]))|(5([25689]))|(7([0|6-9]))|(8([1-9]))|(9([0-9])))([0-9]{7})$/, | ||
'zh-CN': /^((\+|00)86)?(1[3-9]|9[28])\d{9}$/, | ||
'zh-TW': /^(\+?886\-?|0)?9\d{8}$/, | ||
'dz-BT': /^(\+?975|0)?(17|16|77|02)\d{6}$/ | ||
}; | ||
@@ -131,0 +147,0 @@ /* eslint-enable max-len */ |
@@ -30,4 +30,4 @@ import assertString from './util/assertString'; | ||
// SWITZERLAND | ||
CN: /^[GE]\d{8}$/, | ||
// CHINA [G=Ordinary, E=Electronic] followed by 8-digits | ||
CN: /^G\d{8}$|^E(?![IO])[A-Z0-9]\d{7}$/, | ||
// CHINA [G=Ordinary, E=Electronic] followed by 8-digits, or E followed by any UPPERCASE letter (except I and O) followed by 7 digits | ||
CY: /^[A-Z](\d{6}|\d{8})$/, | ||
@@ -63,2 +63,4 @@ // CYPRUS | ||
// INDIA | ||
ID: /^[A-C]\d{7}$/, | ||
// INDONESIA | ||
IR: /^[A-Z]\d{8}$/, | ||
@@ -90,3 +92,3 @@ // IRAN | ||
// NETHERLANDS | ||
PO: /^[A-Z]{2}\d{7}$/, | ||
PL: /^[A-Z]{2}\d{7}$/, | ||
// POLAND | ||
@@ -97,3 +99,3 @@ PT: /^[A-Z]\d{6}$/, | ||
// ROMANIA | ||
RU: /^\d{2}\d{2}\d{6}$/, | ||
RU: /^\d{9}$/, | ||
// RUSSIAN FEDERATION | ||
@@ -100,0 +102,0 @@ SE: /^\d{8}$/, |
@@ -47,2 +47,3 @@ import assertString from './util/assertString'; // common patterns | ||
LV: /^LV\-\d{4}$/, | ||
LK: fiveDigit, | ||
MX: fiveDigit, | ||
@@ -49,0 +50,0 @@ MT: /^[A-Za-z]{3}\s{0,1}\d{4}$/, |
@@ -16,3 +16,3 @@ import assertString from './util/assertString'; | ||
var fullTime = new RegExp("".concat(partialTime.source).concat(timeOffset.source)); | ||
var rfc3339 = new RegExp("".concat(fullDate.source, "[ tT]").concat(fullTime.source)); | ||
var rfc3339 = new RegExp("^".concat(fullDate.source, "[ tT]").concat(fullTime.source, "$")); | ||
export default function isRFC3339(str) { | ||
@@ -19,0 +19,0 @@ assertString(str); |
@@ -1089,11 +1089,7 @@ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } | ||
function ptBrCheck(tin) { | ||
tin = tin.replace(/[^\d]+/g, ''); | ||
if (tin === '') return false; | ||
if (tin.length === 11) { | ||
var _sum; | ||
var ramainder; | ||
var remainder; | ||
_sum = 0; | ||
tin = tin.replace(/[^\d]+/g, ''); | ||
if ( // Reject known invalid CPFs | ||
@@ -1106,5 +1102,5 @@ tin === '11111111111' || tin === '22222222222' || tin === '33333333333' || tin === '44444444444' || tin === '55555555555' || tin === '66666666666' || tin === '77777777777' || tin === '88888888888' || tin === '99999999999' || tin === '00000000000') return false; | ||
ramainder = _sum * 10 % 11; | ||
if (ramainder === 10 || ramainder === 11) ramainder = 0; | ||
if (ramainder !== parseInt(tin.substring(9, 10), 10)) return false; | ||
remainder = _sum * 10 % 11; | ||
if (remainder === 10) remainder = 0; | ||
if (remainder !== parseInt(tin.substring(9, 10), 10)) return false; | ||
_sum = 0; | ||
@@ -1116,12 +1112,8 @@ | ||
ramainder = _sum * 10 % 11; | ||
if (ramainder === 10 || ramainder === 11) ramainder = 0; | ||
if (ramainder !== parseInt(tin.substring(10, 11), 10)) return false; | ||
remainder = _sum * 10 % 11; | ||
if (remainder === 10) remainder = 0; | ||
if (remainder !== parseInt(tin.substring(10, 11), 10)) return false; | ||
return true; | ||
} | ||
if (tin.length !== 14) { | ||
return false; | ||
} | ||
if ( // Reject know invalid CNPJs | ||
@@ -1433,3 +1425,3 @@ tin === '00000000000000' || tin === '11111111111111' || tin === '22222222222222' || tin === '33333333333333' || tin === '44444444444444' || tin === '55555555555555' || tin === '66666666666666' || tin === '77777777777777' || tin === '88888888888888' || tin === '99999999999999') { | ||
'pl-PL': /^\d{10,11}$/, | ||
'pt-BR': /^\d{11,14}$/, | ||
'pt-BR': /(?:^\d{11}$)|(?:^\d{14}$)/, | ||
'pt-PT': /^\d{9}$/, | ||
@@ -1436,0 +1428,0 @@ 'ro-RO': /^\d{13}$/, |
@@ -0,1 +1,13 @@ | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } | ||
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."); } | ||
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); } | ||
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; } | ||
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
import assertString from './util/assertString'; | ||
@@ -28,2 +40,4 @@ import isFQDN from './isFQDN'; | ||
allow_protocol_relative_urls: false, | ||
allow_fragments: true, | ||
allow_query_components: true, | ||
validate_length: true | ||
@@ -66,2 +80,10 @@ }; | ||
if (!options.allow_fragments && url.includes('#')) { | ||
return false; | ||
} | ||
if (!options.allow_query_components && (url.includes('?') || url.includes('&'))) { | ||
return false; | ||
} | ||
var protocol, auth, host, hostname, port, port_str, split, ipv6; | ||
@@ -110,3 +132,3 @@ split = url.split('#'); | ||
if (split[0] === '' || split[0].substr(0, 1) === ':') { | ||
if (split[0] === '') { | ||
return false; | ||
@@ -120,2 +142,11 @@ } | ||
} | ||
var _auth$split = auth.split(':'), | ||
_auth$split2 = _slicedToArray(_auth$split, 2), | ||
user = _auth$split2[0], | ||
password = _auth$split2[1]; | ||
if (user === '' && password === '') { | ||
return false; | ||
} | ||
} | ||
@@ -141,3 +172,3 @@ | ||
if (port_str !== null) { | ||
if (port_str !== null && port_str.length > 0) { | ||
port = parseInt(port_str, 10); | ||
@@ -152,2 +183,6 @@ | ||
if (options.host_whitelist) { | ||
return checkHost(host, options.host_whitelist); | ||
} | ||
if (!isIP(host) && !isFQDN(host, options) && (!ipv6 || !isIP(ipv6, 6))) { | ||
@@ -159,6 +194,2 @@ return false; | ||
if (options.host_whitelist && !checkHost(host, options.host_whitelist)) { | ||
return false; | ||
} | ||
if (options.host_blacklist && checkHost(host, options.host_blacklist)) { | ||
@@ -165,0 +196,0 @@ return false; |
import assertString from './util/assertString'; | ||
var uuid = { | ||
1: /^[0-9A-F]{8}-[0-9A-F]{4}-1[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i, | ||
2: /^[0-9A-F]{8}-[0-9A-F]{4}-2[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i, | ||
3: /^[0-9A-F]{8}-[0-9A-F]{4}-3[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i, | ||
@@ -8,7 +10,6 @@ 4: /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i, | ||
}; | ||
export default function isUUID(str) { | ||
var version = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'all'; | ||
export default function isUUID(str, version) { | ||
assertString(str); | ||
var pattern = uuid[version]; | ||
return pattern && pattern.test(str); | ||
var pattern = uuid[![undefined, null].includes(version) ? version : 'all']; | ||
return !!pattern && pattern.test(str); | ||
} |
import assertString from './util/assertString'; | ||
export var vatMatchers = { | ||
GB: /^GB((\d{3} \d{4} ([0-8][0-9]|9[0-6]))|(\d{9} \d{3})|(((GD[0-4])|(HA[5-9]))[0-9]{2}))$/, | ||
IT: /^(IT)?[0-9]{11}$/ | ||
IT: /^(IT)?[0-9]{11}$/, | ||
NL: /^(NL)?[0-9]{9}B[0-9]{2}$/ | ||
}; | ||
@@ -6,0 +7,0 @@ export default function isVAT(str, countryCode) { |
import assertString from './util/assertString'; | ||
export default function rtrim(str, chars) { | ||
assertString(str); // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Escaping | ||
assertString(str); | ||
var pattern = chars ? new RegExp("[".concat(chars.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), "]+$"), 'g') : /(\s)+$/g; | ||
return str.replace(pattern, ''); | ||
if (chars) { | ||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Escaping | ||
var pattern = new RegExp("[".concat(chars.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), "]+$"), 'g'); | ||
return str.replace(pattern, ''); | ||
} // Use a faster and more safe than regex trim method https://blog.stevenlevithan.com/archives/faster-trim-javascript | ||
var strIndex = str.length - 1; | ||
while (/\s/.test(str.charAt(strIndex))) { | ||
strIndex -= 1; | ||
} | ||
return str.slice(0, strIndex + 1); | ||
} |
import assertString from './util/assertString'; | ||
export default function unescape(str) { | ||
assertString(str); | ||
return str.replace(/&/g, '&').replace(/"/g, '"').replace(/'/g, "'").replace(/</g, '<').replace(/>/g, '>').replace(///g, '/').replace(/\/g, '\\').replace(/`/g, '`'); | ||
return str.replace(/"/g, '"').replace(/'/g, "'").replace(/</g, '<').replace(/>/g, '>').replace(///g, '/').replace(/\/g, '\\').replace(/`/g, '`').replace(/&/g, '&'); // & replacement has to be the last one to prevent | ||
// bugs with intermediate strings containing escape sequences | ||
// See: https://github.com/validatorjs/validator.js/issues/1827 | ||
} |
10
index.js
@@ -92,3 +92,3 @@ "use strict"; | ||
var _isIBAN = _interopRequireDefault(require("./lib/isIBAN")); | ||
var _isIBAN = _interopRequireWildcard(require("./lib/isIBAN")); | ||
@@ -151,2 +151,4 @@ var _isBIC = _interopRequireDefault(require("./lib/isBIC")); | ||
var _isISO2 = _interopRequireDefault(require("./lib/isISO4217")); | ||
var _isBase = _interopRequireDefault(require("./lib/isBase32")); | ||
@@ -202,3 +204,3 @@ | ||
var version = '13.6.0'; | ||
var version = '13.7.0'; | ||
var validator = { | ||
@@ -280,2 +282,3 @@ version: version, | ||
isISO31661Alpha3: _isISO31661Alpha2.default, | ||
isISO4217: _isISO2.default, | ||
isBase32: _isBase.default, | ||
@@ -304,3 +307,4 @@ isBase58: _isBase2.default, | ||
isLicensePlate: _isLicensePlate.default, | ||
isVAT: _isVAT.default | ||
isVAT: _isVAT.default, | ||
ibanLocales: _isIBAN.locales | ||
}; | ||
@@ -307,0 +311,0 @@ var _default = validator; |
@@ -17,2 +17,3 @@ "use strict"; | ||
'fa-IR': /^[ابپتثجچحخدذرزژسشصضطظعغفقکگلمنوهی]+$/i, | ||
'fi-FI': /^[A-ZÅÄÖ]+$/i, | ||
'fr-FR': /^[A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i, | ||
@@ -39,3 +40,4 @@ 'it-IT': /^[A-ZÀÉÈÌÎÓÒÙ]+$/i, | ||
he: /^[א-ת]+$/, | ||
fa: /^['آاءأؤئبپتثجچحخدذرزژسشصضطظعغفقکگلمنوهةی']+$/i | ||
fa: /^['آاءأؤئبپتثجچحخدذرزژسشصضطظعغفقکگلمنوهةی']+$/i, | ||
'hi-IN': /^[\u0900-\u0961]+[\u0972-\u097F]*$/i | ||
}; | ||
@@ -52,2 +54,3 @@ exports.alpha = alpha; | ||
'es-ES': /^[0-9A-ZÁÉÍÑÓÚÜ]+$/i, | ||
'fi-FI': /^[0-9A-ZÅÄÖ]+$/i, | ||
'fr-FR': /^[0-9A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i, | ||
@@ -74,3 +77,4 @@ 'it-IT': /^[0-9A-ZÀÉÈÌÎÓÒÙ]+$/i, | ||
he: /^[0-9א-ת]+$/, | ||
fa: /^['0-9آاءأؤئبپتثجچحخدذرزژسشصضطظعغفقکگلمنوهةی۱۲۳۴۵۶۷۸۹۰']+$/i | ||
fa: /^['0-9آاءأؤئبپتثجچحخدذرزژسشصضطظعغفقکگلمنوهةی۱۲۳۴۵۶۷۸۹۰']+$/i, | ||
'hi-IN': /^[\u0900-\u0963]+[\u0966-\u097F]*$/i | ||
}; | ||
@@ -116,3 +120,3 @@ exports.alphanumeric = alphanumeric; | ||
exports.dotDecimal = dotDecimal; | ||
var commaDecimal = ['bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en-ZM', 'es-ES', 'fr-CA', 'fr-FR', 'id-ID', 'it-IT', 'ku-IQ', 'hu-HU', 'nb-NO', 'nn-NO', 'nl-NL', 'pl-PL', 'pt-PT', 'ru-RU', 'sl-SI', 'sr-RS@latin', 'sr-RS', 'sv-SE', 'tr-TR', 'uk-UA', 'vi-VN']; | ||
var commaDecimal = ['bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en-ZM', 'es-ES', 'fr-CA', 'fr-FR', 'id-ID', 'it-IT', 'ku-IQ', 'hi-IN', 'hu-HU', 'nb-NO', 'nn-NO', 'nl-NL', 'pl-PL', 'pt-PT', 'ru-RU', 'sl-SI', 'sr-RS@latin', 'sr-RS', 'sv-SE', 'tr-TR', 'uk-UA', 'vi-VN']; | ||
exports.commaDecimal = commaDecimal; | ||
@@ -119,0 +123,0 @@ |
@@ -17,3 +17,4 @@ "use strict"; | ||
var defaulContainsOptions = { | ||
ignoreCase: false | ||
ignoreCase: false, | ||
minOccurrences: 1 | ||
}; | ||
@@ -24,3 +25,8 @@ | ||
options = (0, _merge.default)(options, defaulContainsOptions); | ||
return options.ignoreCase ? str.toLowerCase().indexOf((0, _toString.default)(elem).toLowerCase()) >= 0 : str.indexOf((0, _toString.default)(elem)) >= 0; | ||
if (options.ignoreCase) { | ||
return str.toLowerCase().split((0, _toString.default)(elem).toLowerCase()).length > options.minOccurrences; | ||
} | ||
return str.split((0, _toString.default)(elem)).length > options.minOccurrences; | ||
} | ||
@@ -27,0 +33,0 @@ |
@@ -21,3 +21,3 @@ "use strict"; | ||
if (_isISO31661Alpha.CountryCodes.indexOf(str.slice(4, 6).toUpperCase()) < 0) { | ||
if (!_isISO31661Alpha.CountryCodes.has(str.slice(4, 6).toUpperCase())) { | ||
return false; | ||
@@ -24,0 +24,0 @@ } |
@@ -12,5 +12,17 @@ "use strict"; | ||
var defaultOptions = { | ||
loose: false | ||
}; | ||
var strictBooleans = ['true', 'false', '1', '0']; | ||
var looseBooleans = [].concat(strictBooleans, ['yes', 'no']); | ||
function isBoolean(str) { | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultOptions; | ||
(0, _assertString.default)(str); | ||
return ['true', 'false', '1', '0'].indexOf(str) >= 0; | ||
if (options.loose) { | ||
return looseBooleans.includes(str.toLowerCase()); | ||
} | ||
return strictBooleans.includes(str); | ||
} | ||
@@ -17,0 +29,0 @@ |
@@ -13,3 +13,3 @@ "use strict"; | ||
/* eslint-disable max-len */ | ||
var creditCard = /^(?:4[0-9]{12}(?:[0-9]{3,6})?|5[1-5][0-9]{14}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12,15}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11}|6[27][0-9]{14})$/; | ||
var creditCard = /^(?:4[0-9]{12}(?:[0-9]{3,6})?|5[1-5][0-9]{14}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12,15}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11}|6[27][0-9]{14}|^(81[0-9]{14,17}))$/; | ||
/* eslint-enable max-len */ | ||
@@ -16,0 +16,0 @@ |
@@ -33,3 +33,3 @@ "use strict"; | ||
function isValidFormat(format) { | ||
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); | ||
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); | ||
} | ||
@@ -36,0 +36,0 @@ |
@@ -26,3 +26,4 @@ "use strict"; | ||
blacklisted_chars: '', | ||
ignore_max_length: false | ||
ignore_max_length: false, | ||
host_blacklist: [] | ||
}; | ||
@@ -111,5 +112,10 @@ /* eslint-disable max-len */ | ||
var domain = parts.pop(); | ||
var user = parts.join('@'); | ||
var lower_domain = domain.toLowerCase(); | ||
if (options.host_blacklist.includes(lower_domain)) { | ||
return false; | ||
} | ||
var user = parts.join('@'); | ||
if (options.domain_specific_validation && (lower_domain === 'gmail.com' || lower_domain === 'googlemail.com')) { | ||
@@ -127,3 +133,3 @@ /* | ||
if (!(0, _isByteLength.default)(username.replace('.', ''), { | ||
if (!(0, _isByteLength.default)(username.replace(/\./g, ''), { | ||
min: 6, | ||
@@ -130,0 +136,0 @@ max: 30 |
@@ -18,3 +18,4 @@ "use strict"; | ||
allow_trailing_dot: false, | ||
allow_numeric_tld: false | ||
allow_numeric_tld: false, | ||
allow_wildcard: false | ||
}; | ||
@@ -30,3 +31,9 @@ | ||
} | ||
/* Remove the optional wildcard before checking validity */ | ||
if (options.allow_wildcard === true && str.indexOf('*.') === 0) { | ||
str = str.substring(2); | ||
} | ||
var parts = str.split('.'); | ||
@@ -41,8 +48,8 @@ var tld = parts[parts.length - 1]; | ||
if (!/^([a-z\u00a1-\uffff]{2,}|xn[a-z0-9-]{2,})$/i.test(tld)) { | ||
if (!/^([a-z\u00A1-\u00A8\u00AA-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}|xn[a-z0-9-]{2,})$/i.test(tld)) { | ||
return false; | ||
} // disallow spaces && special characers | ||
} // disallow spaces | ||
if (/[\s\u2002-\u200B\u202F\u205F\u3000\uFEFF\uDB40\uDC20\u00A9\uFFFD]/.test(tld)) { | ||
if (/\s/.test(tld)) { | ||
return false; | ||
@@ -49,0 +56,0 @@ } |
@@ -7,2 +7,3 @@ "use strict"; | ||
exports.default = isIBAN; | ||
exports.locales = void 0; | ||
@@ -149,3 +150,3 @@ var _assertString = _interopRequireDefault(require("./util/assertString")); | ||
module.exports = exports.default; | ||
module.exports.default = exports.default; | ||
var locales = Object.keys(ibanRegexThroughCountryCode); | ||
exports.locales = locales; |
@@ -10,5 +10,40 @@ "use strict"; | ||
var _isInt = _interopRequireDefault(require("./isInt")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var validators = { | ||
PL: function PL(str) { | ||
(0, _assertString.default)(str); | ||
var weightOfDigits = { | ||
1: 1, | ||
2: 3, | ||
3: 7, | ||
4: 9, | ||
5: 1, | ||
6: 3, | ||
7: 7, | ||
8: 9, | ||
9: 1, | ||
10: 3, | ||
11: 0 | ||
}; | ||
if (str != null && str.length === 11 && (0, _isInt.default)(str, { | ||
allow_leading_zeroes: true | ||
})) { | ||
var digits = str.split('').slice(0, -1); | ||
var sum = digits.reduce(function (acc, digit, index) { | ||
return acc + Number(digit) * weightOfDigits[index + 1]; | ||
}, 0); | ||
var modulo = sum % 10; | ||
var lastDigit = Number(str.charAt(str.length - 1)); | ||
if (modulo === 0 && lastDigit === 0 || lastDigit === 10 - modulo) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
}, | ||
ES: function ES(str) { | ||
@@ -36,2 +71,20 @@ (0, _assertString.default)(str); | ||
}, | ||
FI: function FI(str) { | ||
// https://dvv.fi/en/personal-identity-code#:~:text=control%20character%20for%20a-,personal,-identity%20code%20calculated | ||
(0, _assertString.default)(str); | ||
if (str.length !== 11) { | ||
return false; | ||
} | ||
if (!str.match(/^\d{6}[\-A\+]\d{3}[0-9ABCDEFHJKLMNPRSTUVWXY]{1}$/)) { | ||
return false; | ||
} | ||
var checkDigits = '0123456789ABCDEFHJKLMNPRSTUVWXY'; | ||
var idAsNumber = parseInt(str.slice(0, 6), 10) * 1000 + parseInt(str.slice(7, 10), 10); | ||
var remainder = idAsNumber % 31; | ||
var checkDigit = checkDigits[remainder]; | ||
return checkDigit === str.slice(10, 11); | ||
}, | ||
IN: function IN(str) { | ||
@@ -89,2 +142,19 @@ var DNI = /^[1-9]\d{3}\s?\d{4}\s?\d{4}$/; // multiplication table | ||
}, | ||
TH: function TH(str) { | ||
if (!str.match(/^[1-8]\d{12}$/)) return false; // validate check digit | ||
var sum = 0; | ||
for (var i = 0; i < 12; i++) { | ||
sum += parseInt(str[i], 10) * (13 - i); | ||
} | ||
return str[12] === ((11 - sum % 11) % 10).toString(); | ||
}, | ||
LK: function LK(str) { | ||
var old_nic = /^[1-9]\d{8}[vx]$/i; | ||
var new_nic = /^[1-9]\d{11}$/i; | ||
if (str.length === 10 && old_nic.test(str)) return true;else if (str.length === 12 && new_nic.test(str)) return true; | ||
return false; | ||
}, | ||
'he-IL': function heIL(str) { | ||
@@ -91,0 +161,0 @@ var DNI = /^\d{9}$/; // sanitize user input |
@@ -14,7 +14,7 @@ "use strict"; | ||
// from https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 | ||
var validISO31661Alpha2CountriesCodes = ['AD', 'AE', 'AF', 'AG', 'AI', 'AL', 'AM', 'AO', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AW', 'AX', 'AZ', 'BA', 'BB', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ', 'BL', 'BM', 'BN', 'BO', 'BQ', 'BR', 'BS', 'BT', 'BV', 'BW', 'BY', 'BZ', 'CA', 'CC', 'CD', 'CF', 'CG', 'CH', 'CI', 'CK', 'CL', 'CM', 'CN', 'CO', 'CR', 'CU', 'CV', 'CW', 'CX', 'CY', 'CZ', 'DE', 'DJ', 'DK', 'DM', 'DO', 'DZ', 'EC', 'EE', 'EG', 'EH', 'ER', 'ES', 'ET', 'FI', 'FJ', 'FK', 'FM', 'FO', 'FR', 'GA', 'GB', 'GD', 'GE', 'GF', 'GG', 'GH', 'GI', 'GL', 'GM', 'GN', 'GP', 'GQ', 'GR', 'GS', 'GT', 'GU', 'GW', 'GY', 'HK', 'HM', 'HN', 'HR', 'HT', 'HU', 'ID', 'IE', 'IL', 'IM', 'IN', 'IO', 'IQ', 'IR', 'IS', 'IT', 'JE', 'JM', 'JO', 'JP', 'KE', 'KG', 'KH', 'KI', 'KM', 'KN', 'KP', 'KR', 'KW', 'KY', 'KZ', 'LA', 'LB', 'LC', 'LI', 'LK', 'LR', 'LS', 'LT', 'LU', 'LV', 'LY', 'MA', 'MC', 'MD', 'ME', 'MF', 'MG', 'MH', 'MK', 'ML', 'MM', 'MN', 'MO', 'MP', 'MQ', 'MR', 'MS', 'MT', 'MU', 'MV', 'MW', 'MX', 'MY', 'MZ', 'NA', 'NC', 'NE', 'NF', 'NG', 'NI', 'NL', 'NO', 'NP', 'NR', 'NU', 'NZ', 'OM', 'PA', 'PE', 'PF', 'PG', 'PH', 'PK', 'PL', 'PM', 'PN', 'PR', 'PS', 'PT', 'PW', 'PY', 'QA', 'RE', 'RO', 'RS', 'RU', 'RW', 'SA', 'SB', 'SC', 'SD', 'SE', 'SG', 'SH', 'SI', 'SJ', 'SK', 'SL', 'SM', 'SN', 'SO', 'SR', 'SS', 'ST', 'SV', 'SX', 'SY', 'SZ', 'TC', 'TD', 'TF', 'TG', 'TH', 'TJ', 'TK', 'TL', 'TM', 'TN', 'TO', 'TR', 'TT', 'TV', 'TW', 'TZ', 'UA', 'UG', 'UM', 'US', 'UY', 'UZ', 'VA', 'VC', 'VE', 'VG', 'VI', 'VN', 'VU', 'WF', 'WS', 'YE', 'YT', 'ZA', 'ZM', 'ZW']; | ||
var validISO31661Alpha2CountriesCodes = new Set(['AD', 'AE', 'AF', 'AG', 'AI', 'AL', 'AM', 'AO', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AW', 'AX', 'AZ', 'BA', 'BB', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ', 'BL', 'BM', 'BN', 'BO', 'BQ', 'BR', 'BS', 'BT', 'BV', 'BW', 'BY', 'BZ', 'CA', 'CC', 'CD', 'CF', 'CG', 'CH', 'CI', 'CK', 'CL', 'CM', 'CN', 'CO', 'CR', 'CU', 'CV', 'CW', 'CX', 'CY', 'CZ', 'DE', 'DJ', 'DK', 'DM', 'DO', 'DZ', 'EC', 'EE', 'EG', 'EH', 'ER', 'ES', 'ET', 'FI', 'FJ', 'FK', 'FM', 'FO', 'FR', 'GA', 'GB', 'GD', 'GE', 'GF', 'GG', 'GH', 'GI', 'GL', 'GM', 'GN', 'GP', 'GQ', 'GR', 'GS', 'GT', 'GU', 'GW', 'GY', 'HK', 'HM', 'HN', 'HR', 'HT', 'HU', 'ID', 'IE', 'IL', 'IM', 'IN', 'IO', 'IQ', 'IR', 'IS', 'IT', 'JE', 'JM', 'JO', 'JP', 'KE', 'KG', 'KH', 'KI', 'KM', 'KN', 'KP', 'KR', 'KW', 'KY', 'KZ', 'LA', 'LB', 'LC', 'LI', 'LK', 'LR', 'LS', 'LT', 'LU', 'LV', 'LY', 'MA', 'MC', 'MD', 'ME', 'MF', 'MG', 'MH', 'MK', 'ML', 'MM', 'MN', 'MO', 'MP', 'MQ', 'MR', 'MS', 'MT', 'MU', 'MV', 'MW', 'MX', 'MY', 'MZ', 'NA', 'NC', 'NE', 'NF', 'NG', 'NI', 'NL', 'NO', 'NP', 'NR', 'NU', 'NZ', 'OM', 'PA', 'PE', 'PF', 'PG', 'PH', 'PK', 'PL', 'PM', 'PN', 'PR', 'PS', 'PT', 'PW', 'PY', 'QA', 'RE', 'RO', 'RS', 'RU', 'RW', 'SA', 'SB', 'SC', 'SD', 'SE', 'SG', 'SH', 'SI', 'SJ', 'SK', 'SL', 'SM', 'SN', 'SO', 'SR', 'SS', 'ST', 'SV', 'SX', 'SY', 'SZ', 'TC', 'TD', 'TF', 'TG', 'TH', 'TJ', 'TK', 'TL', 'TM', 'TN', 'TO', 'TR', 'TT', 'TV', 'TW', 'TZ', 'UA', 'UG', 'UM', 'US', 'UY', 'UZ', 'VA', 'VC', 'VE', 'VG', 'VI', 'VN', 'VU', 'WF', 'WS', 'YE', 'YT', 'ZA', 'ZM', 'ZW']); | ||
function isISO31661Alpha2(str) { | ||
(0, _assertString.default)(str); | ||
return validISO31661Alpha2CountriesCodes.indexOf(str.toUpperCase()) >= 0; | ||
return validISO31661Alpha2CountriesCodes.has(str.toUpperCase()); | ||
} | ||
@@ -21,0 +21,0 @@ |
@@ -10,12 +10,10 @@ "use strict"; | ||
var _includes = _interopRequireDefault(require("./util/includes")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
// from https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3 | ||
var validISO31661Alpha3CountriesCodes = ['AFG', 'ALA', 'ALB', 'DZA', 'ASM', 'AND', 'AGO', 'AIA', 'ATA', 'ATG', 'ARG', 'ARM', 'ABW', 'AUS', 'AUT', 'AZE', 'BHS', 'BHR', 'BGD', 'BRB', 'BLR', 'BEL', 'BLZ', 'BEN', 'BMU', 'BTN', 'BOL', 'BES', 'BIH', 'BWA', 'BVT', 'BRA', 'IOT', 'BRN', 'BGR', 'BFA', 'BDI', 'KHM', 'CMR', 'CAN', 'CPV', 'CYM', 'CAF', 'TCD', 'CHL', 'CHN', 'CXR', 'CCK', 'COL', 'COM', 'COG', 'COD', 'COK', 'CRI', 'CIV', 'HRV', 'CUB', 'CUW', 'CYP', 'CZE', 'DNK', 'DJI', 'DMA', 'DOM', 'ECU', 'EGY', 'SLV', 'GNQ', 'ERI', 'EST', 'ETH', 'FLK', 'FRO', 'FJI', 'FIN', 'FRA', 'GUF', 'PYF', 'ATF', 'GAB', 'GMB', 'GEO', 'DEU', 'GHA', 'GIB', 'GRC', 'GRL', 'GRD', 'GLP', 'GUM', 'GTM', 'GGY', 'GIN', 'GNB', 'GUY', 'HTI', 'HMD', 'VAT', 'HND', 'HKG', 'HUN', 'ISL', 'IND', 'IDN', 'IRN', 'IRQ', 'IRL', 'IMN', 'ISR', 'ITA', 'JAM', 'JPN', 'JEY', 'JOR', 'KAZ', 'KEN', 'KIR', 'PRK', 'KOR', 'KWT', 'KGZ', 'LAO', 'LVA', 'LBN', 'LSO', 'LBR', 'LBY', 'LIE', 'LTU', 'LUX', 'MAC', 'MKD', 'MDG', 'MWI', 'MYS', 'MDV', 'MLI', 'MLT', 'MHL', 'MTQ', 'MRT', 'MUS', 'MYT', 'MEX', 'FSM', 'MDA', 'MCO', 'MNG', 'MNE', 'MSR', 'MAR', 'MOZ', 'MMR', 'NAM', 'NRU', 'NPL', 'NLD', 'NCL', 'NZL', 'NIC', 'NER', 'NGA', 'NIU', 'NFK', 'MNP', 'NOR', 'OMN', 'PAK', 'PLW', 'PSE', 'PAN', 'PNG', 'PRY', 'PER', 'PHL', 'PCN', 'POL', 'PRT', 'PRI', 'QAT', 'REU', 'ROU', 'RUS', 'RWA', 'BLM', 'SHN', 'KNA', 'LCA', 'MAF', 'SPM', 'VCT', 'WSM', 'SMR', 'STP', 'SAU', 'SEN', 'SRB', 'SYC', 'SLE', 'SGP', 'SXM', 'SVK', 'SVN', 'SLB', 'SOM', 'ZAF', 'SGS', 'SSD', 'ESP', 'LKA', 'SDN', 'SUR', 'SJM', 'SWZ', 'SWE', 'CHE', 'SYR', 'TWN', 'TJK', 'TZA', 'THA', 'TLS', 'TGO', 'TKL', 'TON', 'TTO', 'TUN', 'TUR', 'TKM', 'TCA', 'TUV', 'UGA', 'UKR', 'ARE', 'GBR', 'USA', 'UMI', 'URY', 'UZB', 'VUT', 'VEN', 'VNM', 'VGB', 'VIR', 'WLF', 'ESH', 'YEM', 'ZMB', 'ZWE']; | ||
var validISO31661Alpha3CountriesCodes = new Set(['AFG', 'ALA', 'ALB', 'DZA', 'ASM', 'AND', 'AGO', 'AIA', 'ATA', 'ATG', 'ARG', 'ARM', 'ABW', 'AUS', 'AUT', 'AZE', 'BHS', 'BHR', 'BGD', 'BRB', 'BLR', 'BEL', 'BLZ', 'BEN', 'BMU', 'BTN', 'BOL', 'BES', 'BIH', 'BWA', 'BVT', 'BRA', 'IOT', 'BRN', 'BGR', 'BFA', 'BDI', 'KHM', 'CMR', 'CAN', 'CPV', 'CYM', 'CAF', 'TCD', 'CHL', 'CHN', 'CXR', 'CCK', 'COL', 'COM', 'COG', 'COD', 'COK', 'CRI', 'CIV', 'HRV', 'CUB', 'CUW', 'CYP', 'CZE', 'DNK', 'DJI', 'DMA', 'DOM', 'ECU', 'EGY', 'SLV', 'GNQ', 'ERI', 'EST', 'ETH', 'FLK', 'FRO', 'FJI', 'FIN', 'FRA', 'GUF', 'PYF', 'ATF', 'GAB', 'GMB', 'GEO', 'DEU', 'GHA', 'GIB', 'GRC', 'GRL', 'GRD', 'GLP', 'GUM', 'GTM', 'GGY', 'GIN', 'GNB', 'GUY', 'HTI', 'HMD', 'VAT', 'HND', 'HKG', 'HUN', 'ISL', 'IND', 'IDN', 'IRN', 'IRQ', 'IRL', 'IMN', 'ISR', 'ITA', 'JAM', 'JPN', 'JEY', 'JOR', 'KAZ', 'KEN', 'KIR', 'PRK', 'KOR', 'KWT', 'KGZ', 'LAO', 'LVA', 'LBN', 'LSO', 'LBR', 'LBY', 'LIE', 'LTU', 'LUX', 'MAC', 'MKD', 'MDG', 'MWI', 'MYS', 'MDV', 'MLI', 'MLT', 'MHL', 'MTQ', 'MRT', 'MUS', 'MYT', 'MEX', 'FSM', 'MDA', 'MCO', 'MNG', 'MNE', 'MSR', 'MAR', 'MOZ', 'MMR', 'NAM', 'NRU', 'NPL', 'NLD', 'NCL', 'NZL', 'NIC', 'NER', 'NGA', 'NIU', 'NFK', 'MNP', 'NOR', 'OMN', 'PAK', 'PLW', 'PSE', 'PAN', 'PNG', 'PRY', 'PER', 'PHL', 'PCN', 'POL', 'PRT', 'PRI', 'QAT', 'REU', 'ROU', 'RUS', 'RWA', 'BLM', 'SHN', 'KNA', 'LCA', 'MAF', 'SPM', 'VCT', 'WSM', 'SMR', 'STP', 'SAU', 'SEN', 'SRB', 'SYC', 'SLE', 'SGP', 'SXM', 'SVK', 'SVN', 'SLB', 'SOM', 'ZAF', 'SGS', 'SSD', 'ESP', 'LKA', 'SDN', 'SUR', 'SJM', 'SWZ', 'SWE', 'CHE', 'SYR', 'TWN', 'TJK', 'TZA', 'THA', 'TLS', 'TGO', 'TKL', 'TON', 'TTO', 'TUN', 'TUR', 'TKM', 'TCA', 'TUV', 'UGA', 'UKR', 'ARE', 'GBR', 'USA', 'UMI', 'URY', 'UZB', 'VUT', 'VEN', 'VNM', 'VGB', 'VIR', 'WLF', 'ESH', 'YEM', 'ZMB', 'ZWE']); | ||
function isISO31661Alpha3(str) { | ||
(0, _assertString.default)(str); | ||
return (0, _includes.default)(validISO31661Alpha3CountriesCodes, str.toUpperCase()); | ||
return validISO31661Alpha3CountriesCodes.has(str.toUpperCase()); | ||
} | ||
@@ -22,0 +20,0 @@ |
@@ -13,2 +13,5 @@ "use strict"; | ||
var validators = { | ||
'cs-CZ': function csCZ(str) { | ||
return /^(([ABCDEFHKIJKLMNPRSTUVXYZ]|[0-9])-?){5,8}$/.test(str); | ||
}, | ||
'de-DE': function deDE(str) { | ||
@@ -20,2 +23,5 @@ return /^((AW|UL|AK|GA|AÖ|LF|AZ|AM|AS|ZE|AN|AB|A|KG|KH|BA|EW|BZ|HY|KM|BT|HP|B|BC|BI|BO|FN|TT|ÜB|BN|AH|BS|FR|HB|ZZ|BB|BK|BÖ|OC|OK|CW|CE|C|CO|LH|CB|KW|LC|LN|DA|DI|DE|DH|SY|NÖ|DO|DD|DU|DN|D|EI|EA|EE|FI|EM|EL|EN|PF|ED|EF|ER|AU|ZP|E|ES|NT|EU|FL|FO|FT|FF|F|FS|FD|FÜ|GE|G|GI|GF|GS|ZR|GG|GP|GR|NY|ZI|GÖ|GZ|GT|HA|HH|HM|HU|WL|HZ|WR|RN|HK|HD|HN|HS|GK|HE|HF|RZ|HI|HG|HO|HX|IK|IL|IN|J|JL|KL|KA|KS|KF|KE|KI|KT|KO|KN|KR|KC|KU|K|LD|LL|LA|L|OP|LM|LI|LB|LU|LÖ|HL|LG|MD|GN|MZ|MA|ML|MR|MY|AT|DM|MC|NZ|RM|RG|MM|ME|MB|MI|FG|DL|HC|MW|RL|MK|MG|MÜ|WS|MH|M|MS|NU|NB|ND|NM|NK|NW|NR|NI|NF|DZ|EB|OZ|TG|TO|N|OA|GM|OB|CA|EH|FW|OF|OL|OE|OG|BH|LR|OS|AA|GD|OH|KY|NP|WK|PB|PA|PE|PI|PS|P|PM|PR|RA|RV|RE|R|H|SB|WN|RS|RD|RT|BM|NE|GV|RP|SU|GL|RO|GÜ|RH|EG|RW|PN|SK|MQ|RU|SZ|RI|SL|SM|SC|HR|FZ|VS|SW|SN|CR|SE|SI|SO|LP|SG|NH|SP|IZ|ST|BF|TE|HV|OD|SR|S|AC|DW|ZW|TF|TS|TR|TÜ|UM|PZ|TP|UE|UN|UH|MN|KK|VB|V|AE|PL|RC|VG|GW|PW|VR|VK|KB|WA|WT|BE|WM|WE|AP|MO|WW|FB|WZ|WI|WB|JE|WF|WO|W|WÜ|BL|Z|GC)[- ]?[A-Z]{1,2}[- ]?\d{1,4}|(AIC|FDB|ABG|SLN|SAW|KLZ|BUL|ESB|NAB|SUL|WST|ABI|AZE|BTF|KÖT|DKB|FEU|ROT|ALZ|SMÜ|WER|AUR|NOR|DÜW|BRK|HAB|TÖL|WOR|BAD|BAR|BER|BIW|EBS|KEM|MÜB|PEG|BGL|BGD|REI|WIL|BKS|BIR|WAT|BOR|BOH|BOT|BRB|BLK|HHM|NEB|NMB|WSF|LEO|HDL|WMS|WZL|BÜS|CHA|KÖZ|ROD|WÜM|CLP|NEC|COC|ZEL|COE|CUX|DAH|LDS|DEG|DEL|RSL|DLG|DGF|LAN|HEI|MED|DON|KIB|ROK|JÜL|MON|SLE|EBE|EIC|HIG|WBS|BIT|PRÜ|LIB|EMD|WIT|ERH|HÖS|ERZ|ANA|ASZ|MAB|MEK|STL|SZB|FDS|HCH|HOR|WOL|FRG|GRA|WOS|FRI|FFB|GAP|GER|BRL|CLZ|GTH|NOH|HGW|GRZ|LÖB|NOL|WSW|DUD|HMÜ|OHA|KRU|HAL|HAM|HBS|QLB|HVL|NAU|HAS|EBN|GEO|HOH|HDH|ERK|HER|WAN|HEF|ROF|HBN|ALF|HSK|USI|NAI|REH|SAN|KÜN|ÖHR|HOL|WAR|ARN|BRG|GNT|HOG|WOH|KEH|MAI|PAR|RID|ROL|KLE|GEL|KUS|KYF|ART|SDH|LDK|DIL|MAL|VIB|LER|BNA|GHA|GRM|MTL|WUR|LEV|LIF|STE|WEL|LIP|VAI|LUP|HGN|LBZ|LWL|PCH|STB|DAN|MKK|SLÜ|MSP|TBB|MGH|MTK|BIN|MSH|EIL|HET|SGH|BID|MYK|MSE|MST|MÜR|WRN|MEI|GRH|RIE|MZG|MIL|OBB|BED|FLÖ|MOL|FRW|SEE|SRB|AIB|MOS|BCH|ILL|SOB|NMS|NEA|SEF|UFF|NEW|VOH|NDH|TDO|NWM|GDB|GVM|WIS|NOM|EIN|GAN|LAU|HEB|OHV|OSL|SFB|ERB|LOS|BSK|KEL|BSB|MEL|WTL|OAL|FÜS|MOD|OHZ|OPR|BÜR|PAF|PLÖ|CAS|GLA|REG|VIT|ECK|SIM|GOA|EMS|DIZ|GOH|RÜD|SWA|NES|KÖN|MET|LRO|BÜZ|DBR|ROS|TET|HRO|ROW|BRV|HIP|PAN|GRI|SHK|EIS|SRO|SOK|LBS|SCZ|MER|QFT|SLF|SLS|HOM|SLK|ASL|BBG|SBK|SFT|SHG|MGN|MEG|ZIG|SAD|NEN|OVI|SHA|BLB|SIG|SON|SPN|FOR|GUB|SPB|IGB|WND|STD|STA|SDL|OBG|HST|BOG|SHL|PIR|FTL|SEB|SÖM|SÜW|TIR|SAB|TUT|ANG|SDT|LÜN|LSZ|MHL|VEC|VER|VIE|OVL|ANK|OVP|SBG|UEM|UER|WLG|GMN|NVP|RDG|RÜG|DAU|FKB|WAF|WAK|SLZ|WEN|SOG|APD|WUG|GUN|ESW|WIZ|WES|DIN|BRA|BÜD|WHV|HWI|GHC|WTM|WOB|WUN|MAK|SEL|OCH|HOT|WDA)[- ]?(([A-Z][- ]?\d{1,4})|([A-Z]{2}[- ]?\d{1,3})))[- ]?(E|H)?$/.test(str); | ||
}, | ||
'fi-FI': function fiFI(str) { | ||
return /^(?=.{4,7})(([A-Z]{1,3}|[0-9]{1,3})[\s-]?([A-Z]{1,3}|[0-9]{1,5}))$/.test(str); | ||
}, | ||
'pt-PT': function ptPT(str) { | ||
@@ -22,0 +28,0 @@ return /^([A-Z]{2}|[0-9]{2})[ -·]?([A-Z]{2}|[0-9]{2})[ -·]?([A-Z]{2}|[0-9]{2})$/.test(str); |
@@ -12,3 +12,3 @@ "use strict"; | ||
var magnetURI = /^magnet:\?xt=urn:[a-z0-9]+:[a-z0-9]{32,40}&dn=.+&tr=.+$/i; | ||
var magnetURI = /^magnet:\?xt(?:\.1)?=urn:(?:aich|bitprint|btih|ed2k|ed2khash|kzhash|md5|sha1|tree:tiger):[a-z0-9]{32}(?:[a-z0-9]{8})?($|&)/i; | ||
@@ -15,0 +15,0 @@ function isMagnetURI(url) { |
@@ -27,2 +27,3 @@ "use strict"; | ||
'ar-OM': /^((\+|00)968)?(9[1-9])\d{6}$/, | ||
'ar-PS': /^(\+?970|0)5[6|9](\d{7})$/, | ||
'ar-SA': /^(!?(\+?966)|0)?5\d{8}$/, | ||
@@ -39,11 +40,14 @@ 'ar-SY': /^(!?(\+?963)|0)?9\d{8}$/, | ||
'da-DK': /^(\+?45)?\s?\d{2}\s?\d{2}\s?\d{2}\s?\d{2}$/, | ||
'de-DE': /^(\+49)?0?[1|3]([0|5][0-45-9]\d|6([23]|0\d?)|7([0-57-9]|6\d))\d{7}$/, | ||
'de-DE': /^((\+49|0)[1|3])([0|5][0-45-9]\d|6([23]|0\d?)|7([0-57-9]|6\d))\d{7,9}$/, | ||
'de-AT': /^(\+43|0)\d{1,4}\d{3,12}$/, | ||
'de-CH': /^(\+41|0)([1-9])\d{1,9}$/, | ||
'de-LU': /^(\+352)?((6\d1)\d{6})$/, | ||
'dv-MV': /^(\+?960)?(7[2-9]|91|9[3-9])\d{7}$/, | ||
'el-GR': /^(\+?30|0)?(69\d{8})$/, | ||
'en-AU': /^(\+?61|0)4\d{8}$/, | ||
'en-BM': /^(\+?1)?441(((3|7)\d{6}$)|(5[0-3][0-9]\d{4}$)|(59\d{5}))/, | ||
'en-GB': /^(\+?44|0)7\d{9}$/, | ||
'en-GG': /^(\+?44|0)1481\d{6}$/, | ||
'en-GH': /^(\+233|0)(20|50|24|54|27|57|26|56|23|28|55|59)\d{7}$/, | ||
'en-GY': /^(\+592|0)6\d{6}$/, | ||
'en-HK': /^(\+?852[-\s]?)?[456789]\d{3}[-\s]?\d{4}$/, | ||
@@ -54,7 +58,9 @@ 'en-MO': /^(\+?853[-\s]?)?[6]\d{3}[-\s]?\d{4}$/, | ||
'en-KE': /^(\+?254|0)(7|1)\d{8}$/, | ||
'en-KI': /^((\+686|686)?)?( )?((6|7)(2|3|8)[0-9]{6})$/, | ||
'en-MT': /^(\+?356|0)?(99|79|77|21|27|22|25)[0-9]{6}$/, | ||
'en-MU': /^(\+?230|0)?\d{8}$/, | ||
'en-NA': /^(\+?264|0)(6|8)\d{7}$/, | ||
'en-NG': /^(\+?234|0)?[789]\d{9}$/, | ||
'en-NZ': /^(\+?64|0)[28]\d{7,9}$/, | ||
'en-PK': /^((\+92)|(0092))-{0,1}\d{3}-{0,1}\d{7}$|^\d{11}$|^\d{4}-\d{7}$/, | ||
'en-PK': /^((00|\+)?92|0)3[0-6]\d{8}$/, | ||
'en-PH': /^(09|\+639)\d{9}$/, | ||
@@ -70,2 +76,3 @@ 'en-RW': /^(\+?250|0)?[7]\d{8}$/, | ||
'en-ZW': /^(\+263)[0-9]{9}$/, | ||
'en-BW': /^(\+?267)?(7[1-8]{1})\d{6}$/, | ||
'es-AR': /^\+?549(11|[2368]\d)\d{8}$/, | ||
@@ -76,2 +83,3 @@ 'es-BO': /^(\+?591)?(6|7)\d{7}$/, | ||
'es-CR': /^(\+506)?[2-8]\d{7}$/, | ||
'es-CU': /^(\+53|0053)?5\d{7}/, | ||
'es-DO': /^(\+?1)?8[024]9\d{7}$/, | ||
@@ -85,3 +93,5 @@ 'es-HN': /^(\+?504)?[9|8]\d{7}$/, | ||
'es-PY': /^(\+?595|0)9[9876]\d{7}$/, | ||
'es-SV': /^(\+?503)?[67]\d{7}$/, | ||
'es-UY': /^(\+598|0)9[1-9][\d]{6}$/, | ||
'es-VE': /^(\+?58)?(2|4)\d{9}$/, | ||
'et-EE': /^(\+?372)?\s?(5|8[1-4])\s?([0-9]\s?){6,7}$/, | ||
@@ -92,2 +102,4 @@ 'fa-IR': /^(\+?98[\-\s]?|0)9[0-39]\d[\-\s]?\d{3}[\-\s]?\d{4}$/, | ||
'fo-FO': /^(\+?298)?\s?\d{2}\s?\d{2}\s?\d{2}$/, | ||
'fr-BF': /^(\+226|0)[67]\d{7}$/, | ||
'fr-CM': /^(\+?237)6[0-9]{8}$/, | ||
'fr-FR': /^(\+?33|0)[67]\d{8}$/, | ||
@@ -97,5 +109,6 @@ 'fr-GF': /^(\+?594|0|00594)[67]\d{8}$/, | ||
'fr-MQ': /^(\+?596|0|00596)[67]\d{8}$/, | ||
'fr-PF': /^(\+?689)?8[789]\d{6}$/, | ||
'fr-RE': /^(\+?262|0|00262)[67]\d{8}$/, | ||
'he-IL': /^(\+972|0)([23489]|5[012345689]|77)[1-9]\d{6}$/, | ||
'hu-HU': /^(\+?36)(20|30|70)\d{7}$/, | ||
'hu-HU': /^(\+?36|06)(20|30|31|50|70)\d{7}$/, | ||
'id-ID': /^(\+?62|0)8(1[123456789]|2[1238]|3[1238]|5[12356789]|7[78]|9[56789]|8[123456789])([\s?|\d]{5,11})$/, | ||
@@ -115,3 +128,3 @@ 'it-IT': /^(\+?39)?\s?3\d{2} ?\d{6,7}$/, | ||
'ne-NP': /^(\+?977)?9[78]\d{8}$/, | ||
'nl-BE': /^(\+?32|0)4?\d{8}$/, | ||
'nl-BE': /^(\+?32|0)4\d{8}$/, | ||
'nl-NL': /^(((\+|00)?31\(0\))|((\+|00)?31)|0)6{1}\d{8}$/, | ||
@@ -125,3 +138,3 @@ 'nn-NO': /^(\+?47)?[49]\d{7}$/, | ||
'ru-RU': /^(\+?7|8)?9\d{9}$/, | ||
'si-LK': /^(?:0|94|\+94)?(7(0|1|2|5|6|7|8)( |-)?\d)\d{6}$/, | ||
'si-LK': /^(?:0|94|\+94)?(7(0|1|2|4|5|6|7|8)( |-)?)\d{7}$/, | ||
'sl-SI': /^(\+386\s?|0)(\d{1}\s?\d{3}\s?\d{2}\s?\d{2}|\d{2}\s?\d{3}\s?\d{3})$/, | ||
@@ -132,9 +145,12 @@ 'sk-SK': /^(\+?421)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/, | ||
'sv-SE': /^(\+?46|0)[\s\-]?7[\s\-]?[02369]([\s\-]?\d){7}$/, | ||
'tg-TJ': /^(\+?992)?[5][5]\d{7}$/, | ||
'th-TH': /^(\+66|66|0)\d{9}$/, | ||
'tr-TR': /^(\+?90|0)?5\d{9}$/, | ||
'tk-TM': /^(\+993|993|8)\d{8}$/, | ||
'uk-UA': /^(\+?38|8)?0\d{9}$/, | ||
'uz-UZ': /^(\+?998)?(6[125-79]|7[1-69]|88|9\d)\d{7}$/, | ||
'vi-VN': /^(\+?84|0)((3([2-9]))|(5([2689]))|(7([0|6-9]))|(8([1-9]))|(9([0-9])))([0-9]{7})$/, | ||
'zh-CN': /^((\+|00)86)?1([3456789][0-9]|4[579]|6[67]|7[01235678]|9[012356789])[0-9]{8}$/, | ||
'zh-TW': /^(\+?886\-?|0)?9\d{8}$/ | ||
'vi-VN': /^((\+?84)|0)((3([2-9]))|(5([25689]))|(7([0|6-9]))|(8([1-9]))|(9([0-9])))([0-9]{7})$/, | ||
'zh-CN': /^((\+|00)86)?(1[3-9]|9[28])\d{9}$/, | ||
'zh-TW': /^(\+?886\-?|0)?9\d{8}$/, | ||
'dz-BT': /^(\+?975|0)?(17|16|77|02)\d{6}$/ | ||
}; | ||
@@ -141,0 +157,0 @@ /* eslint-enable max-len */ |
@@ -39,4 +39,4 @@ "use strict"; | ||
// SWITZERLAND | ||
CN: /^[GE]\d{8}$/, | ||
// CHINA [G=Ordinary, E=Electronic] followed by 8-digits | ||
CN: /^G\d{8}$|^E(?![IO])[A-Z0-9]\d{7}$/, | ||
// CHINA [G=Ordinary, E=Electronic] followed by 8-digits, or E followed by any UPPERCASE letter (except I and O) followed by 7 digits | ||
CY: /^[A-Z](\d{6}|\d{8})$/, | ||
@@ -72,2 +72,4 @@ // CYPRUS | ||
// INDIA | ||
ID: /^[A-C]\d{7}$/, | ||
// INDONESIA | ||
IR: /^[A-Z]\d{8}$/, | ||
@@ -99,3 +101,3 @@ // IRAN | ||
// NETHERLANDS | ||
PO: /^[A-Z]{2}\d{7}$/, | ||
PL: /^[A-Z]{2}\d{7}$/, | ||
// POLAND | ||
@@ -106,3 +108,3 @@ PT: /^[A-Z]\d{6}$/, | ||
// ROMANIA | ||
RU: /^\d{2}\d{2}\d{6}$/, | ||
RU: /^\d{9}$/, | ||
// RUSSIAN FEDERATION | ||
@@ -109,0 +111,0 @@ SE: /^\d{8}$/, |
@@ -58,2 +58,3 @@ "use strict"; | ||
LV: /^LV\-\d{4}$/, | ||
LK: fiveDigit, | ||
MX: fiveDigit, | ||
@@ -60,0 +61,0 @@ MT: /^[A-Za-z]{3}\s{0,1}\d{4}$/, |
@@ -25,3 +25,3 @@ "use strict"; | ||
var fullTime = new RegExp("".concat(partialTime.source).concat(timeOffset.source)); | ||
var rfc3339 = new RegExp("".concat(fullDate.source, "[ tT]").concat(fullTime.source)); | ||
var rfc3339 = new RegExp("^".concat(fullDate.source, "[ tT]").concat(fullTime.source, "$")); | ||
@@ -28,0 +28,0 @@ function isRFC3339(str) { |
@@ -1106,11 +1106,7 @@ "use strict"; | ||
function ptBrCheck(tin) { | ||
tin = tin.replace(/[^\d]+/g, ''); | ||
if (tin === '') return false; | ||
if (tin.length === 11) { | ||
var _sum; | ||
var ramainder; | ||
var remainder; | ||
_sum = 0; | ||
tin = tin.replace(/[^\d]+/g, ''); | ||
if ( // Reject known invalid CPFs | ||
@@ -1123,5 +1119,5 @@ tin === '11111111111' || tin === '22222222222' || tin === '33333333333' || tin === '44444444444' || tin === '55555555555' || tin === '66666666666' || tin === '77777777777' || tin === '88888888888' || tin === '99999999999' || tin === '00000000000') return false; | ||
ramainder = _sum * 10 % 11; | ||
if (ramainder === 10 || ramainder === 11) ramainder = 0; | ||
if (ramainder !== parseInt(tin.substring(9, 10), 10)) return false; | ||
remainder = _sum * 10 % 11; | ||
if (remainder === 10) remainder = 0; | ||
if (remainder !== parseInt(tin.substring(9, 10), 10)) return false; | ||
_sum = 0; | ||
@@ -1133,12 +1129,8 @@ | ||
ramainder = _sum * 10 % 11; | ||
if (ramainder === 10 || ramainder === 11) ramainder = 0; | ||
if (ramainder !== parseInt(tin.substring(10, 11), 10)) return false; | ||
remainder = _sum * 10 % 11; | ||
if (remainder === 10) remainder = 0; | ||
if (remainder !== parseInt(tin.substring(10, 11), 10)) return false; | ||
return true; | ||
} | ||
if (tin.length !== 14) { | ||
return false; | ||
} | ||
if ( // Reject know invalid CNPJs | ||
@@ -1450,3 +1442,3 @@ tin === '00000000000000' || tin === '11111111111111' || tin === '22222222222222' || tin === '33333333333333' || tin === '44444444444444' || tin === '55555555555555' || tin === '66666666666666' || tin === '77777777777777' || tin === '88888888888888' || tin === '99999999999999') { | ||
'pl-PL': /^\d{10,11}$/, | ||
'pt-BR': /^\d{11,14}$/, | ||
'pt-BR': /(?:^\d{11}$)|(?:^\d{14}$)/, | ||
'pt-PT': /^\d{9}$/, | ||
@@ -1453,0 +1445,0 @@ 'ro-RO': /^\d{13}$/, |
@@ -18,2 +18,14 @@ "use strict"; | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } | ||
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."); } | ||
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); } | ||
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; } | ||
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
/* | ||
@@ -41,2 +53,4 @@ options for isURL method | ||
allow_protocol_relative_urls: false, | ||
allow_fragments: true, | ||
allow_query_components: true, | ||
validate_length: true | ||
@@ -79,2 +93,10 @@ }; | ||
if (!options.allow_fragments && url.includes('#')) { | ||
return false; | ||
} | ||
if (!options.allow_query_components && (url.includes('?') || url.includes('&'))) { | ||
return false; | ||
} | ||
var protocol, auth, host, hostname, port, port_str, split, ipv6; | ||
@@ -123,3 +145,3 @@ split = url.split('#'); | ||
if (split[0] === '' || split[0].substr(0, 1) === ':') { | ||
if (split[0] === '') { | ||
return false; | ||
@@ -133,2 +155,11 @@ } | ||
} | ||
var _auth$split = auth.split(':'), | ||
_auth$split2 = _slicedToArray(_auth$split, 2), | ||
user = _auth$split2[0], | ||
password = _auth$split2[1]; | ||
if (user === '' && password === '') { | ||
return false; | ||
} | ||
} | ||
@@ -154,3 +185,3 @@ | ||
if (port_str !== null) { | ||
if (port_str !== null && port_str.length > 0) { | ||
port = parseInt(port_str, 10); | ||
@@ -165,2 +196,6 @@ | ||
if (options.host_whitelist) { | ||
return checkHost(host, options.host_whitelist); | ||
} | ||
if (!(0, _isIP.default)(host) && !(0, _isFQDN.default)(host, options) && (!ipv6 || !(0, _isIP.default)(ipv6, 6))) { | ||
@@ -172,6 +207,2 @@ return false; | ||
if (options.host_whitelist && !checkHost(host, options.host_whitelist)) { | ||
return false; | ||
} | ||
if (options.host_blacklist && checkHost(host, options.host_blacklist)) { | ||
@@ -178,0 +209,0 @@ return false; |
@@ -13,2 +13,4 @@ "use strict"; | ||
var uuid = { | ||
1: /^[0-9A-F]{8}-[0-9A-F]{4}-1[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i, | ||
2: /^[0-9A-F]{8}-[0-9A-F]{4}-2[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i, | ||
3: /^[0-9A-F]{8}-[0-9A-F]{4}-3[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i, | ||
@@ -20,7 +22,6 @@ 4: /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i, | ||
function isUUID(str) { | ||
var version = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'all'; | ||
function isUUID(str, version) { | ||
(0, _assertString.default)(str); | ||
var pattern = uuid[version]; | ||
return pattern && pattern.test(str); | ||
var pattern = uuid[![undefined, null].includes(version) ? version : 'all']; | ||
return !!pattern && pattern.test(str); | ||
} | ||
@@ -27,0 +28,0 @@ |
@@ -15,3 +15,4 @@ "use strict"; | ||
GB: /^GB((\d{3} \d{4} ([0-8][0-9]|9[0-6]))|(\d{9} \d{3})|(((GD[0-4])|(HA[5-9]))[0-9]{2}))$/, | ||
IT: /^(IT)?[0-9]{11}$/ | ||
IT: /^(IT)?[0-9]{11}$/, | ||
NL: /^(NL)?[0-9]{9}B[0-9]{2}$/ | ||
}; | ||
@@ -18,0 +19,0 @@ exports.vatMatchers = vatMatchers; |
@@ -13,6 +13,18 @@ "use strict"; | ||
function rtrim(str, chars) { | ||
(0, _assertString.default)(str); // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Escaping | ||
(0, _assertString.default)(str); | ||
var pattern = chars ? new RegExp("[".concat(chars.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), "]+$"), 'g') : /(\s)+$/g; | ||
return str.replace(pattern, ''); | ||
if (chars) { | ||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Escaping | ||
var pattern = new RegExp("[".concat(chars.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), "]+$"), 'g'); | ||
return str.replace(pattern, ''); | ||
} // Use a faster and more safe than regex trim method https://blog.stevenlevithan.com/archives/faster-trim-javascript | ||
var strIndex = str.length - 1; | ||
while (/\s/.test(str.charAt(strIndex))) { | ||
strIndex -= 1; | ||
} | ||
return str.slice(0, strIndex + 1); | ||
} | ||
@@ -19,0 +31,0 @@ |
@@ -14,3 +14,5 @@ "use strict"; | ||
(0, _assertString.default)(str); | ||
return str.replace(/&/g, '&').replace(/"/g, '"').replace(/'/g, "'").replace(/</g, '<').replace(/>/g, '>').replace(///g, '/').replace(/\/g, '\\').replace(/`/g, '`'); | ||
return str.replace(/"/g, '"').replace(/'/g, "'").replace(/</g, '<').replace(/>/g, '>').replace(///g, '/').replace(/\/g, '\\').replace(/`/g, '`').replace(/&/g, '&'); // & replacement has to be the last one to prevent | ||
// bugs with intermediate strings containing escape sequences | ||
// See: https://github.com/validatorjs/validator.js/issues/1827 | ||
} | ||
@@ -17,0 +19,0 @@ |
{ | ||
"name": "validator", | ||
"description": "String validation and sanitization", | ||
"version": "13.6.0", | ||
"version": "13.7.0", | ||
"sideEffects": false, | ||
@@ -49,5 +49,6 @@ "homepage": "https://github.com/validatorjs/validator.js", | ||
"mocha": "^6.2.3", | ||
"npm-run-all": "^4.1.5", | ||
"nyc": "^14.1.0", | ||
"rimraf": "^3.0.0", | ||
"rollup": "^0.43.0", | ||
"rollup": "^0.47.0", | ||
"rollup-plugin-babel": "^4.0.1", | ||
@@ -62,3 +63,3 @@ "uglify-js": "^3.0.19" | ||
"clean:browser": "rimraf validator*.js", | ||
"clean": "npm run clean:node && npm run clean:browser && npm run clean:es", | ||
"clean": "run-p clean:*", | ||
"minify": "uglifyjs validator.js -o validator.min.js --compress --mangle --comments /Copyright/", | ||
@@ -68,6 +69,5 @@ "build:browser": "node --require @babel/register build-browser && npm run minify", | ||
"build:node": "babel src -d .", | ||
"build": "npm run build:browser && npm run build:node && npm run build:es", | ||
"build": "run-p build:*", | ||
"pretest": "npm run build && npm run lint", | ||
"test": "nyc mocha --require @babel/register --reporter dot", | ||
"test:ci": "nyc report --reporter=text-lcov" | ||
"test": "nyc --reporter=cobertura --reporter=text-summary mocha --require @babel/register --reporter dot" | ||
}, | ||
@@ -74,0 +74,0 @@ "engines": { |
@@ -69,2 +69,8 @@ # validator.js | ||
CDN | ||
```html | ||
<script src="https://unpkg.com/validator@latest/validator.min.js"></script> | ||
``` | ||
## Contributors | ||
@@ -86,7 +92,7 @@ | ||
--------------------------------------- | -------------------------------------- | ||
**contains(str, seed [, options ])** | check if the string contains the seed.<br/><br/>`options` is an object that defaults to `{ ignoreCase: false}`.<br/>`ignoreCase` specified whether the case of the substring be same or not. | ||
**contains(str, seed [, options ])** | check if the string contains the seed.<br/><br/>`options` is an object that defaults to `{ ignoreCase: false, minOccurrences: 1 }`.<br />Options: <br/> `ignoreCase`: Ignore case when doing comparison, default false<br/>`minOccurences`: Minimum number of occurrences for the seed in the string. Defaults to 1. | ||
**equals(str, comparison)** | check if the string matches the comparison. | ||
**isAfter(str [, date])** | check if the string is a date that's after the specified date (defaults to now). | ||
**isAlpha(str [, locale, options])** | check if the string contains only letters (a-zA-Z).<br/><br/>Locale is one of `['ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-QA', 'ar-QM', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-ZA', 'en-ZM', 'es-ES', 'fa-IR', 'fr-CA', 'fr-FR', 'he', 'hu-HU', 'it-IT', 'ku-IQ', 'nb-NO', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ru-RU', 'sl-SI', 'sk-SK', 'sr-RS', 'sr-RS@latin', 'sv-SE', 'tr-TR', 'uk-UA']`) and defaults to `en-US`. Locale list is `validator.isAlphaLocales`. options is an optional object that can be supplied with the following key(s): ignore which can either be a String or RegExp of characters to be ignored e.g. " -" will ignore spaces and -'s. | ||
**isAlphanumeric(str [, locale, options])** | check if the string contains only letters and numbers (a-zA-Z0-9).<br/><br/>Locale is one of `['ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-QA', 'ar-QM', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-ZA', 'en-ZM', 'es-ES', 'fa-IR', 'fr-CA', 'fr-FR', 'he', 'hu-HU', 'it-IT', 'ku-IQ', 'nb-NO', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ru-RU', 'sl-SI', 'sk-SK', 'sr-RS', 'sr-RS@latin', 'sv-SE', 'tr-TR', 'uk-UA']`) and defaults to `en-US`. Locale list is `validator.isAlphanumericLocales`. options is an optional object that can be supplied with the following key(s): ignore which can either be a String or RegExp of characters to be ignored e.g. " -" will ignore spaces and -'s. | ||
**isAlpha(str [, locale, options])** | check if the string contains only letters (a-zA-Z).<br/><br/>Locale is one of `['ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-QA', 'ar-QM', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-ZA', 'en-ZM', 'es-ES', 'fa-IR', 'fi-FI', 'fr-CA', 'fr-FR', 'he', 'hi-IN', 'hu-HU', 'it-IT', 'ku-IQ', 'nb-NO', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ru-RU', 'sl-SI', 'sk-SK', 'sr-RS', 'sr-RS@latin', 'sv-SE', 'tr-TR', 'uk-UA']`) and defaults to `en-US`. Locale list is `validator.isAlphaLocales`. options is an optional object that can be supplied with the following key(s): ignore which can either be a String or RegExp of characters to be ignored e.g. " -" will ignore spaces and -'s. | ||
**isAlphanumeric(str [, locale, options])** | check if the string contains only letters and numbers (a-zA-Z0-9).<br/><br/>Locale is one of `['ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-QA', 'ar-QM', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-ZA', 'en-ZM', 'es-ES', 'fa-IR', 'fi-FI', 'fr-CA', 'fr-FR', 'he', 'hi-IN', 'hu-HU', 'it-IT', 'ku-IQ', 'nb-NO', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ru-RU', 'sl-SI', 'sk-SK', 'sr-RS', 'sr-RS@latin', 'sv-SE', 'tr-TR', 'uk-UA']`) and defaults to `en-US`. Locale list is `validator.isAlphanumericLocales`. options is an optional object that can be supplied with the following key(s): ignore which can either be a String or RegExp of characters to be ignored e.g. " -" will ignore spaces and -'s. | ||
**isAscii(str)** | check if the string contains ASCII chars only. | ||
@@ -98,3 +104,3 @@ **isBase32(str)** | check if a string is base32 encoded. | ||
**isBIC(str)** | check if a string is a BIC (Bank Identification Code) or SWIFT code. | ||
**isBoolean(str)** | check if a string is a boolean. | ||
**isBoolean(str [, options])** | check if a string is a boolean.<br/>`options` is an object which defaults to `{ loose: false }`. If loose is is set to false, the validator will strictly match ['true', 'false', '0', '1']. If loose is set to true, the validator will also match 'yes', 'no', and will match a valid boolean string of any case. (eg: ['true', 'True', 'TRUE']). | ||
**isBtcAddress(str)** | check if the string is a valid BTC address. | ||
@@ -109,7 +115,7 @@ **isByteLength(str [, options])** | check if the string's length (in UTF-8 bytes) falls in a range.<br/><br/>`options` is an object which defaults to `{min:0, max: undefined}`. | ||
**isEAN(str)** | check if the string is an EAN (European Article Number). | ||
**isEmail(str [, options])** | check if the string is an email.<br/><br/>`options` is an object which defaults to `{ allow_display_name: false, require_display_name: false, allow_utf8_local_part: true, require_tld: true, allow_ip_domain: false, domain_specific_validation: false, blacklisted_chars: '' }`. If `allow_display_name` is set to true, the validator will also match `Display Name <email-address>`. If `require_display_name` is set to true, the validator will reject strings without the format `Display Name <email-address>`. If `allow_utf8_local_part` is set to false, the validator will not allow any non-English UTF8 character in email address' local part. If `require_tld` is set to false, e-mail addresses without having TLD in their domain will also be matched. If `ignore_max_length` is set to true, the validator will not check for the standard max length of an email. If `allow_ip_domain` is set to true, the validator will allow IP addresses in the host part. If `domain_specific_validation` is true, some additional validation will be enabled, e.g. disallowing certain syntactically valid email addresses that are rejected by GMail. If `blacklisted_chars` receives a string, then the validator will reject emails that include any of the characters in the string, in the name part. | ||
**isEmail(str [, options])** | check if the string is an email.<br/><br/>`options` is an object which defaults to `{ allow_display_name: false, require_display_name: false, allow_utf8_local_part: true, require_tld: true, allow_ip_domain: false, domain_specific_validation: false, blacklisted_chars: '', host_blacklist: [] }`. If `allow_display_name` is set to true, the validator will also match `Display Name <email-address>`. If `require_display_name` is set to true, the validator will reject strings without the format `Display Name <email-address>`. If `allow_utf8_local_part` is set to false, the validator will not allow any non-English UTF8 character in email address' local part. If `require_tld` is set to false, e-mail addresses without having TLD in their domain will also be matched. If `ignore_max_length` is set to true, the validator will not check for the standard max length of an email. If `allow_ip_domain` is set to true, the validator will allow IP addresses in the host part. If `domain_specific_validation` is true, some additional validation will be enabled, e.g. disallowing certain syntactically valid email addresses that are rejected by GMail. If `blacklisted_chars` receives a string, then the validator will reject emails that include any of the characters in the string, in the name part. If `host_blacklist` is set to an array of strings and the part of the email after the `@` symbol matches one of the strings defined in it, the validation fails. | ||
**isEmpty(str [, options])** | check if the string has a length of zero.<br/><br/>`options` is an object which defaults to `{ ignore_whitespace:false }`. | ||
**isEthereumAddress(str)** | check if the string is an [Ethereum](https://ethereum.org/) address using basic regex. Does not validate address checksums. | ||
**isFloat(str [, options])** | check if the string is a float.<br/><br/>`options` is an object which can contain the keys `min`, `max`, `gt`, and/or `lt` to validate the float is within boundaries (e.g. `{ min: 7.22, max: 9.55 }`) it also has `locale` as an option.<br/><br/>`min` and `max` are equivalent to 'greater or equal' and 'less or equal', respectively while `gt` and `lt` are their strict counterparts.<br/><br/>`locale` determine the decimal separator and is one of `['ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-QA', 'ar-QM', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-ZA', 'en-ZM', 'es-ES', 'fr-CA', 'fr-FR', 'hu-HU', 'it-IT', 'nb-NO', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ru-RU', 'sl-SI', 'sr-RS', 'sr-RS@latin', 'sv-SE', 'tr-TR', 'uk-UA']`. Locale list is `validator.isFloatLocales`. | ||
**isFQDN(str [, options])** | check if the string is a fully qualified domain name (e.g. domain.com).<br/><br/>`options` is an object which defaults to `{ require_tld: true, allow_underscores: false, allow_trailing_dot: false , allow_numeric_tld: false }`. | ||
**isFQDN(str [, options])** | check if the string is a fully qualified domain name (e.g. domain.com).<br/><br/>`options` is an object which defaults to `{ require_tld: true, allow_underscores: false, allow_trailing_dot: false, allow_numeric_tld: false, allow_wildcard: false }`. If `allow_wildcard` is set to true, the validator will allow domain starting with `*.` (e.g. `*.example.com` or `*.shop.example.com`). | ||
**isFullWidth(str)** | check if the string contains any full-width chars. | ||
@@ -122,3 +128,3 @@ **isHalfWidth(str)** | check if the string contains any half-width chars. | ||
**isIBAN(str)** | check if a string is a IBAN (International Bank Account Number). | ||
**isIdentityCard(str [, locale])** | check if the string is a valid identity card code.<br/><br/>`locale` is one of `['ES', 'IN', 'IT', 'IR', 'MZ', 'NO', 'zh-TW', 'he-IL', 'ar-LY', 'ar-TN', 'zh-CN']` OR `'any'`. If 'any' is used, function will check if any of the locals match.<br/><br/>Defaults to 'any'. | ||
**isIdentityCard(str [, locale])** | check if the string is a valid identity card code.<br/><br/>`locale` is one of `['LK', 'PL', 'ES', 'FI', 'IN', 'IT', 'IR', 'MZ', 'NO', 'TH', 'zh-TW', 'he-IL', 'ar-LY', 'ar-TN', 'zh-CN']` OR `'any'`. If 'any' is used, function will check if any of the locals match.<br/><br/>Defaults to 'any'. | ||
**isIMEI(str [, options]))** | check if the string is a valid IMEI number. Imei should be of format `###############` or `##-######-######-#`.<br/><br/>`options` is an object which can contain the keys `allow_hyphens`. Defaults to first format . If allow_hyphens is set to true, the validator will validate the second format. | ||
@@ -134,2 +140,3 @@ **isIn(str, values)** | check if the string is in a array of allowed values. | ||
**isISO31661Alpha3(str)** | check if the string is a valid [ISO 3166-1 alpha-3](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3) officially assigned country code. | ||
**isISO4217(str)** | check if the string is a valid [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) officially assigned currency code. | ||
**isISRC(str)** | check if the string is a [ISRC](https://en.wikipedia.org/wiki/International_Standard_Recording_Code). | ||
@@ -141,3 +148,3 @@ **isISSN(str [, options])** | check if the string is an [ISSN](https://en.wikipedia.org/wiki/International_Standard_Serial_Number).<br/><br/>`options` is an object which defaults to `{ case_sensitive: false, require_hyphen: false }`. If `case_sensitive` is true, ISSNs with a lowercase `'x'` as the check digit are rejected. | ||
**isLength(str [, options])** | check if the string's length falls in a range.<br/><br/>`options` is an object which defaults to `{min:0, max: undefined}`. Note: this function takes into account surrogate pairs. | ||
**isLicensePlate(str [, locale])** | check if string matches the format of a country's license plate.<br/><br/>(locale is one of `['de-DE', 'de-LI', 'pt-PT', 'sq-AL', 'pt-BR'']` or `any`). | ||
**isLicensePlate(str [, locale])** | check if string matches the format of a country's license plate.<br/><br/>(locale is one of `['cs-CZ', 'de-DE', 'de-LI', 'fi-FI', pt-PT', 'sq-AL', 'pt-BR']` or `any`) | ||
**isLocale(str)** | check if the string is a locale | ||
@@ -149,3 +156,3 @@ **isLowercase(str)** | check if the string is lowercase. | ||
**isMimeType(str)** | check if the string matches to a valid [MIME type](https://en.wikipedia.org/wiki/Media_type) format | ||
**isMobilePhone(str [, locale [, options]])** | check if the string is a mobile phone number,<br/><br/>(locale is either an array of locales (e.g `['sk-SK', 'sr-RS']`) OR one of `['am-Am', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', ar-JO', 'ar-KW', 'ar-SA', 'ar-SY', 'ar-TN', 'az-AZ', 'az-LY', 'az-LB', 'bs-BA', 'be-BY', 'bg-BG', 'bn-BD', 'ca-AD', 'cs-CZ', 'da-DK', 'de-DE', 'de-AT', 'de-CH', 'de-LU', 'el-GR', 'en-AU', 'en-CA', 'en-GB', 'en-GG', 'en-GH', 'en-HK', 'en-MO', 'en-IE', 'en-IN', 'en-KE', 'en-MT', 'en-MU', 'en-NG', 'en-NZ', 'en-PK', 'en-PH', 'en-RW', 'en-SG', 'en-SL', 'en-UG', 'en-US', 'en-TZ', 'en-ZA', 'en-ZM', 'en-ZW', 'es-AR', 'es-BO', 'es-CL', 'es-CO', 'es-CR', 'es-DO', 'es-HN', 'es-PE', 'es-EC', 'es-ES', 'es-MX', 'es-PA', 'es-PY', 'es-UY', 'et-EE', 'fa-IR', 'fi-FI', 'fj-FJ', 'fo-FO', 'fr-BE', 'fr-FR', 'fr-GF', 'fr-GP', 'fr-MQ', 'fr-RE', 'ga-IE', 'he-IL', 'hu-HU', 'id-ID', 'it-IT', 'it-SM', 'ja-JP', 'ka-GE', 'kk-KZ', 'kl-GL', 'ko-KR', 'lt-LT', 'ms-MY', ''mz-MZ', nb-NO', 'ne-NP', 'nl-BE', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'pt-AO', 'ro-RO', 'ru-RU', 'si-LK' 'sl-SI', 'sk-SK', 'sq-AL', 'sr-RS', 'sv-SE', 'th-TH', 'tr-TR', 'uk-UA', 'uz-UZ', 'vi-VN', 'zh-CN', 'zh-HK', 'zh-MO', 'zh-TW']` OR defaults to 'any'. If 'any' or a falsey value is used, function will check if any of the locales match).<br/><br/>`options` is an optional object that can be supplied with the following keys: `strictMode`, if this is set to `true`, the mobile phone number must be supplied with the country code and therefore must start with `+`. Locale list is `validator.isMobilePhoneLocales`. | ||
**isMobilePhone(str [, locale [, options]])** | check if the string is a mobile phone number,<br/><br/>(locale is either an array of locales (e.g `['sk-SK', 'sr-RS']`) OR one of `['am-Am', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', ar-JO', 'ar-KW', 'ar-PS', 'ar-SA', 'ar-SY', 'ar-TN', 'az-AZ', 'az-LY', 'az-LB', 'bs-BA', 'be-BY', 'bg-BG', 'bn-BD', 'ca-AD', 'cs-CZ', 'da-DK', 'de-DE', 'de-AT', 'de-CH', 'de-LU', 'dv-MV', 'el-GR', 'en-AU', 'en-BM', 'en-BW', 'en-CA', 'en-GB', 'en-GG', 'en-GH', 'en-GY', 'en-HK', 'en-MO', 'en-IE', 'en-IN', 'en-KE', 'en-KI', 'en-MT', 'en-MU', 'en-NG', 'en-NZ', 'en-PK', 'en-PH', 'en-RW', 'en-SG', 'en-SL', 'en-UG', 'en-US', 'en-TZ', 'en-ZA', 'en-ZM', 'en-ZW', 'es-AR', 'es-BO', 'es-CL', 'es-CO', 'es-CR', 'es-CU', 'es-DO', 'es-HN', 'es-PE', 'es-EC', 'es-ES', 'es-MX', 'es-PA', 'es-PY', 'es-SV', 'es-UY', 'es-VE', 'et-EE', 'fa-IR', 'fi-FI', 'fj-FJ', 'fo-FO', 'fr-BE', 'fr-BF', 'fr-FR', 'fr-GF', 'fr-GP', 'fr-MQ', 'fr-PF', 'fr-RE', 'ga-IE', 'he-IL', 'hu-HU', 'id-ID', 'it-IT', 'it-SM', 'ja-JP', 'ka-GE', 'kk-KZ', 'kl-GL', 'ko-KR', 'lt-LT', 'ms-MY', ''mz-MZ', nb-NO', 'ne-NP', 'nl-BE', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'pt-AO', 'ro-RO', 'ru-RU', 'si-LK' 'sl-SI', 'sk-SK', 'sq-AL', 'sr-RS', 'sv-SE', 'tg-TJ', 'th-TH', 'tk-TM', 'tr-TR', 'uk-UA', 'uz-UZ', 'vi-VN', 'zh-CN', 'zh-HK', 'zh-MO', 'zh-TW', 'dz-BT']` OR defaults to 'any'. If 'any' or a falsey value is used, function will check if any of the locales match).<br/><br/>`options` is an optional object that can be supplied with the following keys: `strictMode`, if this is set to `true`, the mobile phone number must be supplied with the country code and therefore must start with `+`. Locale list is `validator.isMobilePhoneLocales`. | ||
**isMongoId(str)** | check if the string is a valid hex-encoded representation of a [MongoDB ObjectId][mongoid]. | ||
@@ -155,5 +162,5 @@ **isMultibyte(str)** | check if the string contains one or more multibyte chars. | ||
**isOctal(str)** | check if the string is a valid octal number. | ||
**isPassportNumber(str, countryCode)** | check if the string is a valid passport number.<br/><br/>(countryCode is one of `[ 'AM', 'AR', 'AT', 'AU', 'BE', 'BG', 'BY', 'BR', 'CA', 'CH', 'CN', 'CY', 'CZ', 'DE', 'DK', 'DZ', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HU', 'IE' 'IN', 'IR', 'IS', 'IT', 'JP', 'KR', 'LT', 'LU', 'LV', 'LY', 'MT', 'MY', 'MZ', 'NL', 'PO', 'PT', 'RO', 'RU', 'SE', 'SL', 'SK', 'TR', 'UA', 'US' ]`. | ||
**isPassportNumber(str, countryCode)** | check if the string is a valid passport number.<br/><br/>(countryCode is one of `[ 'AM', 'AR', 'AT', 'AU', 'BE', 'BG', 'BY', 'BR', 'CA', 'CH', 'CN', 'CY', 'CZ', 'DE', 'DK', 'DZ', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HU', 'IE' 'IN', 'IR', 'ID', 'IS', 'IT', 'JP', 'KR', 'LT', 'LU', 'LV', 'LY', 'MT', 'MY', 'MZ', 'NL', 'PL', 'PT', 'RO', 'RU', 'SE', 'SL', 'SK', 'TR', 'UA', 'US' ]`. | ||
**isPort(str)** | check if the string is a valid port number. | ||
**isPostalCode(str, locale)** | check if the string is a postal code,<br/><br/>(locale is one of `[ 'AD', 'AT', 'AU', 'AZ', 'BE', 'BG', 'BR', 'BY', 'CA', 'CH', 'CN', 'CZ', 'DE', 'DK', 'DO', 'DZ', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HT', 'HU', 'ID', 'IE' 'IL', 'IN', 'IR', 'IS', 'IT', 'JP', 'KE', 'KR', 'LI', 'LT', 'LU', 'LV', 'MT', 'MX', 'MY', 'NL', 'NO', 'NP', 'NZ', 'PL', 'PR', 'PT', 'RO', 'RU', 'SA', 'SE', 'SG', 'SI', 'TH', 'TN', 'TW', 'UA', 'US', 'ZA', 'ZM' ]` OR 'any'. If 'any' is used, function will check if any of the locals match. Locale list is `validator.isPostalCodeLocales`.). | ||
**isPostalCode(str, locale)** | check if the string is a postal code,<br/><br/>(locale is one of `[ 'AD', 'AT', 'AU', 'AZ', 'BE', 'BG', 'BR', 'BY', 'CA', 'CH', 'CN', 'CZ', 'DE', 'DK', 'DO', 'DZ', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HT', 'HU', 'ID', 'IE' 'IL', 'IN', 'IR', 'IS', 'IT', 'JP', 'KE', 'KR', 'LI', 'LK', 'LT', 'LU', 'LV', 'MT', 'MX', 'MY', 'NL', 'NO', 'NP', 'NZ', 'PL', 'PR', 'PT', 'RO', 'RU', 'SA', 'SE', 'SG', 'SI', 'TH', 'TN', 'TW', 'UA', 'US', 'ZA', 'ZM' ]` OR 'any'. If 'any' is used, function will check if any of the locals match. Locale list is `validator.isPostalCodeLocales`.). | ||
**isRFC3339(str)** | check if the string is a valid [RFC 3339](https://tools.ietf.org/html/rfc3339) date. | ||
@@ -167,6 +174,6 @@ **isRgbColor(str [, includePercentValues])** | check if the string is a rgb or rgba color.<br/><br/>`includePercentValues` defaults to `true`. If you don't want to allow to set `rgb` or `rgba` values with percents, like `rgb(5%,5%,5%)`, or `rgba(90%,90%,90%,.3)`, then set it to false. | ||
**isTaxID(str, locale)** | Check if the given value is a valid Tax Identification Number. Default locale is `en-US`.<br/><br/>More info about exact TIN support can be found in `src/lib/isTaxID.js`<br/><br/>Supported locales: `[ 'bg-BG', 'cs-CZ', 'de-AT', 'de-DE', 'dk-DK', 'el-CY', 'el-GR', 'en-GB', 'en-IE', 'en-US', 'es-ES', 'et-EE', 'fi-FI', 'fr-BE', 'fr-FR', 'fr-LU', 'hr-HR', 'hu-HU', 'it-IT', 'lb-LU', 'lt-LT', 'lv-LV' 'mt-MT', 'nl-BE', 'nl-NL', 'pl-PL', 'pt-BR', 'pt-PT', 'ro-RO', 'sk-SK', 'sl-SI', 'sv-SE' ]` | ||
**isURL(str [, options])** | check if the string is an URL.<br/><br/>`options` is an object which defaults to `{ protocols: ['http','https','ftp'], require_tld: true, require_protocol: false, require_host: true, require_port: false, require_valid_protocol: true, allow_underscores: false, host_whitelist: false, host_blacklist: false, allow_trailing_dot: false, allow_protocol_relative_urls: false, disallow_auth: false, validate_length: true }`.<br/><br/>require_protocol - if set as true isURL will return false if protocol is not present in the URL.<br/>require_valid_protocol - isURL will check if the URL's protocol is present in the protocols option.<br/>protocols - valid protocols can be modified with this option.<br/>require_host - if set as false isURL will not check if host is present in the URL.<br/>require_port - if set as true isURL will check if port is present in the URL.<br/>allow_protocol_relative_urls - if set as true protocol relative URLs will be allowed.<br/>validate_length - if set as false isURL will skip string length validation (2083 characters is IE max URL length). | ||
**isUUID(str [, version])** | check if the string is a UUID (version 3, 4 or 5). | ||
**isURL(str [, options])** | check if the string is an URL.<br/><br/>`options` is an object which defaults to `{ protocols: ['http','https','ftp'], require_tld: true, require_protocol: false, require_host: true, require_port: false, require_valid_protocol: true, allow_underscores: false, host_whitelist: false, host_blacklist: false, allow_trailing_dot: false, allow_protocol_relative_urls: false, allow_fragments: true, allow_query_components: true, disallow_auth: false, validate_length: true }`.<br/><br/>require_protocol - if set as true isURL will return false if protocol is not present in the URL.<br/>require_valid_protocol - isURL will check if the URL's protocol is present in the protocols option.<br/>protocols - valid protocols can be modified with this option.<br/>require_host - if set as false isURL will not check if host is present in the URL.<br/>require_port - if set as true isURL will check if port is present in the URL.<br/>allow_protocol_relative_urls - if set as true protocol relative URLs will be allowed.<br/>allow_fragments - if set as false isURL will return false if fragments are present.<br/>allow_query_components - if set as false isURL will return false if query components are present.<br/>validate_length - if set as false isURL will skip string length validation (2083 characters is IE max URL length). | ||
**isUUID(str [, version])** | check if the string is a UUID (version 1, 2, 3, 4 or 5). | ||
**isVariableWidth(str)** | check if the string contains a mixture of full and half-width chars. | ||
**isVAT(str, countryCode)** | checks that the string is a [valid VAT number](https://en.wikipedia.org/wiki/VAT_identification_number) if validation is available for the given country code matching [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2). <br/><br/>Available country codes: `[ 'GB', 'IT' ]`. | ||
**isVAT(str, countryCode)** | checks that the string is a [valid VAT number](https://en.wikipedia.org/wiki/VAT_identification_number) if validation is available for the given country code matching [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2). <br/><br/>Available country codes: `[ 'GB', 'IT','NL' ]`. | ||
**isWhitelisted(str, chars)** | checks characters if they appear in the whitelist. | ||
@@ -173,0 +180,0 @@ **matches(str, pattern [, modifiers])** | check if string matches the pattern.<br/><br/>Either `matches('foo', /foo/i)` or `matches('foo', 'foo', 'i')`. |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
209
0.48%13635
3.52%275
2.61%645753
-2.07%16
6.67%