validator
Advanced tools
Comparing version 8.1.0 to 8.2.0
@@ -0,1 +1,14 @@ | ||
#### 8.2.0 | ||
- Added an `isHash()` validator | ||
([#711](https://github.com/chriso/validator.js/pull/711)) | ||
- Control decimal places in `isCurrency()` | ||
([#713](https://github.com/chriso/validator.js/pull/713)) | ||
- New and improved locales | ||
([#700](https://github.com/chriso/validator.js/pull/700), | ||
[#701](https://github.com/chriso/validator.js/pull/701), | ||
[#714](https://github.com/chriso/validator.js/pull/714), | ||
[#715](https://github.com/chriso/validator.js/pull/715), | ||
[#718](https://github.com/chriso/validator.js/pull/718)) | ||
#### 8.1.0 | ||
@@ -2,0 +15,0 @@ |
@@ -135,2 +135,6 @@ 'use strict'; | ||
var _isHash = require('./lib/isHash'); | ||
var _isHash2 = _interopRequireDefault(_isHash); | ||
var _isJSON = require('./lib/isJSON'); | ||
@@ -262,3 +266,3 @@ | ||
var version = '8.1.0'; | ||
var version = '8.2.0'; | ||
@@ -299,2 +303,3 @@ var validator = { | ||
isMD5: _isMD2.default, | ||
isHash: _isHash2.default, | ||
isJSON: _isJSON2.default, | ||
@@ -301,0 +306,0 @@ isEmpty: _isEmpty2.default, |
@@ -13,4 +13,5 @@ 'use strict'; | ||
'fr-FR': /^[A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i, | ||
'it-IT': /^[A-ZÀÉÈÌÎÓÒÙ]+$/i, | ||
'nb-NO': /^[A-ZÆØÅ]+$/i, | ||
'nl-NL': /^[A-ZÉËÏÓÖÜ]+$/i, | ||
'nl-NL': /^[A-ZÁÉËÏÓÖÜÚ]+$/i, | ||
'nn-NO': /^[A-ZÆØÅ]+$/i, | ||
@@ -23,2 +24,3 @@ 'hu-HU': /^[A-ZÁÉÍÓÖŐÚÜŰ]+$/i, | ||
'sr-RS': /^[А-ЯЂЈЉЊЋЏ]+$/i, | ||
'sv-SE': /^[A-ZÅÄÖ]+$/i, | ||
'tr-TR': /^[A-ZÇĞİıÖŞÜ]+$/i, | ||
@@ -36,5 +38,6 @@ 'uk-UA': /^[А-ЩЬЮЯЄIЇҐ]+$/i, | ||
'fr-FR': /^[0-9A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i, | ||
'it-IT': /^[0-9A-ZÀÉÈÌÎÓÒÙ]+$/i, | ||
'hu-HU': /^[0-9A-ZÁÉÍÓÖŐÚÜŰ]+$/i, | ||
'nb-NO': /^[0-9A-ZÆØÅ]+$/i, | ||
'nl-NL': /^[0-9A-ZÉËÏÓÖÜ]+$/i, | ||
'nl-NL': /^[0-9A-ZÁÉËÏÓÖÜÚ]+$/i, | ||
'nn-NO': /^[0-9A-ZÆØÅ]+$/i, | ||
@@ -46,2 +49,3 @@ 'pl-PL': /^[0-9A-ZĄĆĘŚŁŃÓŻŹ]+$/i, | ||
'sr-RS': /^[0-9А-ЯЂЈЉЊЋЏ]+$/i, | ||
'sv-SE': /^[0-9A-ZÅÄÖ]+$/i, | ||
'tr-TR': /^[0-9A-ZÇĞİıÖŞÜ]+$/i, | ||
@@ -48,0 +52,0 @@ 'uk-UA': /^[0-9А-ЩЬЮЯЄIЇҐ]+$/i, |
@@ -19,2 +19,6 @@ 'use strict'; | ||
function currencyRegex(options) { | ||
var decimal_digits = '\\d{' + options.digits_after_decimal[0] + '}'; | ||
options.digits_after_decimal.forEach(function (digit, index) { | ||
if (index !== 0) decimal_digits = decimal_digits + '|\\d{' + digit + '}'; | ||
}); | ||
var symbol = '(\\' + options.symbol.replace(/\./g, '\\.') + ')' + (options.require_symbol ? '' : '?'), | ||
@@ -26,4 +30,4 @@ negative = '-?', | ||
whole_dollar_amount = '(' + valid_whole_dollar_amounts.join('|') + ')?', | ||
decimal_amount = '(\\' + options.decimal_separator + '\\d{2})?'; | ||
var pattern = whole_dollar_amount + decimal_amount; | ||
decimal_amount = '(\\' + options.decimal_separator + '(' + decimal_digits + '))' + (options.require_decimal ? '' : '?'); | ||
var pattern = whole_dollar_amount + (options.allow_decimal || options.require_decimal ? decimal_amount : ''); | ||
@@ -79,2 +83,5 @@ // default is negative sign before symbol, but there are two other options (besides parens) | ||
decimal_separator: '.', | ||
allow_decimal: true, | ||
require_decimal: false, | ||
digits_after_decimal: [2], | ||
allow_space_after_digits: false | ||
@@ -81,0 +88,0 @@ }; |
@@ -16,3 +16,6 @@ 'use strict'; | ||
var phones = { | ||
'ar-AE': /^((\+?971)|0)?5[024568]\d{7}$/, | ||
'ar-DZ': /^(\+?213|0)(5|6|7)\d{8}$/, | ||
'ar-EG': /^((\+?20)|0)?1[012]\d{8}$/, | ||
'ar-JO': /^(\+?962|0)?7[789]\d{7}$/, | ||
'ar-SY': /^(!?(\+?963)|0)?9\d{8}$/, | ||
@@ -22,2 +25,3 @@ 'ar-SA': /^(!?(\+?966)|0)?5\d{8}$/, | ||
'cs-CZ': /^(\+?420)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/, | ||
'sk-SK': /^(\+?421)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/, | ||
'de-DE': /^(\+?49[ \.\-])?([\(]{1}[0-9]{1,6}[\)])?([0-9 \.\-\/]{3,20})((x|ext|extension)[ ]?[0-9]{1,4})?$/, | ||
@@ -24,0 +28,0 @@ 'da-DK': /^(\+?45)?(\d{8})$/, |
@@ -6,2 +6,3 @@ 'use strict'; | ||
}); | ||
exports.locales = undefined; | ||
@@ -75,2 +76,2 @@ exports.default = function (str, locale) { | ||
module.exports = exports['default']; | ||
var locales = exports.locales = Object.keys(patterns); |
{ | ||
"name": "validator", | ||
"description": "String validation and sanitization", | ||
"version": "8.1.0", | ||
"version": "8.2.0", | ||
"homepage": "http://github.com/chriso/validator.js", | ||
@@ -48,2 +48,3 @@ "files": [ | ||
"lint": "eslint src test", | ||
"lint:fix": "eslint --fix src test", | ||
"clean:node": "rm -rf index.js lib", | ||
@@ -50,0 +51,0 @@ "clean:browser": "rm -rf validator*.js", |
186
README.md
@@ -7,2 +7,11 @@ # validator.js | ||
## Strings only | ||
**This library validates and sanitizes strings only.** | ||
If you're not sure if your input is a string, coerce it using `input + ''`. | ||
Passing anything other than a string is an error. | ||
## Installation and Usage | ||
### Server-side usage | ||
@@ -12,2 +21,4 @@ | ||
#### No ES6 | ||
```javascript | ||
@@ -48,88 +59,79 @@ var validator = require('validator'); | ||
### Strings only | ||
## Validators | ||
**This library validates and sanitizes strings only.** | ||
Here is a list of the validators currently available. | ||
If you're not sure if your input is a string, coerce it using `input + ''`. | ||
Passing anything other than a string is an error. | ||
Validator | Description | ||
--------------------------------------- | -------------------------------------- | ||
***contains(str, seed)*** | check if the string contains the seed. | ||
**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])** | 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', '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-FR', 'hu-HU', 'it-IT', 'nb-NO', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ru-RU', 'sr-RS', 'sr-RS@latin', 'sv-SE', 'tr-TR', 'uk-UA']`) and defaults to `en-US`. | ||
**isAlphanumeric(str [, locale])** | check if the string contains only letters and numbers.<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', '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-FR', 'hu-HU', 'it-IT', 'nb-NO', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ru-RU', 'sr-RS', 'sr-RS@latin', 'sv-SE', 'tr-TR', 'uk-UA']`) and defaults to `en-US`. | ||
**isAscii(str)** | check if the string contains ASCII chars only. | ||
**isBase64(str)** | check if a string is base64 encoded. | ||
**isBefore(str [, date])** | check if the string is a date that's before the specified date. | ||
**isBoolean(str)** | check if a string is a boolean. | ||
**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}`. | ||
**isCreditCard(str)** | check if the string is a credit card. | ||
**isCurrency(str, options)** | check if the string is a valid currency amount.<br/><br/>`options` is an object which defaults to `{symbol: '$', require_symbol: false, allow_space_after_symbol: false, symbol_after_digits: false, allow_negatives: true, parens_for_negatives: false, negative_sign_before_digits: false, negative_sign_after_digits: false, allow_negative_sign_placeholder: false, thousands_separator: ',', decimal_separator: '.', allow_decimal: true, require_decimal: false, digits_after_decimal: [2], allow_space_after_digits: false}`.<br/>**Note:** The array digits_after_decimal is filled with the exact number of digits allowd not a range, for example a range 1 to 3 will be given as [1, 2, 3]. | ||
**isDataURI(str)** | check if the string is a [data uri format](https://developer.mozilla.org/en-US/docs/Web/HTTP/data_URIs). | ||
**isDecimal(str)** | check if the string represents a decimal number, such as 0.1, .3, 1.1, 1.00003, 4.0, etc. | ||
**isDivisibleBy(str, number)** | check if the string is a number that's divisible by another. | ||
**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 }`. 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. | ||
**isEmpty(str)** | check if the string has a length of zero. | ||
**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 }`. | ||
**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 }`). `min` and `max` are equivalent to 'greater or equal' and 'less or equal', respectively while `gt` and `lt` are their strict counterparts. | ||
**isFullWidth(str)** | check if the string contains any full-width chars. | ||
**isHalfWidth(str)** | check if the string contains any half-width chars. | ||
**isHash(str, algorithm)** | check if the string is a hash of type algorithm.<br/><br/>Algorithm is one of `['md4', 'md5', 'sha1', 'sha256', 'sha384', 'sha512', 'ripemd128', 'ripemd160', 'tiger128', 'tiger160', 'tiger192', 'crc32', 'crc32b']` | ||
**isHexColor(str)** | check if the string is a hexadecimal color. | ||
**isHexadecimal(str)** | check if the string is a hexadecimal number. | ||
**isIP(str [, version])** | check if the string is an IP (version 4 or 6). | ||
**isISBN(str [, version])** | check if the string is an ISBN (version 10 or 13). | ||
**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. | ||
**isISIN(str)** | check if the string is an [ISIN][ISIN] (stock/security identifier). | ||
**isISO8601(str)** | check if the string is a valid [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date. | ||
**isISRC(str)** | check if the string is a [ISRC](https://en.wikipedia.org/wiki/International_Standard_Recording_Code). | ||
**isIn(str, values)** | check if the string is in a array of allowed values. | ||
**isInt(str [, options])** | check if the string is an integer.<br/><br/>`options` is an object which can contain the keys `min` and/or `max` to check the integer is within boundaries (e.g. `{ min: 10, max: 99 }`). `options` can also contain the key `allow_leading_zeroes`, which when set to false will disallow integer values with leading zeroes (e.g. `{ allow_leading_zeroes: false }`). Finally, `options` can contain the keys `gt` and/or `lt` which will enforce integers being greater than or less than, respectively, the value provided (e.g. `{gt: 1, lt: 4}` for a number between 1 and 4). | ||
**isJSON(str)** | check if the string is valid JSON (note: uses JSON.parse). | ||
**isLatLong(str)** | check if the string is a valid latitude-longitude coordinate. | ||
**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. | ||
**isLowercase(str)** | check if the string is lowercase. | ||
**isMACAddress(str)** | check if the string is a MAC address. | ||
**isMD5(str)** | check if the string is a MD5 hash. | ||
**isMobilePhone(str, locale)** | check if the string is a mobile phone number,<br/><br/>(locale is one of `['ar-AE', 'ar-DZ','ar-EG', 'ar-JO', 'ar-SA', 'ar-SY', 'cs-CZ', 'de-DE', 'da-DK', 'el-GR', 'en-AU', 'en-CA', 'en-GB', 'en-HK', 'en-IN', 'en-KE', 'en-NG', 'en-NZ', 'en-RW', 'en-UG', 'en-US', 'en-TZ', 'en-ZA', 'en-ZM', 'es-ES', 'en-PK', 'fa-IR', 'fi-FI', 'fr-FR', 'he-IL', 'hu-HU', 'it-IT', 'ja-JP', 'ko-KR', 'lt-LT', 'ms-MY', 'nb-NO', 'nn-NO', 'pl-PL', 'pt-PT', 'ro-RO', 'ru-RU', 'sk-SK', 'sr-RS', 'tr-TR', 'vi-VN', 'zh-CN', 'zh-HK', 'zh-TW']` OR 'any'. If 'any' is used, function will check if any of the locales match). | ||
**isMongoId(str)** | check if the string is a valid hex-encoded representation of a [MongoDB ObjectId][mongoid]. | ||
**isMultibyte(str)** | check if the string contains one or more multibyte chars. | ||
**isNumeric(str)** | check if the string contains only numbers. | ||
**isPostalCode(str, locale)** | check if the string is a postal code,<br/><br/>(locale is one of `[ 'AT', 'AU', 'BE', 'CA', 'CH', 'CZ', 'DE', 'DK', 'DZ', 'ES', 'FI', 'FR', 'GB', 'GR', 'IL', 'IN', 'IS', 'IT', 'JP', 'KE', 'LI', 'MX', 'NL', 'NO', 'PL', 'PT', 'RO', 'RU', 'SA', 'SE', 'TW', 'US', 'ZA', 'ZM' ]` OR 'any'. If 'any' is used, function will check if any of the locals match). | ||
**isSurrogatePair(str)** | check if the string contains any surrogate pairs chars. | ||
**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_valid_protocol: true, allow_underscores: false, host_whitelist: false, host_blacklist: false, allow_trailing_dot: false, allow_protocol_relative_urls: false }`. | ||
**isUUID(str [, version])** | check if the string is a UUID (version 3, 4 or 5). | ||
**isUppercase(str)** | check if the string is uppercase. | ||
**isVariableWidth(str)** | check if the string contains a mixture of full and half-width chars. | ||
**isWhitelisted(str, chars)** | checks characters if they appear in the whitelist. | ||
**matches(str, pattern [, modifiers])** | check if string matches the pattern.<br/><br/>Either `matches('foo', /foo/i)` or `matches('foo', 'foo', 'i')`. | ||
### Validators | ||
## Sanitizers | ||
- **contains(str, seed)** - check if the string contains the seed. | ||
- **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])** - check if the string contains only letters (a-zA-Z). 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', '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-FR', 'hu-HU', 'nb-NO', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ru-RU', 'sr-RS', 'sr-RS@latin', 'tr-TR', 'uk-UA']`) and defaults to `en-US`. | ||
- **isAlphanumeric(str [, locale])** - check if the string contains only letters and numbers. 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', '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-FR', 'fr-BE', 'hu-HU', 'nl-BE', 'nb-NO', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ru-RU', 'sr-RS', 'sr-RS@latin', 'tr-TR', 'uk-UA']`) and defaults to `en-US`. | ||
- **isAscii(str)** - check if the string contains ASCII chars only. | ||
- **isBase64(str)** - check if a string is base64 encoded. | ||
- **isBefore(str [, date])** - check if the string is a date that's before the specified date. | ||
- **isBoolean(str)** - check if a string is a boolean. | ||
- **isByteLength(str, options)** - check if the string's length (in UTF-8 bytes) falls in a range. `options` is an object which defaults to `{min:0, max: undefined}`. | ||
- **isCreditCard(str)** - check if the string is a credit card. | ||
- **isCurrency(str, options)** - check if the string is a valid currency amount. `options` is an object which defaults to `{symbol: '$', require_symbol: false, allow_space_after_symbol: false, symbol_after_digits: false, allow_negatives: true, parens_for_negatives: false, negative_sign_before_digits: false, negative_sign_after_digits: false, allow_negative_sign_placeholder: false, thousands_separator: ',', decimal_separator: '.', allow_space_after_digits: false }`. | ||
- **isDataURI(str)** - check if the string is a [data uri format](https://developer.mozilla.org/en-US/docs/Web/HTTP/data_URIs). | ||
- **isDecimal(str)** - check if the string represents a decimal number, such as 0.1, .3, 1.1, 1.00003, 4.0, etc. | ||
- **isDivisibleBy(str, number)** - check if the string is a number that's divisible by another. | ||
- **isEmail(str [, options])** - check if the string is an email. `options` is an object which defaults to `{ allow_display_name: false, require_display_name: false, allow_utf8_local_part: true, require_tld: true }`. 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. | ||
- **isEmpty(str)** - check if the string has a length of zero. | ||
- **isFQDN(str [, options])** - check if the string is a fully qualified domain name (e.g. domain.com). `options` is an object which defaults to `{ require_tld: true, allow_underscores: false, allow_trailing_dot: false }`. | ||
- **isFloat(str [, options])** - check if the string is a float. `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 }`). `min` and `max` are equivalent to 'greater or equal' and 'less or equal', respectively while `gt` and `lt` are their strict counterparts. | ||
- **isFullWidth(str)** - check if the string contains any full-width chars. | ||
- **isHalfWidth(str)** - check if the string contains any half-width chars. | ||
- **isHexColor(str)** - check if the string is a hexadecimal color. | ||
- **isHexadecimal(str)** - check if the string is a hexadecimal number. | ||
- **isIP(str [, version])** - check if the string is an IP (version 4 or 6). | ||
- **isISBN(str [, version])** - check if the string is an ISBN (version 10 or 13). | ||
- **isISSN(str [, options])** - check if the string is an [ISSN](https://en.wikipedia.org/wiki/International_Standard_Serial_Number). `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. | ||
- **isISIN(str)** - check if the string is an [ISIN][ISIN] (stock/security identifier). | ||
- **isISO8601(str)** - check if the string is a valid [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date. | ||
- **isISRC(str)** - check if the string is a [ISRC](https://en.wikipedia.org/wiki/International_Standard_Recording_Code). | ||
- **isIn(str, values)** - check if the string is in a array of allowed values. | ||
- **isInt(str [, options])** - check if the string is an integer. `options` is an object which can contain the keys `min` and/or `max` to check the integer is within boundaries (e.g. `{ min: 10, max: 99 }`). `options` can also contain the key `allow_leading_zeroes`, which when set to false will disallow integer values with leading zeroes (e.g. `{ allow_leading_zeroes: false }`). Finally, `options` can contain the keys `gt` and/or `lt` which will enforce integers being greater than or less than, respectively, the value provided (e.g. `{gt: 1, lt: 4}` for a number between 1 and 4). | ||
- **isJSON(str)** - check if the string is valid JSON (note: uses JSON.parse). | ||
- **isLatLong(str)** - check if the string is a valid latitude-longitude coordinate. | ||
- **isLength(str, options)** - check if the string's length falls in a range. `options` is an object which defaults to `{min:0, max: undefined}`. Note: this function takes into account surrogate pairs. | ||
- **isLowercase(str)** - check if the string is lowercase. | ||
- **isMACAddress(str)** - check if the string is a MAC address. | ||
- **isMD5(str)** - check if the string is a MD5 hash. | ||
- **isMobilePhone(str, locale)** - check if the string is a mobile phone number, (locale is one of `['ar-DZ', 'ar-SA', 'ar-SY', 'cs-CZ', 'de-DE', 'da-DK', 'el-GR', 'en-AU', 'en-CA', 'en-GB', 'en-HK', 'en-IN', 'en-KE', 'en-NG', 'en-NZ', 'en-RW', 'en-UG', 'en-US', 'en-TZ', 'en-ZA', 'en-ZM', 'es-ES', 'en-PK', 'fa-IR', 'fi-FI', 'fr-FR', 'he-IL', 'hu-HU', 'it-IT', 'ja-JP', 'ko-KR', 'lt-LT', 'ms-MY', 'nb-NO', 'nn-NO', 'pl-PL', 'pt-PT', 'ro-RO', 'ru-RU', 'sr-RS', 'tr-TR', 'vi-VN', 'zh-CN', 'zh-HK', 'zh-TW']` OR 'any'. If 'any' is used, function will check if any of the locales match). | ||
- **isMongoId(str)** - check if the string is a valid hex-encoded representation of a [MongoDB ObjectId][mongoid]. | ||
- **isMultibyte(str)** - check if the string contains one or more multibyte chars. | ||
- **isNumeric(str)** - check if the string contains only numbers. | ||
- **isPostalCode(str, locale)** - check if the string is a postal code, (locale is one of `[ 'AT','AU','BE','CA','CH','CZ','DE','DK','DZ','ES','FI','FR','GB','GR','IL','IN','IS','IT','JP','KE','LI','MX','NL','NO','PL','PT','RO','RU','SA','SE','TW','US','ZA','ZM' ]` OR 'any'. If 'any' is used, function will check if any of the locals match). | ||
- **isSurrogatePair(str)** - check if the string contains any surrogate pairs chars. | ||
- **isURL(str [, options])** - check if the string is an URL. `options` is an object which defaults to `{ protocols: ['http','https','ftp'], require_tld: true, require_protocol: false, require_host: true, require_valid_protocol: true, allow_underscores: false, host_whitelist: false, host_blacklist: false, allow_trailing_dot: false, allow_protocol_relative_urls: false }`. | ||
- **isUUID(str [, version])** - check if the string is a UUID (version 3, 4 or 5). | ||
- **isUppercase(str)** - check if the string is uppercase. | ||
- **isVariableWidth(str)** - check if the string contains a mixture of full and half-width chars. | ||
- **isWhitelisted(str, chars)** - checks characters if they appear in the whitelist. | ||
- **matches(str, pattern [, modifiers])** - check if string matches the pattern. Either `matches('foo', /foo/i)` or `matches('foo', 'foo', 'i')`. | ||
Here is a list of the sanitizers currently available. | ||
### Sanitizers | ||
Sanitizer | Description | ||
-------------------------------------- | ------------------------------- | ||
**blacklist(input, chars)** | remove characters that appear in the blacklist. The characters are used in a RegExp and so you will need to escape some chars, e.g. `blacklist(input, '\\[\\]')`. | ||
**escape(input)** | replace `<`, `>`, `&`, `'`, `"` and `/` with HTML entities. | ||
**unescape(input)** | replaces HTML encoded entities with `<`, `>`, `&`, `'`, `"` and `/`. | ||
**ltrim(input [, chars])** | trim characters from the left-side of the input. | ||
**normalizeEmail(email [, options])** | canonicalizes an email address.<br/><br/>`options` is an object with the following keys and default values:<br/><ul><li>*all_lowercase: true* - Transforms the local part (before the @ symbol) of all email addresses to lowercase. Please note that this may violate RFC 5321, which gives providers the possibility to treat the local part of email addresses in a case sensitive way (although in practice most - yet not all - providers don't). The domain part of the email address is always lowercased, as it's case insensitive per RFC 1035.</li><li>*gmail_lowercase: true* - GMail addresses are known to be case-insensitive, so this switch allows lowercasing them even when *all_lowercase* is set to false. Please note that when *all_lowercase* is true, GMail addresses are lowercased regardless of the value of this setting.</li><li>*gmail_remove_dots: true*: Removes dots from the local part of the email address, as GMail ignores them (e.g. "john.doe" and "johndoe" are considered equal).</li><li>*gmail_remove_subaddress: true*: Normalizes addresses by removing "sub-addresses", which is the part following a "+" sign (e.g. "foo+bar@gmail.com" becomes "foo@gmail.com").</li><li>*gmail_convert_googlemaildotcom: true*: Converts addresses with domain @googlemail.com to @gmail.com, as they're equivalent.</li><li>*outlookdotcom_lowercase: true* - Outlook.com addresses (including Windows Live and Hotmail) are known to be case-insensitive, so this switch allows lowercasing them even when *all_lowercase* is set to false. Please note that when *all_lowercase* is true, Outlook.com addresses are lowercased regardless of the value of this setting.</li><li>*outlookdotcom_remove_subaddress: true*: Normalizes addresses by removing "sub-addresses", which is the part following a "+" sign (e.g. "foo+bar@outlook.com" becomes "foo@outlook.com").</li><li>*yahoo_lowercase: true* - Yahoo Mail addresses are known to be case-insensitive, so this switch allows lowercasing them even when *all_lowercase* is set to false. Please note that when *all_lowercase* is true, Yahoo Mail addresses are lowercased regardless of the value of this setting.</li><li>*yahoo_remove_subaddress: true*: Normalizes addresses by removing "sub-addresses", which is the part following a "-" sign (e.g. "foo-bar@yahoo.com" becomes "foo@yahoo.com").</li><li>*icloud_lowercase: true* - iCloud addresses (including MobileMe) are known to be case-insensitive, so this switch allows lowercasing them even when *all_lowercase* is set to false. Please note that when *all_lowercase* is true, iCloud addresses are lowercased regardless of the value of this setting.</li><li>*icloud_remove_subaddress: true*: Normalizes addresses by removing "sub-addresses", which is the part following a "+" sign (e.g. "foo+bar@icloud.com" becomes "foo@icloud.com").</li></ul> | ||
**rtrim(input [, chars])** | trim characters from the right-side of the input. | ||
**stripLow(input [, keep_new_lines])** | remove characters with a numerical value < 32 and 127, mostly control characters. If `keep_new_lines` is `true`, newline characters are preserved (`\n` and `\r`, hex `0xA` and `0xD`). Unicode-safe in JavaScript. | ||
**toBoolean(input [, strict])** | convert the input string to a boolean. Everything except for `'0'`, `'false'` and `''` returns `true`. In strict mode only `'1'` and `'true'` return `true`. | ||
**toDate(input)** | convert the input string to a date, or `null` if the input is not a date. | ||
**toFloat(input)** | convert the input string to a float, or `NaN` if the input is not a float. | ||
**toInt(input [, radix])** | convert the input string to an integer, or `NaN` if the input is not an integer. | ||
**trim(input [, chars])** | trim characters (whitespace by default) from both sides of the input. | ||
**whitelist(input, chars)** | remove characters that do not appear in the whitelist. The characters are used in a RegExp and so you will need to escape some chars, e.g. `whitelist(input, '\\[\\]')`. | ||
- **blacklist(input, chars)** - remove characters that appear in the blacklist. The characters are used in a RegExp and so you will need to escape some chars, e.g. `blacklist(input, '\\[\\]')`. | ||
- **escape(input)** - replace `<`, `>`, `&`, `'`, `"` and `/` with HTML entities. | ||
- **unescape(input)** - replaces HTML encoded entities with `<`, `>`, `&`, `'`, `"` and `/`. | ||
- **ltrim(input [, chars])** - trim characters from the left-side of the input. | ||
- **normalizeEmail(email [, options])** - canonicalizes an email address. `options` is an object with the following keys and default values: | ||
- *all_lowercase: true* - Transforms the local part (before the @ symbol) of all email addresses to lowercase. Please note that this may violate RFC 5321, which gives providers the possibility to treat the local part of email addresses in a case sensitive way (although in practice most - yet not all - providers don't). The domain part of the email address is always lowercased, as it's case insensitive per RFC 1035. | ||
- *gmail_lowercase: true* - GMail addresses are known to be case-insensitive, so this switch allows lowercasing them even when *all_lowercase* is set to false. Please note that when *all_lowercase* is true, GMail addresses are lowercased regardless of the value of this setting. | ||
- *gmail_remove_dots: true*: Removes dots from the local part of the email address, as GMail ignores them (e.g. "john.doe" and "johndoe" are considered equal). | ||
- *gmail_remove_subaddress: true*: Normalizes addresses by removing "sub-addresses", which is the part following a "+" sign (e.g. "foo+bar@gmail.com" becomes "foo@gmail.com"). | ||
- *gmail_convert_googlemaildotcom: true*: Converts addresses with domain @googlemail.com to @gmail.com, as they're equivalent. | ||
- *outlookdotcom_lowercase: true* - Outlook.com addresses (including Windows Live and Hotmail) are known to be case-insensitive, so this switch allows lowercasing them even when *all_lowercase* is set to false. Please note that when *all_lowercase* is true, Outlook.com addresses are lowercased regardless of the value of this setting. | ||
- *outlookdotcom_remove_subaddress: true*: Normalizes addresses by removing "sub-addresses", which is the part following a "+" sign (e.g. "foo+bar@outlook.com" becomes "foo@outlook.com"). | ||
- *yahoo_lowercase: true* - Yahoo Mail addresses are known to be case-insensitive, so this switch allows lowercasing them even when *all_lowercase* is set to false. Please note that when *all_lowercase* is true, Yahoo Mail addresses are lowercased regardless of the value of this setting. | ||
- *yahoo_remove_subaddress: true*: Normalizes addresses by removing "sub-addresses", which is the part following a "-" sign (e.g. "foo-bar@yahoo.com" becomes "foo@yahoo.com"). | ||
- *icloud_lowercase: true* - iCloud addresses (including MobileMe) are known to be case-insensitive, so this switch allows lowercasing them even when *all_lowercase* is set to false. Please note that when *all_lowercase* is true, iCloud addresses are lowercased regardless of the value of this setting. | ||
- *icloud_remove_subaddress: true*: Normalizes addresses by removing "sub-addresses", which is the part following a "+" sign (e.g. "foo+bar@icloud.com" becomes "foo@icloud.com"). | ||
- **rtrim(input [, chars])** - trim characters from the right-side of the input. | ||
- **stripLow(input [, keep_new_lines])** - remove characters with a numerical value < 32 and 127, mostly control characters. If `keep_new_lines` is `true`, newline characters are preserved (`\n` and `\r`, hex `0xA` and `0xD`). Unicode-safe in JavaScript. | ||
- **toBoolean(input [, strict])** - convert the input string to a boolean. Everything except for `'0'`, `'false'` and `''` returns `true`. In strict mode only `'1'` and `'true'` return `true`. | ||
- **toDate(input)** - convert the input string to a date, or `null` if the input is not a date. | ||
- **toFloat(input)** - convert the input string to a float, or `NaN` if the input is not a float. | ||
- **toInt(input [, radix])** - convert the input string to an integer, or `NaN` if the input is not an integer. | ||
- **trim(input [, chars])** - trim characters (whitespace by default) from both sides of the input. | ||
- **whitelist(input, chars)** - remove characters that do not appear in the whitelist. The characters are used in a RegExp and so you will need to escape some chars, e.g. `whitelist(input, '\\[\\]')`. | ||
### XSS Sanitization | ||
@@ -141,4 +143,22 @@ | ||
### Tests | ||
## Contributing | ||
In general, we follow the "fork-and-pull" Git workflow. | ||
1. Fork the repo on GitHub | ||
2. Clone the project to your own machine | ||
3. Work on your fork | ||
1. Make your changes and additions | ||
2. Change or add tests if needed | ||
3. Run tests and make sure they pass | ||
4. Add changes to README.md if needed | ||
4. Commit changes to your own branch | ||
5. **Make sure** you merge the latest from "upstream" and resolve conflicts if there is any | ||
6. Push your work back up to your fork | ||
7. Submit a Pull request so that we can review your changes | ||
## Tests | ||
Tests are using mocha, to run the tests use: | ||
```sh | ||
@@ -148,7 +168,7 @@ $ npm test | ||
### Reading | ||
## Reading | ||
Remember, validating can be troublesome sometimes. See [A list of articles about programming assumptions commonly made that aren't true](https://github.com/jameslk/awesome-falsehoods). | ||
### License (MIT) | ||
## License (MIT) | ||
@@ -155,0 +175,0 @@ ``` |
@@ -444,4 +444,5 @@ /*! | ||
'fr-FR': /^[A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i, | ||
'it-IT': /^[A-ZÀÉÈÌÎÓÒÙ]+$/i, | ||
'nb-NO': /^[A-ZÆØÅ]+$/i, | ||
'nl-NL': /^[A-ZÉËÏÓÖÜ]+$/i, | ||
'nl-NL': /^[A-ZÁÉËÏÓÖÜÚ]+$/i, | ||
'nn-NO': /^[A-ZÆØÅ]+$/i, | ||
@@ -454,2 +455,3 @@ 'hu-HU': /^[A-ZÁÉÍÓÖŐÚÜŰ]+$/i, | ||
'sr-RS': /^[А-ЯЂЈЉЊЋЏ]+$/i, | ||
'sv-SE': /^[A-ZÅÄÖ]+$/i, | ||
'tr-TR': /^[A-ZÇĞİıÖŞÜ]+$/i, | ||
@@ -467,5 +469,6 @@ 'uk-UA': /^[А-ЩЬЮЯЄIЇҐ]+$/i, | ||
'fr-FR': /^[0-9A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i, | ||
'it-IT': /^[0-9A-ZÀÉÈÌÎÓÒÙ]+$/i, | ||
'hu-HU': /^[0-9A-ZÁÉÍÓÖŐÚÜŰ]+$/i, | ||
'nb-NO': /^[0-9A-ZÆØÅ]+$/i, | ||
'nl-NL': /^[0-9A-ZÉËÏÓÖÜ]+$/i, | ||
'nl-NL': /^[0-9A-ZÁÉËÏÓÖÜÚ]+$/i, | ||
'nn-NO': /^[0-9A-ZÆØÅ]+$/i, | ||
@@ -477,2 +480,3 @@ 'pl-PL': /^[0-9A-ZĄĆĘŚŁŃÓŻŹ]+$/i, | ||
'sr-RS': /^[0-9А-ЯЂЈЉЊЋЏ]+$/i, | ||
'sv-SE': /^[0-9A-ZÅÄÖ]+$/i, | ||
'tr-TR': /^[0-9A-ZÇĞİıÖŞÜ]+$/i, | ||
@@ -656,2 +660,24 @@ 'uk-UA': /^[0-9А-ЩЬЮЯЄIЇҐ]+$/i, | ||
var lengths = { | ||
md5: 32, | ||
md4: 32, | ||
sha1: 40, | ||
sha256: 64, | ||
sha384: 96, | ||
sha512: 128, | ||
ripemd128: 32, | ||
ripemd160: 40, | ||
tiger128: 32, | ||
tiger160: 40, | ||
tiger192: 48, | ||
crc32: 8, | ||
crc32b: 8 | ||
}; | ||
function isHash(str, algorithm) { | ||
assertString(str); | ||
var hash = new RegExp('^[a-f0-9]{' + lengths[algorithm] + '}$'); | ||
return hash.test(str); | ||
} | ||
function isJSON(str) { | ||
@@ -904,3 +930,6 @@ assertString(str); | ||
var phones = { | ||
'ar-AE': /^((\+?971)|0)?5[024568]\d{7}$/, | ||
'ar-DZ': /^(\+?213|0)(5|6|7)\d{8}$/, | ||
'ar-EG': /^((\+?20)|0)?1[012]\d{8}$/, | ||
'ar-JO': /^(\+?962|0)?7[789]\d{7}$/, | ||
'ar-SY': /^(!?(\+?963)|0)?9\d{8}$/, | ||
@@ -910,2 +939,3 @@ 'ar-SA': /^(!?(\+?966)|0)?5\d{8}$/, | ||
'cs-CZ': /^(\+?420)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/, | ||
'sk-SK': /^(\+?421)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/, | ||
'de-DE': /^(\+?49[ \.\-])?([\(]{1}[0-9]{1,6}[\)])?([0-9 \.\-\/]{3,20})((x|ext|extension)[ ]?[0-9]{1,4})?$/, | ||
@@ -979,2 +1009,6 @@ 'da-DK': /^(\+?45)?(\d{8})$/, | ||
function currencyRegex(options) { | ||
var decimal_digits = '\\d{' + options.digits_after_decimal[0] + '}'; | ||
options.digits_after_decimal.forEach(function (digit, index) { | ||
if (index !== 0) decimal_digits = decimal_digits + '|\\d{' + digit + '}'; | ||
}); | ||
var symbol = '(\\' + options.symbol.replace(/\./g, '\\.') + ')' + (options.require_symbol ? '' : '?'), | ||
@@ -986,4 +1020,4 @@ negative = '-?', | ||
whole_dollar_amount = '(' + valid_whole_dollar_amounts.join('|') + ')?', | ||
decimal_amount = '(\\' + options.decimal_separator + '\\d{2})?'; | ||
var pattern = whole_dollar_amount + decimal_amount; | ||
decimal_amount = '(\\' + options.decimal_separator + '(' + decimal_digits + '))' + (options.require_decimal ? '' : '?'); | ||
var pattern = whole_dollar_amount + (options.allow_decimal || options.require_decimal ? decimal_amount : ''); | ||
@@ -1039,2 +1073,5 @@ // default is negative sign before symbol, but there are two other options (besides parens) | ||
decimal_separator: '.', | ||
allow_decimal: true, | ||
require_decimal: false, | ||
digits_after_decimal: [2], | ||
allow_space_after_digits: false | ||
@@ -1131,2 +1168,4 @@ }; | ||
var isPostalCode = function (str, locale) { | ||
@@ -1328,3 +1367,3 @@ assertString(str); | ||
var version = '8.1.0'; | ||
var version = '8.2.0'; | ||
@@ -1365,2 +1404,3 @@ var validator = { | ||
isMD5: isMD5, | ||
isHash: isHash, | ||
isJSON: isJSON, | ||
@@ -1367,0 +1407,0 @@ isEmpty: isEmpty, |
@@ -23,2 +23,2 @@ /*! | ||
*/ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.validator=e()}(this,function(){"use strict";function t(t){if(!("string"==typeof t||t instanceof String))throw new TypeError("This library (validator.js) validates strings only")}function e(e){return t(e),e=Date.parse(e),isNaN(e)?null:new Date(e)}function r(e){return t(e),parseFloat(e)}function o(t){return"object"===(void 0===t?"undefined":v(t))&&null!==t?t="function"==typeof t.toString?t.toString():"[object Object]":(null===t||void 0===t||isNaN(t)&&!t.length)&&(t=""),String(t)}function i(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments[1];for(var r in e)void 0===t[r]&&(t[r]=e[r]);return t}function n(e,r){t(e);var o=void 0,i=void 0;"object"===(void 0===r?"undefined":v(r))?(o=r.min||0,i=r.max):(o=arguments[1],i=arguments[2]);var n=encodeURI(e).split(/%..|./).length-1;return n>=o&&(void 0===i||n<=i)}function l(e,r){t(e),(r=i(r,$)).allow_trailing_dot&&"."===e[e.length-1]&&(e=e.substring(0,e.length-1));var o=e.split(".");if(r.require_tld){var n=o.pop();if(!o.length||!/^([a-z\u00a1-\uffff]{2,}|xn[a-z0-9-]{2,})$/i.test(n))return!1;if(/[\s\u2002-\u200B\u202F\u205F\u3000\uFEFF\uDB40\uDC20]/.test(n))return!1}for(var l,a=0;a<o.length;a++){if(l=o[a],r.allow_underscores&&(l=l.replace(/_/g,"")),!/^[a-z\u00a1-\uffff0-9-]+$/i.test(l))return!1;if(/[\uff01-\uff5e]/.test(l))return!1;if("-"===l[0]||"-"===l[l.length-1])return!1}return!0}function a(e,r){if(t(e),(r=i(r,F)).require_display_name||r.allow_display_name){var o=e.match(A);if(o)e=o[1];else if(r.require_display_name)return!1}var a=e.split("@"),u=a.pop(),s=a.join("@"),d=u.toLowerCase();if("gmail.com"!==d&&"googlemail.com"!==d||(s=s.replace(/\./g,"").toLowerCase()),!n(s,{max:64})||!n(u,{max:254}))return!1;if(!l(u,{require_tld:r.require_tld}))return!1;if('"'===s[0])return s=s.slice(1,s.length-1),r.allow_utf8_local_part?b.test(s):w.test(s);for(var c=r.allow_utf8_local_part?y:x,f=s.split("."),p=0;p<f.length;p++)if(!c.test(f[p]))return!1;return!0}function u(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(t(e),!(r=String(r)))return u(e,4)||u(e,6);if("4"===r)return!!S.test(e)&&e.split(".").sort(function(t,e){return t-e})[3]<=255;if("6"===r){var o=e.split(":"),i=!1,n=u(o[o.length-1],4),l=n?7:8;if(o.length>l)return!1;if("::"===e)return!0;"::"===e.substr(0,2)?(o.shift(),o.shift(),i=!0):"::"===e.substr(e.length-2)&&(o.pop(),o.pop(),i=!0);for(var a=0;a<o.length;++a)if(""===o[a]&&a>0&&a<o.length-1){if(i)return!1;i=!0}else if(n&&a===o.length-1);else if(!E.test(o[a]))return!1;return i?o.length>=1:o.length===l}return!1}function s(t){return"[object RegExp]"===Object.prototype.toString.call(t)}function d(t,e){for(var r=0;r<e.length;r++){var o=e[r];if(t===o||s(o)&&o.test(t))return!0}return!1}function c(e){return t(e),W.test(e)}function f(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(t(e),!(r=String(r)))return f(e,10)||f(e,13);var o=e.replace(/[\s-]+/g,""),i=0,n=void 0;if("10"===r){if(!et.test(o))return!1;for(n=0;n<9;n++)i+=(n+1)*o.charAt(n);if("X"===o.charAt(9)?i+=100:i+=10*o.charAt(9),i%11==0)return!!o}else if("13"===r){if(!rt.test(o))return!1;for(n=0;n<12;n++)i+=ot[n%2]*o.charAt(n);if(o.charAt(12)-(10-i%10)%10==0)return!!o}return!1}function p(t){var e="(\\"+t.symbol.replace(/\./g,"\\.")+")"+(t.require_symbol?"":"?"),r="("+["0","[1-9]\\d*","[1-9]\\d{0,2}(\\"+t.thousands_separator+"\\d{3})*"].join("|")+")?"+("(\\"+t.decimal_separator+"\\d{2})?");return t.allow_negatives&&!t.parens_for_negatives&&(t.negative_sign_after_digits?r+="-?":t.negative_sign_before_digits&&(r="-?"+r)),t.allow_negative_sign_placeholder?r="( (?!\\-))?"+r:t.allow_space_after_symbol?r=" ?"+r:t.allow_space_after_digits&&(r+="( (?!$))?"),t.symbol_after_digits?r+=e:r=e+r,t.allow_negatives&&(t.parens_for_negatives?r="(\\("+r+"\\)|"+r+")":t.negative_sign_before_digits||t.negative_sign_after_digits||(r="-?"+r)),new RegExp("^(?!-? )(?=.*\\d)"+r+"$")}function g(e,r){t(e);var o=r?new RegExp("^["+r+"]+","g"):/^\s+/g;return e.replace(o,"")}function h(e,r){t(e);for(var o=r?new RegExp("["+r+"]"):/\s/,i=e.length-1;i>=0&&o.test(e[i]);)i--;return i<e.length?e.substr(0,i+1):e}function m(e,r){return t(e),e.replace(new RegExp("["+r+"]+","g"),"")}for(var _,v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},$={require_tld:!0,allow_underscores:!1,allow_trailing_dot:!1},F={allow_display_name:!1,require_display_name:!1,allow_utf8_local_part:!0,require_tld:!0},A=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\,\.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF\s]*<(.+)>$/i,x=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i,w=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i,y=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i,b=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*$/i,S=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/,E=/^[0-9A-F]{1,4}$/i,Z={protocols:["http","https","ftp"],require_tld:!0,require_protocol:!1,require_host:!0,require_valid_protocol:!0,allow_underscores:!1,allow_trailing_dot:!1,allow_protocol_relative_urls:!1},k=/^\[([^\]]+)\](?::([0-9]+))?$/,D=/^([0-9a-fA-F][0-9a-fA-F]:){5}([0-9a-fA-F][0-9a-fA-F])$/,O={"en-US":/^[A-Z]+$/i,"cs-CZ":/^[A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]+$/i,"da-DK":/^[A-ZÆØÅ]+$/i,"de-DE":/^[A-ZÄÖÜß]+$/i,"es-ES":/^[A-ZÁÉÍÑÓÚÜ]+$/i,"fr-FR":/^[A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i,"nb-NO":/^[A-ZÆØÅ]+$/i,"nl-NL":/^[A-ZÉËÏÓÖÜ]+$/i,"nn-NO":/^[A-ZÆØÅ]+$/i,"hu-HU":/^[A-ZÁÉÍÓÖŐÚÜŰ]+$/i,"pl-PL":/^[A-ZĄĆĘŚŁŃÓŻŹ]+$/i,"pt-PT":/^[A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ]+$/i,"ru-RU":/^[А-ЯЁ]+$/i,"sr-RS@latin":/^[A-ZČĆŽŠĐ]+$/i,"sr-RS":/^[А-ЯЂЈЉЊЋЏ]+$/i,"tr-TR":/^[A-ZÇĞİıÖŞÜ]+$/i,"uk-UA":/^[А-ЩЬЮЯЄIЇҐ]+$/i,ar:/^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/},R={"en-US":/^[0-9A-Z]+$/i,"cs-CZ":/^[0-9A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]+$/i,"da-DK":/^[0-9A-ZÆØÅ]+$/i,"de-DE":/^[0-9A-ZÄÖÜß]+$/i,"es-ES":/^[0-9A-ZÁÉÍÑÓÚÜ]+$/i,"fr-FR":/^[0-9A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i,"hu-HU":/^[0-9A-ZÁÉÍÓÖŐÚÜŰ]+$/i,"nb-NO":/^[0-9A-ZÆØÅ]+$/i,"nl-NL":/^[0-9A-ZÉËÏÓÖÜ]+$/i,"nn-NO":/^[0-9A-ZÆØÅ]+$/i,"pl-PL":/^[0-9A-ZĄĆĘŚŁŃÓŻŹ]+$/i,"pt-PT":/^[0-9A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ]+$/i,"ru-RU":/^[0-9А-ЯЁ]+$/i,"sr-RS@latin":/^[0-9A-ZČĆŽŠĐ]+$/i,"sr-RS":/^[0-9А-ЯЂЈЉЊЋЏ]+$/i,"tr-TR":/^[0-9A-ZÇĞİıÖŞÜ]+$/i,"uk-UA":/^[0-9А-ЩЬЮЯЄIЇҐ]+$/i,ar:/^[٠١٢٣٤٥٦٧٨٩0-9ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/},C=["AU","GB","HK","IN","NZ","ZA","ZM"],I=0;I<C.length;I++)O[_="en-"+C[I]]=O["en-US"],R[_]=R["en-US"];O["pt-BR"]=O["pt-PT"],R["pt-BR"]=R["pt-PT"];for(var N,P=["AE","BH","DZ","EG","IQ","JO","KW","LB","LY","MA","QM","QA","SA","SD","SY","TN","YE"],L=0;L<P.length;L++)O[N="ar-"+P[L]]=O.ar,R[N]=R.ar;var U=/^[-+]?[0-9]+$/,z=/^[\x00-\x7F]+$/,B=/[^\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]/,j=/[\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]/,T=/[^\x00-\x7F]/,q=/[\uD800-\uDBFF][\uDC00-\uDFFF]/,H=/^(?:[-+]?(?:0|[1-9][0-9]*))$/,K=/^[-+]?[0-9]+$/,M=/^(?:[-+])?(?:[0-9]+)?(?:\.[0-9]*)?(?:[eE][\+\-]?(?:[0-9]+))?$/,G=/^[-+]?([0-9]+|\.[0-9]+|[0-9]+\.[0-9]+)$/,W=/^[0-9A-F]+$/i,J=/^#?([0-9A-F]{3}|[0-9A-F]{6})$/i,X=/^[A-Z]{2}[0-9A-Z]{3}\d{2}\d{5}$/,Y=/^[a-f0-9]{32}$/,V={3:/^[0-9A-F]{8}-[0-9A-F]{4}-3[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i,4:/^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,5:/^[0-9A-F]{8}-[0-9A-F]{4}-5[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,all:/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i},Q=/^(?:4[0-9]{12}(?:[0-9]{3})?|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}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11}|62[0-9]{14})$/,tt=/^[A-Z]{2}[0-9A-Z]{9}[0-9]$/,et=/^(?:[0-9]{9}X|[0-9]{10})$/,rt=/^(?:[0-9]{13})$/,ot=[1,3],it="^\\d{4}-?\\d{3}[\\dX]$",nt={"ar-DZ":/^(\+?213|0)(5|6|7)\d{8}$/,"ar-SY":/^(!?(\+?963)|0)?9\d{8}$/,"ar-SA":/^(!?(\+?966)|0)?5\d{8}$/,"en-US":/^(\+?1)?[2-9]\d{2}[2-9](?!11)\d{6}$/,"cs-CZ":/^(\+?420)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/,"de-DE":/^(\+?49[ \.\-])?([\(]{1}[0-9]{1,6}[\)])?([0-9 \.\-\/]{3,20})((x|ext|extension)[ ]?[0-9]{1,4})?$/,"da-DK":/^(\+?45)?(\d{8})$/,"el-GR":/^(\+?30)?(69\d{8})$/,"en-AU":/^(\+?61|0)4\d{8}$/,"en-GB":/^(\+?44|0)7\d{9}$/,"en-HK":/^(\+?852\-?)?[569]\d{3}\-?\d{4}$/,"en-IN":/^(\+?91|0)?[789]\d{9}$/,"en-KE":/^(\+?254|0)?[7]\d{8}$/,"en-NG":/^(\+?234|0)?[789]\d{9}$/,"en-NZ":/^(\+?64|0)2\d{7,9}$/,"en-UG":/^(\+?256|0)?[7]\d{8}$/,"en-RW":/^(\+?250|0)?[7]\d{8}$/,"en-TZ":/^(\+?255|0)?[67]\d{8}$/,"en-ZA":/^(\+?27|0)\d{9}$/,"en-ZM":/^(\+?26)?09[567]\d{7}$/,"es-ES":/^(\+?34)?(6\d{1}|7[1234])\d{7}$/,"fi-FI":/^(\+?358|0)\s?(4(0|1|2|4|5|6)?|50)\s?(\d\s?){4,8}\d$/,"fa-IR":/^(\+?98[\-\s]?|0)9[0-39]\d[\-\s]?\d{3}[\-\s]?\d{4}$/,"fr-FR":/^(\+?33|0)[67]\d{8}$/,"he-IL":/^(\+972|0)([23489]|5[0248]|77)[1-9]\d{6}/,"hu-HU":/^(\+?36)(20|30|70)\d{7}$/,"lt-LT":/^(\+370|8)\d{8}$/,"id-ID":/^(\+?62|0[1-9])[\s|\d]+$/,"it-IT":/^(\+?39)?\s?3\d{2} ?\d{6,7}$/,"ko-KR":/^((\+?82)[ \-]?)?0?1([0|1|6|7|8|9]{1})[ \-]?\d{3,4}[ \-]?\d{4}$/,"ja-JP":/^(\+?81|0)\d{1,4}[ \-]?\d{1,4}[ \-]?\d{4}$/,"ms-MY":/^(\+?6?01){1}(([145]{1}(\-|\s)?\d{7,8})|([236789]{1}(\s|\-)?\d{7}))$/,"nb-NO":/^(\+?47)?[49]\d{7}$/,"nl-BE":/^(\+?32|0)4?\d{8}$/,"nn-NO":/^(\+?47)?[49]\d{7}$/,"pl-PL":/^(\+?48)? ?[5-8]\d ?\d{3} ?\d{2} ?\d{2}$/,"pt-BR":/^(\+?55|0)\-?[1-9]{2}\-?[2-9]{1}\d{3,4}\-?\d{4}$/,"pt-PT":/^(\+?351)?9[1236]\d{7}$/,"ro-RO":/^(\+?4?0)\s?7\d{2}(\/|\s|\.|\-)?\d{3}(\s|\.|\-)?\d{3}$/,"en-PK":/^((\+92)|(0092))-{0,1}\d{3}-{0,1}\d{7}$|^\d{11}$|^\d{4}-\d{7}$/,"ru-RU":/^(\+?7|8)?9\d{9}$/,"sr-RS":/^(\+3816|06)[- \d]{5,9}$/,"tr-TR":/^(\+?90|0)?5\d{9}$/,"vi-VN":/^(\+?84|0)?((1(2([0-9])|6([2-9])|88|99))|(9((?!5)[0-9])))([0-9]{7})$/,"zh-CN":/^(\+?0?86\-?)?1[345789]\d{9}$/,"zh-TW":/^(\+?886\-?|0)?9\d{8}$/};nt["en-CA"]=nt["en-US"],nt["fr-BE"]=nt["nl-BE"],nt["zh-HK"]=nt["en-HK"];var lt={symbol:"$",require_symbol:!1,allow_space_after_symbol:!1,symbol_after_digits:!1,allow_negatives:!0,parens_for_negatives:!1,negative_sign_before_digits:!1,negative_sign_after_digits:!1,allow_negative_sign_placeholder:!1,thousands_separator:",",decimal_separator:".",allow_space_after_digits:!1},at=/^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/,ut=/[^A-Z0-9+\/=]/i,st=/^\s*data:([a-z]+\/[a-z0-9\-\+]+(;[a-z\-]+=[a-z0-9\-]+)?)?(;base64)?,[a-z0-9!\$&',\(\)\*\+,;=\-\._~:@\/\?%\s]*\s*$/i,dt=/^\(?[+-]?(90(\.0+)?|[1-8]?\d(\.\d+)?)$/,ct=/^\s?[+-]?(180(\.0+)?|1[0-7]\d(\.\d+)?|\d{1,2}(\.\d+)?)\)?$/,ft=/^\d{4}$/,pt=/^\d{5}$/,gt=/^\d{6}$/,ht={AT:ft,AU:gt,BE:ft,CA:/^[ABCEGHJKLMNPRSTVXY]\d[ABCEGHJ-NPRSTV-Z][\s\-]?\d[ABCEGHJ-NPRSTV-Z]\d$/i,CH:ft,CZ:/^\d{3}\s?\d{2}$/,DE:pt,DK:ft,DZ:pt,ES:pt,FI:pt,FR:/^\d{2}\s?\d{3}$/,GB:/^(gir\s?0aa|[a-z]{1,2}\d[\da-z]?\s?(\d[a-z]{2})?)$/i,GR:/^\d{3}\s?\d{2}$/,IL:pt,IN:gt,IS:/^\d{3}$/,IT:pt,JP:/^\d{3}\-\d{4}$/,KE:pt,LI:/^(948[5-9]|949[0-7])$/,MX:pt,NL:/^\d{4}\s?[a-z]{2}$/i,NO:ft,PL:/^\d{2}\-\d{3}$/,PT:/^\d{4}(\-\d{3})?$/,RO:gt,RU:gt,SA:pt,SE:/^\d{3}\s?\d{2}$/,TW:/^\d{3}(\d{2})?$/,US:/^\d{5}(-\d{4})?$/,ZA:ft,ZM:pt},mt={all_lowercase:!0,gmail_lowercase:!0,gmail_remove_dots:!0,gmail_remove_subaddress:!0,gmail_convert_googlemaildotcom:!0,outlookdotcom_lowercase:!0,outlookdotcom_remove_subaddress:!0,yahoo_lowercase:!0,yahoo_remove_subaddress:!0,icloud_lowercase:!0,icloud_remove_subaddress:!0},_t=["icloud.com","me.com"],vt=["hotmail.at","hotmail.be","hotmail.ca","hotmail.cl","hotmail.co.il","hotmail.co.nz","hotmail.co.th","hotmail.co.uk","hotmail.com","hotmail.com.ar","hotmail.com.au","hotmail.com.br","hotmail.com.gr","hotmail.com.mx","hotmail.com.pe","hotmail.com.tr","hotmail.com.vn","hotmail.cz","hotmail.de","hotmail.dk","hotmail.es","hotmail.fr","hotmail.hu","hotmail.id","hotmail.ie","hotmail.in","hotmail.it","hotmail.jp","hotmail.kr","hotmail.lv","hotmail.my","hotmail.ph","hotmail.pt","hotmail.sa","hotmail.sg","hotmail.sk","live.be","live.co.uk","live.com","live.com.ar","live.com.mx","live.de","live.es","live.eu","live.fr","live.it","live.nl","msn.com","outlook.at","outlook.be","outlook.cl","outlook.co.il","outlook.co.nz","outlook.co.th","outlook.com","outlook.com.ar","outlook.com.au","outlook.com.br","outlook.com.gr","outlook.com.pe","outlook.com.tr","outlook.com.vn","outlook.cz","outlook.de","outlook.dk","outlook.es","outlook.fr","outlook.hu","outlook.id","outlook.ie","outlook.in","outlook.it","outlook.jp","outlook.kr","outlook.lv","outlook.my","outlook.ph","outlook.pt","outlook.sa","outlook.sg","outlook.sk","passport.com"],$t=["rocketmail.com","yahoo.ca","yahoo.co.uk","yahoo.com","yahoo.de","yahoo.fr","yahoo.in","yahoo.it","ymail.com"];return{version:"8.1.0",toDate:e,toFloat:r,toInt:function(e,r){return t(e),parseInt(e,r||10)},toBoolean:function(e,r){return t(e),r?"1"===e||"true"===e:"0"!==e&&"false"!==e&&""!==e},equals:function(e,r){return t(e),e===r},contains:function(e,r){return t(e),e.indexOf(o(r))>=0},matches:function(e,r,o){return t(e),"[object RegExp]"!==Object.prototype.toString.call(r)&&(r=new RegExp(r,o)),r.test(e)},isEmail:a,isURL:function(e,r){if(t(e),!e||e.length>=2083||/[\s<>]/.test(e))return!1;if(0===e.indexOf("mailto:"))return!1;r=i(r,Z);var o=void 0,n=void 0,a=void 0,s=void 0,c=void 0,f=void 0,p=void 0,g=void 0;if(p=e.split("#"),e=p.shift(),p=e.split("?"),e=p.shift(),(p=e.split("://")).length>1){if(o=p.shift(),r.require_valid_protocol&&-1===r.protocols.indexOf(o))return!1}else{if(r.require_protocol)return!1;r.allow_protocol_relative_urls&&"//"===e.substr(0,2)&&(p[0]=e.substr(2))}if(""===(e=p.join("://")))return!1;if(p=e.split("/"),""===(e=p.shift())&&!r.require_host)return!0;if((p=e.split("@")).length>1&&(n=p.shift()).indexOf(":")>=0&&n.split(":").length>2)return!1;f=null,g=null;var h=(s=p.join("@")).match(k);return h?(a="",g=h[1],f=h[2]||null):(a=(p=s.split(":")).shift(),p.length&&(f=p.join(":"))),!(null!==f&&(c=parseInt(f,10),!/^[0-9]+$/.test(f)||c<=0||c>65535)||!(u(a)||l(a,r)||g&&u(g,6))||(a=a||g,r.host_whitelist&&!d(a,r.host_whitelist)||r.host_blacklist&&d(a,r.host_blacklist)))},isMACAddress:function(e){return t(e),D.test(e)},isIP:u,isFQDN:l,isBoolean:function(e){return t(e),["true","false","1","0"].indexOf(e)>=0},isAlpha:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"en-US";if(t(e),r in O)return O[r].test(e);throw new Error("Invalid locale '"+r+"'")},isAlphanumeric:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"en-US";if(t(e),r in R)return R[r].test(e);throw new Error("Invalid locale '"+r+"'")},isNumeric:function(e){return t(e),U.test(e)},isLowercase:function(e){return t(e),e===e.toLowerCase()},isUppercase:function(e){return t(e),e===e.toUpperCase()},isAscii:function(e){return t(e),z.test(e)},isFullWidth:function(e){return t(e),B.test(e)},isHalfWidth:function(e){return t(e),j.test(e)},isVariableWidth:function(e){return t(e),B.test(e)&&j.test(e)},isMultibyte:function(e){return t(e),T.test(e)},isSurrogatePair:function(e){return t(e),q.test(e)},isInt:function(e,r){t(e);var o=(r=r||{}).hasOwnProperty("allow_leading_zeroes")&&!r.allow_leading_zeroes?H:K,i=!r.hasOwnProperty("min")||e>=r.min,n=!r.hasOwnProperty("max")||e<=r.max,l=!r.hasOwnProperty("lt")||e<r.lt,a=!r.hasOwnProperty("gt")||e>r.gt;return o.test(e)&&i&&n&&l&&a},isFloat:function(e,r){return t(e),r=r||{},""!==e&&"."!==e&&M.test(e)&&(!r.hasOwnProperty("min")||e>=r.min)&&(!r.hasOwnProperty("max")||e<=r.max)&&(!r.hasOwnProperty("lt")||e<r.lt)&&(!r.hasOwnProperty("gt")||e>r.gt)},isDecimal:function(e){return t(e),""!==e&&G.test(e)},isHexadecimal:c,isDivisibleBy:function(e,o){return t(e),r(e)%parseInt(o,10)==0},isHexColor:function(e){return t(e),J.test(e)},isISRC:function(e){return t(e),X.test(e)},isMD5:function(e){return t(e),Y.test(e)},isJSON:function(e){t(e);try{var r=JSON.parse(e);return!!r&&"object"===(void 0===r?"undefined":v(r))}catch(t){}return!1},isEmpty:function(e){return t(e),0===e.length},isLength:function(e,r){t(e);var o=void 0,i=void 0;"object"===(void 0===r?"undefined":v(r))?(o=r.min||0,i=r.max):(o=arguments[1],i=arguments[2]);var n=e.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g)||[],l=e.length-n.length;return l>=o&&(void 0===i||l<=i)},isByteLength:n,isUUID:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"all";t(e);var o=V[r];return o&&o.test(e)},isMongoId:function(e){return t(e),c(e)&&24===e.length},isAfter:function(r){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:String(new Date);t(r);var i=e(o),n=e(r);return!!(n&&i&&n>i)},isBefore:function(r){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:String(new Date);t(r);var i=e(o),n=e(r);return!!(n&&i&&n<i)},isIn:function(e,r){t(e);var i=void 0;if("[object Array]"===Object.prototype.toString.call(r)){var n=[];for(i in r)({}).hasOwnProperty.call(r,i)&&(n[i]=o(r[i]));return n.indexOf(e)>=0}return"object"===(void 0===r?"undefined":v(r))?r.hasOwnProperty(e):!(!r||"function"!=typeof r.indexOf)&&r.indexOf(e)>=0},isCreditCard:function(e){t(e);var r=e.replace(/[- ]+/g,"");if(!Q.test(r))return!1;for(var o=0,i=void 0,n=void 0,l=void 0,a=r.length-1;a>=0;a--)i=r.substring(a,a+1),n=parseInt(i,10),o+=l&&(n*=2)>=10?n%10+1:n,l=!l;return!(o%10!=0||!r)},isISIN:function(e){if(t(e),!tt.test(e))return!1;for(var r=e.replace(/[A-Z]/g,function(t){return parseInt(t,36)}),o=0,i=void 0,n=void 0,l=!0,a=r.length-2;a>=0;a--)i=r.substring(a,a+1),n=parseInt(i,10),o+=l&&(n*=2)>=10?n+1:n,l=!l;return parseInt(e.substr(e.length-1),10)===(1e4-o)%10},isISBN:f,isISSN:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t(e);var o=it;if(o=r.require_hyphen?o.replace("?",""):o,!(o=r.case_sensitive?new RegExp(o):new RegExp(o,"i")).test(e))return!1;var i=e.replace("-",""),n=8,l=0,a=!0,u=!1,s=void 0;try{for(var d,c=i[Symbol.iterator]();!(a=(d=c.next()).done);a=!0){var f=d.value;l+=("X"===f.toUpperCase()?10:+f)*n,--n}}catch(t){u=!0,s=t}finally{try{!a&&c.return&&c.return()}finally{if(u)throw s}}return l%11==0},isMobilePhone:function(e,r){if(t(e),r in nt)return nt[r].test(e);if("any"===r){for(var o in nt)if(nt.hasOwnProperty(o)&&nt[o].test(e))return!0;return!1}throw new Error("Invalid locale '"+r+"'")},isPostalCode:function(e,r){if(t(e),r in ht)return ht[r].test(e);if("any"===r){for(var o in ht)if(ht.hasOwnProperty(o)&&ht[o].test(e))return!0;return!1}throw new Error("Invalid locale '"+r+"'")},isCurrency:function(e,r){return t(e),r=i(r,lt),p(r).test(e)},isISO8601:function(e){return t(e),at.test(e)},isBase64:function(e){t(e);var r=e.length;if(!r||r%4!=0||ut.test(e))return!1;var o=e.indexOf("=");return-1===o||o===r-1||o===r-2&&"="===e[r-1]},isDataURI:function(e){return t(e),st.test(e)},isLatLong:function(e){if(t(e),!e.includes(","))return!1;var r=e.split(",");return dt.test(r[0])&&ct.test(r[1])},ltrim:g,rtrim:h,trim:function(t,e){return h(g(t,e),e)},escape:function(e){return t(e),e.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">").replace(/\//g,"/").replace(/\\/g,"\").replace(/`/g,"`")},unescape:function(e){return t(e),e.replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">").replace(///g,"/").replace(/\/g,"\\").replace(/`/g,"`")},stripLow:function(e,r){return t(e),m(e,r?"\\x00-\\x09\\x0B\\x0C\\x0E-\\x1F\\x7F":"\\x00-\\x1F\\x7F")},whitelist:function(e,r){return t(e),e.replace(new RegExp("[^"+r+"]+","g"),"")},blacklist:m,isWhitelisted:function(e,r){t(e);for(var o=e.length-1;o>=0;o--)if(-1===r.indexOf(e[o]))return!1;return!0},normalizeEmail:function(t,e){if(e=i(e,mt),!a(t))return!1;var r=t.split("@"),o=r.pop(),n=[r.join("@"),o];if(n[1]=n[1].toLowerCase(),"gmail.com"===n[1]||"googlemail.com"===n[1]){if(e.gmail_remove_subaddress&&(n[0]=n[0].split("+")[0]),e.gmail_remove_dots&&(n[0]=n[0].replace(/\./g,"")),!n[0].length)return!1;(e.all_lowercase||e.gmail_lowercase)&&(n[0]=n[0].toLowerCase()),n[1]=e.gmail_convert_googlemaildotcom?"gmail.com":n[1]}else if(~_t.indexOf(n[1])){if(e.icloud_remove_subaddress&&(n[0]=n[0].split("+")[0]),!n[0].length)return!1;(e.all_lowercase||e.icloud_lowercase)&&(n[0]=n[0].toLowerCase())}else if(~vt.indexOf(n[1])){if(e.outlookdotcom_remove_subaddress&&(n[0]=n[0].split("+")[0]),!n[0].length)return!1;(e.all_lowercase||e.outlookdotcom_lowercase)&&(n[0]=n[0].toLowerCase())}else if(~$t.indexOf(n[1])){if(e.yahoo_remove_subaddress){var l=n[0].split("-");n[0]=l.length>1?l.slice(0,-1).join("-"):l[0]}if(!n[0].length)return!1;(e.all_lowercase||e.yahoo_lowercase)&&(n[0]=n[0].toLowerCase())}else e.all_lowercase&&(n[0]=n[0].toLowerCase());return n.join("@")},toString:o}}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.validator=t()}(this,function(){"use strict";function e(e){if(!("string"==typeof e||e instanceof String))throw new TypeError("This library (validator.js) validates strings only")}function t(t){return e(t),t=Date.parse(t),isNaN(t)?null:new Date(t)}function r(t){return e(t),parseFloat(t)}function o(e){return"object"===(void 0===e?"undefined":v(e))&&null!==e?e="function"==typeof e.toString?e.toString():"[object Object]":(null===e||void 0===e||isNaN(e)&&!e.length)&&(e=""),String(e)}function i(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments[1];for(var r in t)void 0===e[r]&&(e[r]=t[r]);return e}function n(t,r){e(t);var o=void 0,i=void 0;"object"===(void 0===r?"undefined":v(r))?(o=r.min||0,i=r.max):(o=arguments[1],i=arguments[2]);var n=encodeURI(t).split(/%..|./).length-1;return n>=o&&(void 0===i||n<=i)}function a(t,r){e(t),(r=i(r,$)).allow_trailing_dot&&"."===t[t.length-1]&&(t=t.substring(0,t.length-1));var o=t.split(".");if(r.require_tld){var n=o.pop();if(!o.length||!/^([a-z\u00a1-\uffff]{2,}|xn[a-z0-9-]{2,})$/i.test(n))return!1;if(/[\s\u2002-\u200B\u202F\u205F\u3000\uFEFF\uDB40\uDC20]/.test(n))return!1}for(var a,l=0;l<o.length;l++){if(a=o[l],r.allow_underscores&&(a=a.replace(/_/g,"")),!/^[a-z\u00a1-\uffff0-9-]+$/i.test(a))return!1;if(/[\uff01-\uff5e]/.test(a))return!1;if("-"===a[0]||"-"===a[a.length-1])return!1}return!0}function l(t,r){if(e(t),(r=i(r,F)).require_display_name||r.allow_display_name){var o=t.match(A);if(o)t=o[1];else if(r.require_display_name)return!1}var l=t.split("@"),s=l.pop(),u=l.join("@"),d=s.toLowerCase();if("gmail.com"!==d&&"googlemail.com"!==d||(u=u.replace(/\./g,"").toLowerCase()),!n(u,{max:64})||!n(s,{max:254}))return!1;if(!a(s,{require_tld:r.require_tld}))return!1;if('"'===u[0])return u=u.slice(1,u.length-1),r.allow_utf8_local_part?b.test(u):w.test(u);for(var c=r.allow_utf8_local_part?y:x,f=u.split("."),g=0;g<f.length;g++)if(!c.test(f[g]))return!1;return!0}function s(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(e(t),!(r=String(r)))return s(t,4)||s(t,6);if("4"===r)return!!E.test(t)&&t.split(".").sort(function(e,t){return e-t})[3]<=255;if("6"===r){var o=t.split(":"),i=!1,n=s(o[o.length-1],4),a=n?7:8;if(o.length>a)return!1;if("::"===t)return!0;"::"===t.substr(0,2)?(o.shift(),o.shift(),i=!0):"::"===t.substr(t.length-2)&&(o.pop(),o.pop(),i=!0);for(var l=0;l<o.length;++l)if(""===o[l]&&l>0&&l<o.length-1){if(i)return!1;i=!0}else if(n&&l===o.length-1);else if(!S.test(o[l]))return!1;return i?o.length>=1:o.length===a}return!1}function u(e){return"[object RegExp]"===Object.prototype.toString.call(e)}function d(e,t){for(var r=0;r<t.length;r++){var o=t[r];if(e===o||u(o)&&o.test(e))return!0}return!1}function c(t){return e(t),J.test(t)}function f(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(e(t),!(r=String(r)))return f(t,10)||f(t,13);var o=t.replace(/[\s-]+/g,""),i=0,n=void 0;if("10"===r){if(!re.test(o))return!1;for(n=0;n<9;n++)i+=(n+1)*o.charAt(n);if("X"===o.charAt(9)?i+=100:i+=10*o.charAt(9),i%11==0)return!!o}else if("13"===r){if(!oe.test(o))return!1;for(n=0;n<12;n++)i+=ie[n%2]*o.charAt(n);if(o.charAt(12)-(10-i%10)%10==0)return!!o}return!1}function g(e){var t="\\d{"+e.digits_after_decimal[0]+"}";e.digits_after_decimal.forEach(function(e,r){0!==r&&(t=t+"|\\d{"+e+"}")});var r="(\\"+e.symbol.replace(/\./g,"\\.")+")"+(e.require_symbol?"":"?"),o="("+["0","[1-9]\\d*","[1-9]\\d{0,2}(\\"+e.thousands_separator+"\\d{3})*"].join("|")+")?",i="(\\"+e.decimal_separator+"("+t+"))"+(e.require_decimal?"":"?"),n=o+(e.allow_decimal||e.require_decimal?i:"");return e.allow_negatives&&!e.parens_for_negatives&&(e.negative_sign_after_digits?n+="-?":e.negative_sign_before_digits&&(n="-?"+n)),e.allow_negative_sign_placeholder?n="( (?!\\-))?"+n:e.allow_space_after_symbol?n=" ?"+n:e.allow_space_after_digits&&(n+="( (?!$))?"),e.symbol_after_digits?n+=r:n=r+n,e.allow_negatives&&(e.parens_for_negatives?n="(\\("+n+"\\)|"+n+")":e.negative_sign_before_digits||e.negative_sign_after_digits||(n="-?"+n)),new RegExp("^(?!-? )(?=.*\\d)"+n+"$")}function p(t,r){e(t);var o=r?new RegExp("^["+r+"]+","g"):/^\s+/g;return t.replace(o,"")}function h(t,r){e(t);for(var o=r?new RegExp("["+r+"]"):/\s/,i=t.length-1;i>=0&&o.test(t[i]);)i--;return i<t.length?t.substr(0,i+1):t}function m(t,r){return e(t),t.replace(new RegExp("["+r+"]+","g"),"")}for(var _,v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},$={require_tld:!0,allow_underscores:!1,allow_trailing_dot:!1},F={allow_display_name:!1,require_display_name:!1,allow_utf8_local_part:!0,require_tld:!0},A=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\,\.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF\s]*<(.+)>$/i,x=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i,w=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i,y=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i,b=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*$/i,E=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/,S=/^[0-9A-F]{1,4}$/i,Z={protocols:["http","https","ftp"],require_tld:!0,require_protocol:!1,require_host:!0,require_valid_protocol:!0,allow_underscores:!1,allow_trailing_dot:!1,allow_protocol_relative_urls:!1},k=/^\[([^\]]+)\](?::([0-9]+))?$/,D=/^([0-9a-fA-F][0-9a-fA-F]:){5}([0-9a-fA-F][0-9a-fA-F])$/,O={"en-US":/^[A-Z]+$/i,"cs-CZ":/^[A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]+$/i,"da-DK":/^[A-ZÆØÅ]+$/i,"de-DE":/^[A-ZÄÖÜß]+$/i,"es-ES":/^[A-ZÁÉÍÑÓÚÜ]+$/i,"fr-FR":/^[A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i,"it-IT":/^[A-ZÀÉÈÌÎÓÒÙ]+$/i,"nb-NO":/^[A-ZÆØÅ]+$/i,"nl-NL":/^[A-ZÁÉËÏÓÖÜÚ]+$/i,"nn-NO":/^[A-ZÆØÅ]+$/i,"hu-HU":/^[A-ZÁÉÍÓÖŐÚÜŰ]+$/i,"pl-PL":/^[A-ZĄĆĘŚŁŃÓŻŹ]+$/i,"pt-PT":/^[A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ]+$/i,"ru-RU":/^[А-ЯЁ]+$/i,"sr-RS@latin":/^[A-ZČĆŽŠĐ]+$/i,"sr-RS":/^[А-ЯЂЈЉЊЋЏ]+$/i,"sv-SE":/^[A-ZÅÄÖ]+$/i,"tr-TR":/^[A-ZÇĞİıÖŞÜ]+$/i,"uk-UA":/^[А-ЩЬЮЯЄIЇҐ]+$/i,ar:/^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/},R={"en-US":/^[0-9A-Z]+$/i,"cs-CZ":/^[0-9A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]+$/i,"da-DK":/^[0-9A-ZÆØÅ]+$/i,"de-DE":/^[0-9A-ZÄÖÜß]+$/i,"es-ES":/^[0-9A-ZÁÉÍÑÓÚÜ]+$/i,"fr-FR":/^[0-9A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i,"it-IT":/^[0-9A-ZÀÉÈÌÎÓÒÙ]+$/i,"hu-HU":/^[0-9A-ZÁÉÍÓÖŐÚÜŰ]+$/i,"nb-NO":/^[0-9A-ZÆØÅ]+$/i,"nl-NL":/^[0-9A-ZÁÉËÏÓÖÜÚ]+$/i,"nn-NO":/^[0-9A-ZÆØÅ]+$/i,"pl-PL":/^[0-9A-ZĄĆĘŚŁŃÓŻŹ]+$/i,"pt-PT":/^[0-9A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ]+$/i,"ru-RU":/^[0-9А-ЯЁ]+$/i,"sr-RS@latin":/^[0-9A-ZČĆŽŠĐ]+$/i,"sr-RS":/^[0-9А-ЯЂЈЉЊЋЏ]+$/i,"sv-SE":/^[0-9A-ZÅÄÖ]+$/i,"tr-TR":/^[0-9A-ZÇĞİıÖŞÜ]+$/i,"uk-UA":/^[0-9А-ЩЬЮЯЄIЇҐ]+$/i,ar:/^[٠١٢٣٤٥٦٧٨٩0-9ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/},I=["AU","GB","HK","IN","NZ","ZA","ZM"],C=0;C<I.length;C++)O[_="en-"+I[C]]=O["en-US"],R[_]=R["en-US"];O["pt-BR"]=O["pt-PT"],R["pt-BR"]=R["pt-PT"];for(var N,P=["AE","BH","DZ","EG","IQ","JO","KW","LB","LY","MA","QM","QA","SA","SD","SY","TN","YE"],L=0;L<P.length;L++)O[N="ar-"+P[L]]=O.ar,R[N]=R.ar;var U=/^[-+]?[0-9]+$/,z=/^[\x00-\x7F]+$/,B=/[^\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]/,j=/[\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]/,T=/[^\x00-\x7F]/,q=/[\uD800-\uDBFF][\uDC00-\uDFFF]/,H=/^(?:[-+]?(?:0|[1-9][0-9]*))$/,K=/^[-+]?[0-9]+$/,M=/^(?:[-+])?(?:[0-9]+)?(?:\.[0-9]*)?(?:[eE][\+\-]?(?:[0-9]+))?$/,G=/^[-+]?([0-9]+|\.[0-9]+|[0-9]+\.[0-9]+)$/,J=/^[0-9A-F]+$/i,W=/^#?([0-9A-F]{3}|[0-9A-F]{6})$/i,X=/^[A-Z]{2}[0-9A-Z]{3}\d{2}\d{5}$/,Y=/^[a-f0-9]{32}$/,V={md5:32,md4:32,sha1:40,sha256:64,sha384:96,sha512:128,ripemd128:32,ripemd160:40,tiger128:32,tiger160:40,tiger192:48,crc32:8,crc32b:8},Q={3:/^[0-9A-F]{8}-[0-9A-F]{4}-3[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i,4:/^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,5:/^[0-9A-F]{8}-[0-9A-F]{4}-5[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,all:/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i},ee=/^(?:4[0-9]{12}(?:[0-9]{3})?|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}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11}|62[0-9]{14})$/,te=/^[A-Z]{2}[0-9A-Z]{9}[0-9]$/,re=/^(?:[0-9]{9}X|[0-9]{10})$/,oe=/^(?:[0-9]{13})$/,ie=[1,3],ne="^\\d{4}-?\\d{3}[\\dX]$",ae={"ar-AE":/^((\+?971)|0)?5[024568]\d{7}$/,"ar-DZ":/^(\+?213|0)(5|6|7)\d{8}$/,"ar-EG":/^((\+?20)|0)?1[012]\d{8}$/,"ar-JO":/^(\+?962|0)?7[789]\d{7}$/,"ar-SY":/^(!?(\+?963)|0)?9\d{8}$/,"ar-SA":/^(!?(\+?966)|0)?5\d{8}$/,"en-US":/^(\+?1)?[2-9]\d{2}[2-9](?!11)\d{6}$/,"cs-CZ":/^(\+?420)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/,"sk-SK":/^(\+?421)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/,"de-DE":/^(\+?49[ \.\-])?([\(]{1}[0-9]{1,6}[\)])?([0-9 \.\-\/]{3,20})((x|ext|extension)[ ]?[0-9]{1,4})?$/,"da-DK":/^(\+?45)?(\d{8})$/,"el-GR":/^(\+?30)?(69\d{8})$/,"en-AU":/^(\+?61|0)4\d{8}$/,"en-GB":/^(\+?44|0)7\d{9}$/,"en-HK":/^(\+?852\-?)?[569]\d{3}\-?\d{4}$/,"en-IN":/^(\+?91|0)?[789]\d{9}$/,"en-KE":/^(\+?254|0)?[7]\d{8}$/,"en-NG":/^(\+?234|0)?[789]\d{9}$/,"en-NZ":/^(\+?64|0)2\d{7,9}$/,"en-UG":/^(\+?256|0)?[7]\d{8}$/,"en-RW":/^(\+?250|0)?[7]\d{8}$/,"en-TZ":/^(\+?255|0)?[67]\d{8}$/,"en-ZA":/^(\+?27|0)\d{9}$/,"en-ZM":/^(\+?26)?09[567]\d{7}$/,"es-ES":/^(\+?34)?(6\d{1}|7[1234])\d{7}$/,"fi-FI":/^(\+?358|0)\s?(4(0|1|2|4|5|6)?|50)\s?(\d\s?){4,8}\d$/,"fa-IR":/^(\+?98[\-\s]?|0)9[0-39]\d[\-\s]?\d{3}[\-\s]?\d{4}$/,"fr-FR":/^(\+?33|0)[67]\d{8}$/,"he-IL":/^(\+972|0)([23489]|5[0248]|77)[1-9]\d{6}/,"hu-HU":/^(\+?36)(20|30|70)\d{7}$/,"lt-LT":/^(\+370|8)\d{8}$/,"id-ID":/^(\+?62|0[1-9])[\s|\d]+$/,"it-IT":/^(\+?39)?\s?3\d{2} ?\d{6,7}$/,"ko-KR":/^((\+?82)[ \-]?)?0?1([0|1|6|7|8|9]{1})[ \-]?\d{3,4}[ \-]?\d{4}$/,"ja-JP":/^(\+?81|0)\d{1,4}[ \-]?\d{1,4}[ \-]?\d{4}$/,"ms-MY":/^(\+?6?01){1}(([145]{1}(\-|\s)?\d{7,8})|([236789]{1}(\s|\-)?\d{7}))$/,"nb-NO":/^(\+?47)?[49]\d{7}$/,"nl-BE":/^(\+?32|0)4?\d{8}$/,"nn-NO":/^(\+?47)?[49]\d{7}$/,"pl-PL":/^(\+?48)? ?[5-8]\d ?\d{3} ?\d{2} ?\d{2}$/,"pt-BR":/^(\+?55|0)\-?[1-9]{2}\-?[2-9]{1}\d{3,4}\-?\d{4}$/,"pt-PT":/^(\+?351)?9[1236]\d{7}$/,"ro-RO":/^(\+?4?0)\s?7\d{2}(\/|\s|\.|\-)?\d{3}(\s|\.|\-)?\d{3}$/,"en-PK":/^((\+92)|(0092))-{0,1}\d{3}-{0,1}\d{7}$|^\d{11}$|^\d{4}-\d{7}$/,"ru-RU":/^(\+?7|8)?9\d{9}$/,"sr-RS":/^(\+3816|06)[- \d]{5,9}$/,"tr-TR":/^(\+?90|0)?5\d{9}$/,"vi-VN":/^(\+?84|0)?((1(2([0-9])|6([2-9])|88|99))|(9((?!5)[0-9])))([0-9]{7})$/,"zh-CN":/^(\+?0?86\-?)?1[345789]\d{9}$/,"zh-TW":/^(\+?886\-?|0)?9\d{8}$/};ae["en-CA"]=ae["en-US"],ae["fr-BE"]=ae["nl-BE"],ae["zh-HK"]=ae["en-HK"];var le={symbol:"$",require_symbol:!1,allow_space_after_symbol:!1,symbol_after_digits:!1,allow_negatives:!0,parens_for_negatives:!1,negative_sign_before_digits:!1,negative_sign_after_digits:!1,allow_negative_sign_placeholder:!1,thousands_separator:",",decimal_separator:".",allow_decimal:!0,require_decimal:!1,digits_after_decimal:[2],allow_space_after_digits:!1},se=/^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/,ue=/[^A-Z0-9+\/=]/i,de=/^\s*data:([a-z]+\/[a-z0-9\-\+]+(;[a-z\-]+=[a-z0-9\-]+)?)?(;base64)?,[a-z0-9!\$&',\(\)\*\+,;=\-\._~:@\/\?%\s]*\s*$/i,ce=/^\(?[+-]?(90(\.0+)?|[1-8]?\d(\.\d+)?)$/,fe=/^\s?[+-]?(180(\.0+)?|1[0-7]\d(\.\d+)?|\d{1,2}(\.\d+)?)\)?$/,ge=/^\d{4}$/,pe=/^\d{5}$/,he=/^\d{6}$/,me={AT:ge,AU:he,BE:ge,CA:/^[ABCEGHJKLMNPRSTVXY]\d[ABCEGHJ-NPRSTV-Z][\s\-]?\d[ABCEGHJ-NPRSTV-Z]\d$/i,CH:ge,CZ:/^\d{3}\s?\d{2}$/,DE:pe,DK:ge,DZ:pe,ES:pe,FI:pe,FR:/^\d{2}\s?\d{3}$/,GB:/^(gir\s?0aa|[a-z]{1,2}\d[\da-z]?\s?(\d[a-z]{2})?)$/i,GR:/^\d{3}\s?\d{2}$/,IL:pe,IN:he,IS:/^\d{3}$/,IT:pe,JP:/^\d{3}\-\d{4}$/,KE:pe,LI:/^(948[5-9]|949[0-7])$/,MX:pe,NL:/^\d{4}\s?[a-z]{2}$/i,NO:ge,PL:/^\d{2}\-\d{3}$/,PT:/^\d{4}(\-\d{3})?$/,RO:he,RU:he,SA:pe,SE:/^\d{3}\s?\d{2}$/,TW:/^\d{3}(\d{2})?$/,US:/^\d{5}(-\d{4})?$/,ZA:ge,ZM:pe},_e={all_lowercase:!0,gmail_lowercase:!0,gmail_remove_dots:!0,gmail_remove_subaddress:!0,gmail_convert_googlemaildotcom:!0,outlookdotcom_lowercase:!0,outlookdotcom_remove_subaddress:!0,yahoo_lowercase:!0,yahoo_remove_subaddress:!0,icloud_lowercase:!0,icloud_remove_subaddress:!0},ve=["icloud.com","me.com"],$e=["hotmail.at","hotmail.be","hotmail.ca","hotmail.cl","hotmail.co.il","hotmail.co.nz","hotmail.co.th","hotmail.co.uk","hotmail.com","hotmail.com.ar","hotmail.com.au","hotmail.com.br","hotmail.com.gr","hotmail.com.mx","hotmail.com.pe","hotmail.com.tr","hotmail.com.vn","hotmail.cz","hotmail.de","hotmail.dk","hotmail.es","hotmail.fr","hotmail.hu","hotmail.id","hotmail.ie","hotmail.in","hotmail.it","hotmail.jp","hotmail.kr","hotmail.lv","hotmail.my","hotmail.ph","hotmail.pt","hotmail.sa","hotmail.sg","hotmail.sk","live.be","live.co.uk","live.com","live.com.ar","live.com.mx","live.de","live.es","live.eu","live.fr","live.it","live.nl","msn.com","outlook.at","outlook.be","outlook.cl","outlook.co.il","outlook.co.nz","outlook.co.th","outlook.com","outlook.com.ar","outlook.com.au","outlook.com.br","outlook.com.gr","outlook.com.pe","outlook.com.tr","outlook.com.vn","outlook.cz","outlook.de","outlook.dk","outlook.es","outlook.fr","outlook.hu","outlook.id","outlook.ie","outlook.in","outlook.it","outlook.jp","outlook.kr","outlook.lv","outlook.my","outlook.ph","outlook.pt","outlook.sa","outlook.sg","outlook.sk","passport.com"],Fe=["rocketmail.com","yahoo.ca","yahoo.co.uk","yahoo.com","yahoo.de","yahoo.fr","yahoo.in","yahoo.it","ymail.com"];return{version:"8.2.0",toDate:t,toFloat:r,toInt:function(t,r){return e(t),parseInt(t,r||10)},toBoolean:function(t,r){return e(t),r?"1"===t||"true"===t:"0"!==t&&"false"!==t&&""!==t},equals:function(t,r){return e(t),t===r},contains:function(t,r){return e(t),t.indexOf(o(r))>=0},matches:function(t,r,o){return e(t),"[object RegExp]"!==Object.prototype.toString.call(r)&&(r=new RegExp(r,o)),r.test(t)},isEmail:l,isURL:function(t,r){if(e(t),!t||t.length>=2083||/[\s<>]/.test(t))return!1;if(0===t.indexOf("mailto:"))return!1;r=i(r,Z);var o=void 0,n=void 0,l=void 0,u=void 0,c=void 0,f=void 0,g=void 0,p=void 0;if(g=t.split("#"),t=g.shift(),g=t.split("?"),t=g.shift(),(g=t.split("://")).length>1){if(o=g.shift(),r.require_valid_protocol&&-1===r.protocols.indexOf(o))return!1}else{if(r.require_protocol)return!1;r.allow_protocol_relative_urls&&"//"===t.substr(0,2)&&(g[0]=t.substr(2))}if(""===(t=g.join("://")))return!1;if(g=t.split("/"),""===(t=g.shift())&&!r.require_host)return!0;if((g=t.split("@")).length>1&&(n=g.shift()).indexOf(":")>=0&&n.split(":").length>2)return!1;f=null,p=null;var h=(u=g.join("@")).match(k);return h?(l="",p=h[1],f=h[2]||null):(l=(g=u.split(":")).shift(),g.length&&(f=g.join(":"))),!(null!==f&&(c=parseInt(f,10),!/^[0-9]+$/.test(f)||c<=0||c>65535)||!(s(l)||a(l,r)||p&&s(p,6))||(l=l||p,r.host_whitelist&&!d(l,r.host_whitelist)||r.host_blacklist&&d(l,r.host_blacklist)))},isMACAddress:function(t){return e(t),D.test(t)},isIP:s,isFQDN:a,isBoolean:function(t){return e(t),["true","false","1","0"].indexOf(t)>=0},isAlpha:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"en-US";if(e(t),r in O)return O[r].test(t);throw new Error("Invalid locale '"+r+"'")},isAlphanumeric:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"en-US";if(e(t),r in R)return R[r].test(t);throw new Error("Invalid locale '"+r+"'")},isNumeric:function(t){return e(t),U.test(t)},isLowercase:function(t){return e(t),t===t.toLowerCase()},isUppercase:function(t){return e(t),t===t.toUpperCase()},isAscii:function(t){return e(t),z.test(t)},isFullWidth:function(t){return e(t),B.test(t)},isHalfWidth:function(t){return e(t),j.test(t)},isVariableWidth:function(t){return e(t),B.test(t)&&j.test(t)},isMultibyte:function(t){return e(t),T.test(t)},isSurrogatePair:function(t){return e(t),q.test(t)},isInt:function(t,r){e(t);var o=(r=r||{}).hasOwnProperty("allow_leading_zeroes")&&!r.allow_leading_zeroes?H:K,i=!r.hasOwnProperty("min")||t>=r.min,n=!r.hasOwnProperty("max")||t<=r.max,a=!r.hasOwnProperty("lt")||t<r.lt,l=!r.hasOwnProperty("gt")||t>r.gt;return o.test(t)&&i&&n&&a&&l},isFloat:function(t,r){return e(t),r=r||{},""!==t&&"."!==t&&M.test(t)&&(!r.hasOwnProperty("min")||t>=r.min)&&(!r.hasOwnProperty("max")||t<=r.max)&&(!r.hasOwnProperty("lt")||t<r.lt)&&(!r.hasOwnProperty("gt")||t>r.gt)},isDecimal:function(t){return e(t),""!==t&&G.test(t)},isHexadecimal:c,isDivisibleBy:function(t,o){return e(t),r(t)%parseInt(o,10)==0},isHexColor:function(t){return e(t),W.test(t)},isISRC:function(t){return e(t),X.test(t)},isMD5:function(t){return e(t),Y.test(t)},isHash:function(t,r){return e(t),new RegExp("^[a-f0-9]{"+V[r]+"}$").test(t)},isJSON:function(t){e(t);try{var r=JSON.parse(t);return!!r&&"object"===(void 0===r?"undefined":v(r))}catch(e){}return!1},isEmpty:function(t){return e(t),0===t.length},isLength:function(t,r){e(t);var o=void 0,i=void 0;"object"===(void 0===r?"undefined":v(r))?(o=r.min||0,i=r.max):(o=arguments[1],i=arguments[2]);var n=t.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g)||[],a=t.length-n.length;return a>=o&&(void 0===i||a<=i)},isByteLength:n,isUUID:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"all";e(t);var o=Q[r];return o&&o.test(t)},isMongoId:function(t){return e(t),c(t)&&24===t.length},isAfter:function(r){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:String(new Date);e(r);var i=t(o),n=t(r);return!!(n&&i&&n>i)},isBefore:function(r){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:String(new Date);e(r);var i=t(o),n=t(r);return!!(n&&i&&n<i)},isIn:function(t,r){e(t);var i=void 0;if("[object Array]"===Object.prototype.toString.call(r)){var n=[];for(i in r)({}).hasOwnProperty.call(r,i)&&(n[i]=o(r[i]));return n.indexOf(t)>=0}return"object"===(void 0===r?"undefined":v(r))?r.hasOwnProperty(t):!(!r||"function"!=typeof r.indexOf)&&r.indexOf(t)>=0},isCreditCard:function(t){e(t);var r=t.replace(/[- ]+/g,"");if(!ee.test(r))return!1;for(var o=0,i=void 0,n=void 0,a=void 0,l=r.length-1;l>=0;l--)i=r.substring(l,l+1),n=parseInt(i,10),o+=a&&(n*=2)>=10?n%10+1:n,a=!a;return!(o%10!=0||!r)},isISIN:function(t){if(e(t),!te.test(t))return!1;for(var r=t.replace(/[A-Z]/g,function(e){return parseInt(e,36)}),o=0,i=void 0,n=void 0,a=!0,l=r.length-2;l>=0;l--)i=r.substring(l,l+1),n=parseInt(i,10),o+=a&&(n*=2)>=10?n+1:n,a=!a;return parseInt(t.substr(t.length-1),10)===(1e4-o)%10},isISBN:f,isISSN:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e(t);var o=ne;if(o=r.require_hyphen?o.replace("?",""):o,!(o=r.case_sensitive?new RegExp(o):new RegExp(o,"i")).test(t))return!1;var i=t.replace("-",""),n=8,a=0,l=!0,s=!1,u=void 0;try{for(var d,c=i[Symbol.iterator]();!(l=(d=c.next()).done);l=!0){var f=d.value;a+=("X"===f.toUpperCase()?10:+f)*n,--n}}catch(e){s=!0,u=e}finally{try{!l&&c.return&&c.return()}finally{if(s)throw u}}return a%11==0},isMobilePhone:function(t,r){if(e(t),r in ae)return ae[r].test(t);if("any"===r){for(var o in ae)if(ae.hasOwnProperty(o)&&ae[o].test(t))return!0;return!1}throw new Error("Invalid locale '"+r+"'")},isPostalCode:function(t,r){if(e(t),r in me)return me[r].test(t);if("any"===r){for(var o in me)if(me.hasOwnProperty(o)&&me[o].test(t))return!0;return!1}throw new Error("Invalid locale '"+r+"'")},isCurrency:function(t,r){return e(t),r=i(r,le),g(r).test(t)},isISO8601:function(t){return e(t),se.test(t)},isBase64:function(t){e(t);var r=t.length;if(!r||r%4!=0||ue.test(t))return!1;var o=t.indexOf("=");return-1===o||o===r-1||o===r-2&&"="===t[r-1]},isDataURI:function(t){return e(t),de.test(t)},isLatLong:function(t){if(e(t),!t.includes(","))return!1;var r=t.split(",");return ce.test(r[0])&&fe.test(r[1])},ltrim:p,rtrim:h,trim:function(e,t){return h(p(e,t),t)},escape:function(t){return e(t),t.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">").replace(/\//g,"/").replace(/\\/g,"\").replace(/`/g,"`")},unescape:function(t){return e(t),t.replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">").replace(///g,"/").replace(/\/g,"\\").replace(/`/g,"`")},stripLow:function(t,r){return e(t),m(t,r?"\\x00-\\x09\\x0B\\x0C\\x0E-\\x1F\\x7F":"\\x00-\\x1F\\x7F")},whitelist:function(t,r){return e(t),t.replace(new RegExp("[^"+r+"]+","g"),"")},blacklist:m,isWhitelisted:function(t,r){e(t);for(var o=t.length-1;o>=0;o--)if(-1===r.indexOf(t[o]))return!1;return!0},normalizeEmail:function(e,t){if(t=i(t,_e),!l(e))return!1;var r=e.split("@"),o=r.pop(),n=[r.join("@"),o];if(n[1]=n[1].toLowerCase(),"gmail.com"===n[1]||"googlemail.com"===n[1]){if(t.gmail_remove_subaddress&&(n[0]=n[0].split("+")[0]),t.gmail_remove_dots&&(n[0]=n[0].replace(/\./g,"")),!n[0].length)return!1;(t.all_lowercase||t.gmail_lowercase)&&(n[0]=n[0].toLowerCase()),n[1]=t.gmail_convert_googlemaildotcom?"gmail.com":n[1]}else if(~ve.indexOf(n[1])){if(t.icloud_remove_subaddress&&(n[0]=n[0].split("+")[0]),!n[0].length)return!1;(t.all_lowercase||t.icloud_lowercase)&&(n[0]=n[0].toLowerCase())}else if(~$e.indexOf(n[1])){if(t.outlookdotcom_remove_subaddress&&(n[0]=n[0].split("+")[0]),!n[0].length)return!1;(t.all_lowercase||t.outlookdotcom_lowercase)&&(n[0]=n[0].toLowerCase())}else if(~Fe.indexOf(n[1])){if(t.yahoo_remove_subaddress){var a=n[0].split("-");n[0]=a.length>1?a.slice(0,-1).join("-"):a[0]}if(!n[0].length)return!1;(t.all_lowercase||t.yahoo_lowercase)&&(n[0]=n[0].toLowerCase())}else t.all_lowercase&&(n[0]=n[0].toLowerCase());return n.join("@")},toString:o}}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
180675
75
3277
206