diff --git a/README.md b/README.md index 41538e84c..a771bab0d 100644 --- a/README.md +++ b/README.md @@ -63,8 +63,8 @@ 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).

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', 'el-GR', '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', 'sk-SK', '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.

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', 'el-GR', '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', 'sk-SK', 'sr-RS', 'sr-RS@latin', 'sv-SE', 'tr-TR', 'uk-UA']`) and defaults to `en-US`. +**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', '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', 'fr-FR', 'hu-HU', 'it-IT', 'nb-NO', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ru-RU', 'sk-SK', '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.

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', 'fr-FR', 'hu-HU', 'it-IT', 'nb-NO', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ru-RU', 'sk-SK', '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. @@ -73,12 +73,12 @@ Validator | Description **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_decimal: true, require_decimal: false, digits_after_decimal: [2], allow_space_after_digits: false}`.
**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, options)** | check if the string represents a decimal number, such as 0.1, .3, 1.1, 1.00003, 4.0, etc.

`options` is an object which defaults to `{force_decimal: false, decimal_digits: '1,', locale: 'en-US'}`

`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', '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']`.
**Note:** `decimal_digits` is given as a range like '1,3', a specific value like '3' or min like '1,'. +**isDecimal(str, options)** | check if the string represents a decimal number, such as 0.1, .3, 1.1, 1.00003, 4.0, etc.

`options` is an object which defaults to `{force_decimal: false, decimal_digits: '1,', locale: 'en-US'}`

`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-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']`.
**Note:** `decimal_digits` is given as a range like '1,3', a specific value like '3' or min like '1,'. **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 `. If `require_display_name` is set to true, the validator will reject strings without the format `Display Name `. 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 }`) it also has `locale` as an option.

`min` and `max` are equivalent to 'greater or equal' and 'less or equal', respectively while `gt` and `lt` are their strict counterparts.

`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', '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']`. +**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 }`) it also has `locale` as an option.

`min` and `max` are equivalent to 'greater or equal' and 'less or equal', respectively while `gt` and `lt` are their strict counterparts.

`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-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']`. **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.

Algorithm is one of `['md4', 'md5', 'sha1', 'sha256', 'sha384', 'sha512', 'ripemd128', 'ripemd160', 'tiger128', 'tiger160', 'tiger192', 'crc32', 'crc32b']` @@ -100,12 +100,12 @@ Validator | Description **isMACAddress(str)** | check if the string is a MAC address. **isMD5(str)** | check if the string is a MD5 hash. **isMimeType(str)** | check if the string matches to a valid [MIME type](https://en.wikipedia.org/wiki/Media_type) format -**isMobilePhone(str, locale)** | check if the string is a mobile phone number,

(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-SG', 'en-UG', 'en-US', 'en-TZ', 'en-ZA', 'en-ZM', 'en-PK', 'es-ES', 'et-EE', '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', 'pt-BR','ro-RO', 'ru-RU', 'sk-SK', 'sr-RS', 'tr-TR', 'uk-UA', 'vi-VN', 'zh-CN', 'zh-HK', 'zh-TW']` OR 'any'. If 'any' is used, function will check if any of the locales match). +**isMobilePhone(str, locale)** | check if the string is a mobile phone number,

(locale is one of `['ar-AE', 'ar-DZ', 'ar-EG', 'ar-JO', 'ar-SA', 'ar-SY', 'bg-BG', '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-SG', 'en-UG', 'en-US', 'en-TZ', 'en-ZA', 'en-ZM', 'en-PK', 'es-ES', 'et-EE', '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', 'pt-BR', 'ro-RO', 'ru-RU', 'sk-SK', 'sr-RS', 'tr-TR', 'uk-UA', '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. **isPort(str)** | check if the string is a valid port number. -**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). +**isPostalCode(str, locale)** | check if the string is a postal code,

(locale is one of `[ 'AT', 'AU', 'BE', 'BG', '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). diff --git a/lib/alpha.js b/lib/alpha.js index 98874140c..8456bc41c 100644 --- a/lib/alpha.js +++ b/lib/alpha.js @@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", { }); var alpha = exports.alpha = { 'en-US': /^[A-Z]+$/i, + 'bg-BG': /^[А-Я]+$/i, 'cs-CZ': /^[A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]+$/i, 'da-DK': /^[A-ZÆØÅ]+$/i, 'de-DE': /^[A-ZÄÖÜß]+$/i, @@ -30,6 +31,7 @@ var alpha = exports.alpha = { var alphanumeric = exports.alphanumeric = { 'en-US': /^[0-9A-Z]+$/i, + 'bg-BG': /^[0-9А-Я]+$/i, 'cs-CZ': /^[0-9A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]+$/i, 'da-DK': /^[0-9A-ZÆØÅ]+$/i, 'de-DE': /^[0-9A-ZÄÖÜß]+$/i, @@ -79,7 +81,7 @@ for (var _locale, _i = 0; _i < arabicLocales.length; _i++) { // Source: https://en.wikipedia.org/wiki/Decimal_mark var dotDecimal = exports.dotDecimal = []; -var commaDecimal = exports.commaDecimal = ['cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'es-ES', 'fr-FR', 'it-IT', 'hu-HU', 'nb-NO', 'nn-NO', 'nl-NL', 'pl-Pl', 'pt-PT', 'ru-RU', 'sr-RS@latin', 'sr-RS', 'sv-SE', 'tr-TR', 'uk-UA']; +var commaDecimal = exports.commaDecimal = ['bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'es-ES', 'fr-FR', 'it-IT', 'hu-HU', 'nb-NO', 'nn-NO', 'nl-NL', 'pl-Pl', 'pt-PT', 'ru-RU', 'sr-RS@latin', 'sr-RS', 'sv-SE', 'tr-TR', 'uk-UA']; for (var _i2 = 0; _i2 < dotDecimal.length; _i2++) { decimal[dotDecimal[_i2]] = decimal['en-US']; diff --git a/lib/isMobilePhone.js b/lib/isMobilePhone.js index 181fc1776..2bf103aaf 100644 --- a/lib/isMobilePhone.js +++ b/lib/isMobilePhone.js @@ -19,6 +19,7 @@ var phones = { 'ar-JO': /^(\+?962|0)?7[789]\d{7}$/, 'ar-SA': /^(!?(\+?966)|0)?5\d{8}$/, 'ar-SY': /^(!?(\+?963)|0)?9\d{8}$/, + 'bg-BG': /^(\+?359|0)?8[789]\d{7}$/, 'cs-CZ': /^(\+?420)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/, 'da-DK': /^(\+?45)?\s?\d{2}\s?\d{2}\s?\d{2}\s?\d{2}$/, 'de-DE': /^(\+?49[ \.\-])?([\(]{1}[0-9]{1,6}[\)])?([0-9 \.\-\/]{3,20})((x|ext|extension)[ ]?[0-9]{1,4})?$/, diff --git a/lib/isPostalCode.js b/lib/isPostalCode.js index d4523bd1d..0d9564396 100644 --- a/lib/isPostalCode.js +++ b/lib/isPostalCode.js @@ -39,6 +39,7 @@ var patterns = { AT: fourDigit, AU: fourDigit, BE: fourDigit, + BG: fourDigit, CA: /^[ABCEGHJKLMNPRSTVXY]\d[ABCEGHJ-NPRSTV-Z][\s\-]?\d[ABCEGHJ-NPRSTV-Z]\d$/i, CH: fourDigit, CZ: /^\d{3}\s?\d{2}$/, diff --git a/src/lib/alpha.js b/src/lib/alpha.js index 07f5a38cc..bdc129fe0 100644 --- a/src/lib/alpha.js +++ b/src/lib/alpha.js @@ -1,5 +1,6 @@ export const alpha = { 'en-US': /^[A-Z]+$/i, + 'bg-BG': /^[А-Я]+$/i, 'cs-CZ': /^[A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]+$/i, 'da-DK': /^[A-ZÆØÅ]+$/i, 'de-DE': /^[A-ZÄÖÜß]+$/i, @@ -25,6 +26,7 @@ export const alpha = { export const alphanumeric = { 'en-US': /^[0-9A-Z]+$/i, + 'bg-BG': /^[0-9А-Я]+$/i, 'cs-CZ': /^[0-9A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]+$/i, 'da-DK': /^[0-9A-ZÆØÅ]+$/i, 'de-DE': /^[0-9A-ZÄÖÜß]+$/i, @@ -79,7 +81,7 @@ for (let locale, i = 0; i < arabicLocales.length; i++) { // Source: https://en.wikipedia.org/wiki/Decimal_mark export const dotDecimal = []; export const commaDecimal = [ - 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'es-ES', 'fr-FR', 'it-IT', 'hu-HU', 'nb-NO', + 'bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'es-ES', 'fr-FR', 'it-IT', 'hu-HU', 'nb-NO', 'nn-NO', 'nl-NL', 'pl-Pl', 'pt-PT', 'ru-RU', 'sr-RS@latin', 'sr-RS', 'sv-SE', 'tr-TR', 'uk-UA', ]; diff --git a/src/lib/isMobilePhone.js b/src/lib/isMobilePhone.js index d6bfae9c7..f546e7ee9 100644 --- a/src/lib/isMobilePhone.js +++ b/src/lib/isMobilePhone.js @@ -8,6 +8,7 @@ const phones = { 'ar-JO': /^(\+?962|0)?7[789]\d{7}$/, 'ar-SA': /^(!?(\+?966)|0)?5\d{8}$/, 'ar-SY': /^(!?(\+?963)|0)?9\d{8}$/, + 'bg-BG': /^(\+?359|0)?8[789]\d{7}$/, 'cs-CZ': /^(\+?420)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/, 'da-DK': /^(\+?45)?\s?\d{2}\s?\d{2}\s?\d{2}\s?\d{2}$/, 'de-DE': /^(\+?49[ \.\-])?([\(]{1}[0-9]{1,6}[\)])?([0-9 \.\-\/]{3,20})((x|ext|extension)[ ]?[0-9]{1,4})?$/, diff --git a/src/lib/isPostalCode.js b/src/lib/isPostalCode.js index 831178a59..cd0e5eeac 100644 --- a/src/lib/isPostalCode.js +++ b/src/lib/isPostalCode.js @@ -10,6 +10,7 @@ const patterns = { AT: fourDigit, AU: fourDigit, BE: fourDigit, + BG: fourDigit, CA: /^[ABCEGHJKLMNPRSTVXY]\d[ABCEGHJ-NPRSTV-Z][\s\-]?\d[ABCEGHJ-NPRSTV-Z]\d$/i, CH: fourDigit, CZ: /^\d{3}\s?\d{2}$/, diff --git a/test/validators.js b/test/validators.js index 20ba124d7..1faa06a38 100644 --- a/test/validators.js +++ b/test/validators.js @@ -692,6 +692,27 @@ describe('Validators', function () { }); }); + it('should validate bulgarian alpha strings', function () { + test({ + validator: 'isAlpha', + args: ['bg-BG'], + valid: [ + 'абв', + 'АБВ', + 'жаба', + 'яГоДа', + ], + invalid: [ + 'abc1', + ' foo ', + '', + 'ЁЧПС', + '_аз_обичам_обувки_', + 'ехо!', + ], + }); + }); + it('should validate czech alpha strings', function () { test({ validator: 'isAlpha', @@ -1077,6 +1098,26 @@ describe('Validators', function () { }); }); + it('should validate bulgarian alphanumeric strings', function () { + test({ + validator: 'isAlphanumeric', + args: ['bg-BG'], + valid: [ + 'абв1', + '4АБ5В6', + 'жаба', + 'яГоДа2', + 'йЮя', + '123', + ], + invalid: [ + ' ', + '789 ', + 'hello000', + ], + }); + }); + it('should validate czech alphanumeric strings', function () { test({ validator: 'isAlphanumeric', @@ -1528,6 +1569,46 @@ describe('Validators', function () { ], }); + test({ + validator: 'isDecimal', + args: [{ locale: ['bg-BG'] }], + valid: [ + '123', + '00123', + '-00123', + '0', + '-0', + '+123', + '0,01', + ',1', + '1,0', + '-,25', + '-0', + '0,0000000000001', + ], + invalid: [ + '0.0000000000001', + '0.01', + '.1', + '1.0', + '-.25', + '0٫01', + '٫1', + '1٫0', + '-٫25', + '0٫0000000000001', + '....', + ' ', + '', + '-', + '+', + '.', + '0.1a', + 'a', + '\n', + ], + }); + test({ validator: 'isDecimal', args: [{ locale: ['cs-CZ'] }], @@ -3053,6 +3134,21 @@ describe('Validators', function () { '0114152198', ], }, + { + locale: 'bg-BG', + valid: [ + '+359897123456', + '+359898888888', + '0897123123', + ], + invalid: [ + '', + '0898123', + '+359212555666', + '18001234567', + '12125559999', + ], + }, { locale: 'cs-CZ', valid: [ @@ -5117,6 +5213,12 @@ describe('Validators', function () { '39940', ], }, + { + locale: 'BG', + valid: [ + '1000', + ], + }, { locale: 'CZ', valid: [ diff --git a/validator.js b/validator.js index 279865735..1aa11b1e8 100644 --- a/validator.js +++ b/validator.js @@ -436,6 +436,7 @@ function isBoolean(str) { var alpha = { 'en-US': /^[A-Z]+$/i, + 'bg-BG': /^[А-Я]+$/i, 'cs-CZ': /^[A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]+$/i, 'da-DK': /^[A-ZÆØÅ]+$/i, 'de-DE': /^[A-ZÄÖÜß]+$/i, @@ -461,6 +462,7 @@ var alpha = { var alphanumeric = { 'en-US': /^[0-9A-Z]+$/i, + 'bg-BG': /^[0-9А-Я]+$/i, 'cs-CZ': /^[0-9A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]+$/i, 'da-DK': /^[0-9A-ZÆØÅ]+$/i, 'de-DE': /^[0-9A-ZÄÖÜß]+$/i, @@ -510,7 +512,7 @@ for (var _locale, _i = 0; _i < arabicLocales.length; _i++) { // Source: https://en.wikipedia.org/wiki/Decimal_mark var dotDecimal = []; -var commaDecimal = ['cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'es-ES', 'fr-FR', 'it-IT', 'hu-HU', 'nb-NO', 'nn-NO', 'nl-NL', 'pl-Pl', 'pt-PT', 'ru-RU', 'sr-RS@latin', 'sr-RS', 'sv-SE', 'tr-TR', 'uk-UA']; +var commaDecimal = ['bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'es-ES', 'fr-FR', 'it-IT', 'hu-HU', 'nb-NO', 'nn-NO', 'nl-NL', 'pl-Pl', 'pt-PT', 'ru-RU', 'sr-RS@latin', 'sr-RS', 'sv-SE', 'tr-TR', 'uk-UA']; for (var _i2 = 0; _i2 < dotDecimal.length; _i2++) { decimal[dotDecimal[_i2]] = decimal['en-US']; @@ -970,6 +972,7 @@ var phones = { 'ar-JO': /^(\+?962|0)?7[789]\d{7}$/, 'ar-SA': /^(!?(\+?966)|0)?5\d{8}$/, 'ar-SY': /^(!?(\+?963)|0)?9\d{8}$/, + 'bg-BG': /^(\+?359|0)?8[789]\d{7}$/, 'cs-CZ': /^(\+?420)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/, 'da-DK': /^(\+?45)?\s?\d{2}\s?\d{2}\s?\d{2}\s?\d{2}$/, 'de-DE': /^(\+?49[ \.\-])?([\(]{1}[0-9]{1,6}[\)])?([0-9 \.\-\/]{3,20})((x|ext|extension)[ ]?[0-9]{1,4})?$/, @@ -1216,6 +1219,7 @@ var patterns = { AT: fourDigit, AU: fourDigit, BE: fourDigit, + BG: fourDigit, CA: /^[ABCEGHJKLMNPRSTVXY]\d[ABCEGHJ-NPRSTV-Z][\s\-]?\d[ABCEGHJ-NPRSTV-Z]\d$/i, CH: fourDigit, CZ: /^\d{3}\s?\d{2}$/, diff --git a/validator.min.js b/validator.min.js index 6ad39f4b4..e47bdda45 100644 --- a/validator.min.js +++ b/validator.min.js @@ -20,4 +20,4 @@ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -!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 i(e){return"object"===(void 0===e?"undefined":_(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 o(){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 i=void 0,o=void 0;"object"===(void 0===r?"undefined":_(r))?(i=r.min||0,o=r.max):(i=arguments[1],o=arguments[2]);var n=encodeURI(t).split(/%..|./).length-1;return n>=i&&(void 0===o||n<=o)}function a(t,r){e(t),(r=o(r,$)).allow_trailing_dot&&"."===t[t.length-1]&&(t=t.substring(0,t.length-1));var i=t.split(".");if(r.require_tld){var n=i.pop();if(!i.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;l1&&void 0!==arguments[1]?arguments[1]:"";if(e(t),!(r=String(r)))return l(t,4)||l(t,6);if("4"===r){if(!E.test(t))return!1;return t.split(".").sort(function(e,t){return e-t})[3]<=255}if("6"===r){var i=t.split(":"),o=!1,n=l(i[i.length-1],4),a=n?7:8;if(i.length>a)return!1;if("::"===t)return!0;"::"===t.substr(0,2)?(i.shift(),i.shift(),o=!0):"::"===t.substr(t.length-2)&&(i.pop(),i.pop(),o=!0);for(var s=0;s0&&s=1:i.length===a}return!1}function s(e){return"[object RegExp]"===Object.prototype.toString.call(e)}function u(e,t){for(var r=0;r=r.min,n=!r.hasOwnProperty("max")||t<=r.max,a=!r.hasOwnProperty("lt")||tr.gt;return i.test(t)&&o&&n&&a&&l}function c(t){return e(t),Q.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 i=t.replace(/[\s-]+/g,""),o=0,n=void 0;if("10"===r){if(!ae.test(i))return!1;for(n=0;n<9;n++)o+=(n+1)*i.charAt(n);if("X"===i.charAt(9)?o+=100:o+=10*i.charAt(9),o%11==0)return!!i}else if("13"===r){if(!le.test(i))return!1;for(n=0;n<12;n++)o+=se[n%2]*i.charAt(n);if(i.charAt(12)-(10-o%10)%10==0)return!!i}return!1}function p(t,r){e(t);var i=r?new RegExp("^["+r+"]+","g"):/^\s+/g;return t.replace(i,"")}function g(t,r){e(t);for(var i=r?new RegExp("["+r+"]"):/\s/,o=t.length-1;o>=0&&i.test(t[o]);)o--;return o$/i,A=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i,x=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i,S=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i,w=/^([\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})$/,Z=/^[0-9A-F]{1,4}$/i,y={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},b=/^\[([^\]]+)\](?::([0-9]+))?$/,R=/^([0-9a-fA-F][0-9a-fA-F]:){5}([0-9a-fA-F][0-9a-fA-F])$/,C={"en-US":/^[A-Z]+$/i,"cs-CZ":/^[A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]+$/i,"da-DK":/^[A-ZÆØÅ]+$/i,"de-DE":/^[A-ZÄÖÜß]+$/i,"el-GR":/^[Α-ω]+$/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,"sk-SK":/^[A-ZÁČĎÉÍŇÓŠŤÚÝŽĹŔĽÄÔ]+$/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:/^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/},D={"en-US":/^[0-9A-Z]+$/i,"cs-CZ":/^[0-9A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]+$/i,"da-DK":/^[0-9A-ZÆØÅ]+$/i,"de-DE":/^[0-9A-ZÄÖÜß]+$/i,"el-GR":/^[0-9Α-ω]+$/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,"sk-SK":/^[0-9A-ZÁČĎÉÍŇÓŠŤÚÝŽĹŔĽÄÔ]+$/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={"en-US":".",ar:"٫"},O=["AU","GB","HK","IN","NZ","ZA","ZM"],k=0;k=0},matches:function(t,r,i){return e(t),"[object RegExp]"!==Object.prototype.toString.call(r)&&(r=new RegExp(r,i)),r.test(t)},isEmail:function(t,r){if(e(t),(r=o(r,v)).require_display_name||r.allow_display_name){var i=t.match(F);if(i)t=i[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?w.test(u):x.test(u);for(var c=r.allow_utf8_local_part?S:A,f=u.split("."),p=0;p=2083||/[\s<>]/.test(t))return!1;if(0===t.indexOf("mailto:"))return!1;r=o(r,y);var i=void 0,n=void 0,s=void 0,d=void 0,c=void 0,f=void 0,p=void 0,g=void 0;if(p=t.split("#"),t=p.shift(),p=t.split("?"),t=p.shift(),(p=t.split("://")).length>1){if(i=p.shift(),r.require_valid_protocol&&-1===r.protocols.indexOf(i))return!1}else{if(r.require_protocol)return!1;r.allow_protocol_relative_urls&&"//"===t.substr(0,2)&&(p[0]=t.substr(2))}if(""===(t=p.join("://")))return!1;if(p=t.split("/"),""===(t=p.shift())&&!r.require_host)return!0;if((p=t.split("@")).length>1&&(n=p.shift()).indexOf(":")>=0&&n.split(":").length>2)return!1;f=null,g=null;var m=(d=p.join("@")).match(b);return m?(s="",g=m[1],f=m[2]||null):(s=(p=d.split(":")).shift(),p.length&&(f=p.join(":"))),!(null!==f&&(c=parseInt(f,10),!/^[0-9]+$/.test(f)||c<=0||c>65535)||!(l(s)||a(s,r)||g&&l(g,6))||(s=s||g,r.host_whitelist&&!u(s,r.host_whitelist)||r.host_blacklist&&u(s,r.host_blacklist)))},isMACAddress:function(t){return e(t),R.test(t)},isIP:l,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 C)return C[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 D)return D[r].test(t);throw new Error("Invalid locale '"+r+"'")},isNumeric:function(t){return e(t),G.test(t)},isPort:function(e){return d(e,{min:0,max:65535})},isLowercase:function(t){return e(t),t===t.toLowerCase()},isUppercase:function(t){return e(t),t===t.toUpperCase()},isAscii:function(t){return e(t),H.test(t)},isFullWidth:function(t){return e(t),j.test(t)},isHalfWidth:function(t){return e(t),q.test(t)},isVariableWidth:function(t){return e(t),j.test(t)&&q.test(t)},isMultibyte:function(t){return e(t),W.test(t)},isSurrogatePair:function(t){return e(t),J.test(t)},isInt:d,isFloat:function(t,r){e(t),r=r||{};var i=new RegExp("^(?:[-+])?(?:[0-9]+)?(?:\\"+(r.locale?I[r.locale]:".")+"[0-9]*)?(?:[eE][\\+\\-]?(?:[0-9]+))?$");return""!==t&&"."!==t&&"-"!==t&&"+"!==t&&i.test(t)&&(!r.hasOwnProperty("min")||t>=r.min)&&(!r.hasOwnProperty("max")||t<=r.max)&&(!r.hasOwnProperty("lt")||tr.gt)},isDecimal:function(t,r){if(e(t),(r=o(r,V)).locale in I)return!Y.includes(t.replace(/ /g,""))&&function(e){return new RegExp("^[-+]?([0-9]+)?(\\"+I[e.locale]+"[0-9]{"+e.decimal_digits+"})"+(e.force_decimal?"":"?")+"$")}(r).test(t);throw new Error("Invalid locale '"+r.locale+"'")},isHexadecimal:c,isDivisibleBy:function(t,i){return e(t),r(t)%parseInt(i,10)==0},isHexColor:function(t){return e(t),X.test(t)},isISRC:function(t){return e(t),ee.test(t)},isMD5:function(t){return e(t),te.test(t)},isHash:function(t,r){return e(t),new RegExp("^[a-f0-9]{"+re[r]+"}$").test(t)},isJSON:function(t){e(t);try{var r=JSON.parse(t);return!!r&&"object"===(void 0===r?"undefined":_(r))}catch(e){}return!1},isEmpty:function(t){return e(t),0===t.length},isLength:function(t,r){e(t);var i=void 0,o=void 0;"object"===(void 0===r?"undefined":_(r))?(i=r.min||0,o=r.max):(i=arguments[1],o=arguments[2]);var n=t.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g)||[],a=t.length-n.length;return a>=i&&(void 0===o||a<=o)},isByteLength:n,isUUID:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"all";e(t);var i=ie[r];return i&&i.test(t)},isMongoId:function(t){return e(t),c(t)&&24===t.length},isAfter:function(r){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:String(new Date);e(r);var o=t(i),n=t(r);return!!(n&&o&&n>o)},isBefore:function(r){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:String(new Date);e(r);var o=t(i),n=t(r);return!!(n&&o&&n=0}return"object"===(void 0===r?"undefined":_(r))?r.hasOwnProperty(t):!(!r||"function"!=typeof r.indexOf)&&r.indexOf(t)>=0},isCreditCard:function(t){e(t);var r=t.replace(/[- ]+/g,"");if(!oe.test(r))return!1;for(var i=0,o=void 0,n=void 0,a=void 0,l=r.length-1;l>=0;l--)o=r.substring(l,l+1),n=parseInt(o,10),i+=a&&(n*=2)>=10?n%10+1:n,a=!a;return!(i%10!=0||!r)},isISIN:function(t){if(e(t),!ne.test(t))return!1;for(var r=t.replace(/[A-Z]/g,function(e){return parseInt(e,36)}),i=0,o=void 0,n=void 0,a=!0,l=r.length-2;l>=0;l--)o=r.substring(l,l+1),n=parseInt(o,10),i+=a&&(n*=2)>=10?n+1:n,a=!a;return parseInt(t.substr(t.length-1),10)===(1e4-i)%10},isISBN:f,isISSN:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e(t);var i=ue;if(i=r.require_hyphen?i.replace("?",""):i,!(i=r.case_sensitive?new RegExp(i):new RegExp(i,"i")).test(t))return!1;var o=t.replace("-",""),n=8,a=0,l=!0,s=!1,u=void 0;try{for(var d,c=o[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 de)return de[r].test(t);if("any"===r){for(var i in de)if(de.hasOwnProperty(i)&&de[i].test(t))return!0;return!1}throw new Error("Invalid locale '"+r+"'")},isPostalCode:function(t,r){if(e(t),r in we)return we[r].test(t);if("any"===r){for(var i in we)if(we.hasOwnProperty(i)&&we[i].test(t))return!0;return!1}throw new Error("Invalid locale '"+r+"'")},isCurrency:function(t,r){return e(t),r=o(r,ce),function(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?"":"?"),i="("+["0","[1-9]\\d*","[1-9]\\d{0,2}(\\"+e.thousands_separator+"\\d{3})*"].join("|")+")?",o="(\\"+e.decimal_separator+"("+t+"))"+(e.require_decimal?"":"?"),n=i+(e.allow_decimal||e.require_decimal?o:"");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+"$")}(r).test(t)},isISO8601:function(t){return e(t),fe.test(t)},isISO31661Alpha2:function(t){return e(t),pe.includes(t.toUpperCase())},isBase64:function(t){e(t);var r=t.length;if(!r||r%4!=0||ge.test(t))return!1;var i=t.indexOf("=");return-1===i||i===r-1||i===r-2&&"="===t[r-1]},isDataURI:function(t){return e(t),me.test(t)},isMimeType:function(t){return e(t),he.test(t)||_e.test(t)||$e.test(t)},isLatLong:function(t){if(e(t),!t.includes(","))return!1;var r=t.split(",");return ve.test(r[0])&&Fe.test(r[1])},ltrim:p,rtrim:g,trim:function(e,t){return g(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,"`")},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 i=t.length-1;i>=0;i--)if(-1===r.indexOf(t[i]))return!1;return!0},normalizeEmail:function(e,t){t=o(t,Ee);var r=e.split("@"),i=r.pop(),n=[r.join("@"),i];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(~Ze.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(~ye.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(~be.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:i}}); \ No newline at end of file +!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 i(e){return"object"===(void 0===e?"undefined":_(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 o(){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 i=void 0,o=void 0;"object"===(void 0===r?"undefined":_(r))?(i=r.min||0,o=r.max):(i=arguments[1],o=arguments[2]);var n=encodeURI(t).split(/%..|./).length-1;return n>=i&&(void 0===o||n<=o)}function a(t,r){e(t),(r=o(r,$)).allow_trailing_dot&&"."===t[t.length-1]&&(t=t.substring(0,t.length-1));var i=t.split(".");if(r.require_tld){var n=i.pop();if(!i.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;l1&&void 0!==arguments[1]?arguments[1]:"";if(e(t),!(r=String(r)))return l(t,4)||l(t,6);if("4"===r){if(!E.test(t))return!1;return t.split(".").sort(function(e,t){return e-t})[3]<=255}if("6"===r){var i=t.split(":"),o=!1,n=l(i[i.length-1],4),a=n?7:8;if(i.length>a)return!1;if("::"===t)return!0;"::"===t.substr(0,2)?(i.shift(),i.shift(),o=!0):"::"===t.substr(t.length-2)&&(i.pop(),i.pop(),o=!0);for(var s=0;s0&&s=1:i.length===a}return!1}function s(e){return"[object RegExp]"===Object.prototype.toString.call(e)}function u(e,t){for(var r=0;r=r.min,n=!r.hasOwnProperty("max")||t<=r.max,a=!r.hasOwnProperty("lt")||tr.gt;return i.test(t)&&o&&n&&a&&l}function c(t){return e(t),Q.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 i=t.replace(/[\s-]+/g,""),o=0,n=void 0;if("10"===r){if(!ae.test(i))return!1;for(n=0;n<9;n++)o+=(n+1)*i.charAt(n);if("X"===i.charAt(9)?o+=100:o+=10*i.charAt(9),o%11==0)return!!i}else if("13"===r){if(!le.test(i))return!1;for(n=0;n<12;n++)o+=se[n%2]*i.charAt(n);if(i.charAt(12)-(10-o%10)%10==0)return!!i}return!1}function p(t,r){e(t);var i=r?new RegExp("^["+r+"]+","g"):/^\s+/g;return t.replace(i,"")}function g(t,r){e(t);for(var i=r?new RegExp("["+r+"]"):/\s/,o=t.length-1;o>=0&&i.test(t[o]);)o--;return o$/i,A=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i,x=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i,S=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i,w=/^([\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})$/,Z=/^[0-9A-F]{1,4}$/i,y={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},b=/^\[([^\]]+)\](?::([0-9]+))?$/,R=/^([0-9a-fA-F][0-9a-fA-F]:){5}([0-9a-fA-F][0-9a-fA-F])$/,C={"en-US":/^[A-Z]+$/i,"cs-CZ":/^[A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]+$/i,"da-DK":/^[A-ZÆØÅ]+$/i,"de-DE":/^[A-ZÄÖÜß]+$/i,"el-GR":/^[Α-ω]+$/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,"sk-SK":/^[A-ZÁČĎÉÍŇÓŠŤÚÝŽĹŔĽÄÔ]+$/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:/^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/},D={"en-US":/^[0-9A-Z]+$/i,"cs-CZ":/^[0-9A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]+$/i,"da-DK":/^[0-9A-ZÆØÅ]+$/i,"de-DE":/^[0-9A-ZÄÖÜß]+$/i,"el-GR":/^[0-9Α-ω]+$/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,"sk-SK":/^[0-9A-ZÁČĎÉÍŇÓŠŤÚÝŽĹŔĽÄÔ]+$/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={"en-US":".",ar:"٫"},O=["AU","GB","HK","IN","NZ","ZA","ZM"],k=0;k=0},matches:function(t,r,i){return e(t),"[object RegExp]"!==Object.prototype.toString.call(r)&&(r=new RegExp(r,i)),r.test(t)},isEmail:function(t,r){if(e(t),(r=o(r,v)).require_display_name||r.allow_display_name){var i=t.match(F);if(i)t=i[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?w.test(u):x.test(u);for(var c=r.allow_utf8_local_part?S:A,f=u.split("."),p=0;p=2083||/[\s<>]/.test(t))return!1;if(0===t.indexOf("mailto:"))return!1;r=o(r,y);var i=void 0,n=void 0,s=void 0,d=void 0,c=void 0,f=void 0,p=void 0,g=void 0;if(p=t.split("#"),t=p.shift(),p=t.split("?"),t=p.shift(),(p=t.split("://")).length>1){if(i=p.shift(),r.require_valid_protocol&&-1===r.protocols.indexOf(i))return!1}else{if(r.require_protocol)return!1;r.allow_protocol_relative_urls&&"//"===t.substr(0,2)&&(p[0]=t.substr(2))}if(""===(t=p.join("://")))return!1;if(p=t.split("/"),""===(t=p.shift())&&!r.require_host)return!0;if((p=t.split("@")).length>1&&(n=p.shift()).indexOf(":")>=0&&n.split(":").length>2)return!1;f=null,g=null;var m=(d=p.join("@")).match(b);return m?(s="",g=m[1],f=m[2]||null):(s=(p=d.split(":")).shift(),p.length&&(f=p.join(":"))),!(null!==f&&(c=parseInt(f,10),!/^[0-9]+$/.test(f)||c<=0||c>65535)||!(l(s)||a(s,r)||g&&l(g,6))||(s=s||g,r.host_whitelist&&!u(s,r.host_whitelist)||r.host_blacklist&&u(s,r.host_blacklist)))},isMACAddress:function(t){return e(t),R.test(t)},isIP:l,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 C)return C[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 D)return D[r].test(t);throw new Error("Invalid locale '"+r+"'")},isNumeric:function(t){return e(t),G.test(t)},isPort:function(e){return d(e,{min:0,max:65535})},isLowercase:function(t){return e(t),t===t.toLowerCase()},isUppercase:function(t){return e(t),t===t.toUpperCase()},isAscii:function(t){return e(t),H.test(t)},isFullWidth:function(t){return e(t),j.test(t)},isHalfWidth:function(t){return e(t),q.test(t)},isVariableWidth:function(t){return e(t),j.test(t)&&q.test(t)},isMultibyte:function(t){return e(t),W.test(t)},isSurrogatePair:function(t){return e(t),J.test(t)},isInt:d,isFloat:function(t,r){e(t),r=r||{};var i=new RegExp("^(?:[-+])?(?:[0-9]+)?(?:\\"+(r.locale?I[r.locale]:".")+"[0-9]*)?(?:[eE][\\+\\-]?(?:[0-9]+))?$");return""!==t&&"."!==t&&"-"!==t&&"+"!==t&&i.test(t)&&(!r.hasOwnProperty("min")||t>=r.min)&&(!r.hasOwnProperty("max")||t<=r.max)&&(!r.hasOwnProperty("lt")||tr.gt)},isDecimal:function(t,r){if(e(t),(r=o(r,V)).locale in I)return!Y.includes(t.replace(/ /g,""))&&function(e){return new RegExp("^[-+]?([0-9]+)?(\\"+I[e.locale]+"[0-9]{"+e.decimal_digits+"})"+(e.force_decimal?"":"?")+"$")}(r).test(t);throw new Error("Invalid locale '"+r.locale+"'")},isHexadecimal:c,isDivisibleBy:function(t,i){return e(t),r(t)%parseInt(i,10)==0},isHexColor:function(t){return e(t),X.test(t)},isISRC:function(t){return e(t),ee.test(t)},isMD5:function(t){return e(t),te.test(t)},isHash:function(t,r){return e(t),new RegExp("^[a-f0-9]{"+re[r]+"}$").test(t)},isJSON:function(t){e(t);try{var r=JSON.parse(t);return!!r&&"object"===(void 0===r?"undefined":_(r))}catch(e){}return!1},isEmpty:function(t){return e(t),0===t.length},isLength:function(t,r){e(t);var i=void 0,o=void 0;"object"===(void 0===r?"undefined":_(r))?(i=r.min||0,o=r.max):(i=arguments[1],o=arguments[2]);var n=t.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g)||[],a=t.length-n.length;return a>=i&&(void 0===o||a<=o)},isByteLength:n,isUUID:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"all";e(t);var i=ie[r];return i&&i.test(t)},isMongoId:function(t){return e(t),c(t)&&24===t.length},isAfter:function(r){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:String(new Date);e(r);var o=t(i),n=t(r);return!!(n&&o&&n>o)},isBefore:function(r){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:String(new Date);e(r);var o=t(i),n=t(r);return!!(n&&o&&n=0}return"object"===(void 0===r?"undefined":_(r))?r.hasOwnProperty(t):!(!r||"function"!=typeof r.indexOf)&&r.indexOf(t)>=0},isCreditCard:function(t){e(t);var r=t.replace(/[- ]+/g,"");if(!oe.test(r))return!1;for(var i=0,o=void 0,n=void 0,a=void 0,l=r.length-1;l>=0;l--)o=r.substring(l,l+1),n=parseInt(o,10),i+=a&&(n*=2)>=10?n%10+1:n,a=!a;return!(i%10!=0||!r)},isISIN:function(t){if(e(t),!ne.test(t))return!1;for(var r=t.replace(/[A-Z]/g,function(e){return parseInt(e,36)}),i=0,o=void 0,n=void 0,a=!0,l=r.length-2;l>=0;l--)o=r.substring(l,l+1),n=parseInt(o,10),i+=a&&(n*=2)>=10?n+1:n,a=!a;return parseInt(t.substr(t.length-1),10)===(1e4-i)%10},isISBN:f,isISSN:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e(t);var i=ue;if(i=r.require_hyphen?i.replace("?",""):i,!(i=r.case_sensitive?new RegExp(i):new RegExp(i,"i")).test(t))return!1;var o=t.replace("-",""),n=8,a=0,l=!0,s=!1,u=void 0;try{for(var d,c=o[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 de)return de[r].test(t);if("any"===r){for(var i in de)if(de.hasOwnProperty(i)&&de[i].test(t))return!0;return!1}throw new Error("Invalid locale '"+r+"'")},isPostalCode:function(t,r){if(e(t),r in we)return we[r].test(t);if("any"===r){for(var i in we)if(we.hasOwnProperty(i)&&we[i].test(t))return!0;return!1}throw new Error("Invalid locale '"+r+"'")},isCurrency:function(t,r){return e(t),r=o(r,ce),function(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?"":"?"),i="("+["0","[1-9]\\d*","[1-9]\\d{0,2}(\\"+e.thousands_separator+"\\d{3})*"].join("|")+")?",o="(\\"+e.decimal_separator+"("+t+"))"+(e.require_decimal?"":"?"),n=i+(e.allow_decimal||e.require_decimal?o:"");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+"$")}(r).test(t)},isISO8601:function(t){return e(t),fe.test(t)},isISO31661Alpha2:function(t){return e(t),pe.includes(t.toUpperCase())},isBase64:function(t){e(t);var r=t.length;if(!r||r%4!=0||ge.test(t))return!1;var i=t.indexOf("=");return-1===i||i===r-1||i===r-2&&"="===t[r-1]},isDataURI:function(t){return e(t),me.test(t)},isMimeType:function(t){return e(t),he.test(t)||_e.test(t)||$e.test(t)},isLatLong:function(t){if(e(t),!t.includes(","))return!1;var r=t.split(",");return ve.test(r[0])&&Fe.test(r[1])},ltrim:p,rtrim:g,trim:function(e,t){return g(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,"`")},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 i=t.length-1;i>=0;i--)if(-1===r.indexOf(t[i]))return!1;return!0},normalizeEmail:function(e,t){t=o(t,Ee);var r=e.split("@"),i=r.pop(),n=[r.join("@"),i];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(~Ze.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(~ye.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(~be.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:i}});