diff --git a/README.md b/README.md
index 7a7c72f21..9c824b021 100644
--- a/README.md
+++ b/README.md
@@ -136,14 +136,14 @@ Validator | Description
**isMagnetURI(str)** | check if the string is a [magnet uri format](https://en.wikipedia.org/wiki/Magnet_URI_scheme).
**isMD5(str)** | check if the string is a MD5 hash.
Please note that you can also use the `isHash(str, 'md5')` function. Keep in mind that MD5 has some collision weaknesses compared to other algorithms (e.g., SHA).
**isMimeType(str)** | check if the string matches to a valid [MIME type](https://en.wikipedia.org/wiki/Media_type) format
-**isMobilePhone(str [, locale [, options]])** | check if the string is a mobile phone number,
(locale is either an array of locales (e.g `['sk-SK', 'sr-RS']`) OR one of `['am-Am', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', ar-JO', 'ar-KW', 'ar-SA', 'ar-SY', 'ar-TN', 'bs-BA', 'be-BY', 'bg-BG', 'bn-BD', 'cs-CZ', 'da-DK', 'de-DE', 'de-AT', 'de-CH', 'el-GR', 'en-AU', 'en-CA', 'en-GB', 'en-GG', 'en-GH', 'en-HK', 'en-MO', 'en-IE', 'en-IN', 'en-KE', 'en-MT', 'en-MU', 'en-NG', 'en-NZ', 'en-PK', 'en-PH', 'en-RW', 'en-SG', 'en-SL', 'en-UG', 'en-US', 'en-TZ', 'en-ZA', 'en-ZM', 'en-ZW' , 'es-CL', 'es-CO', 'es-CR', 'es-EC', 'es-ES', 'es-MX', 'es-PA', 'es-PY', 'es-UY', 'et-EE', 'fa-IR', 'fi-FI', 'fj-FJ', 'fo-FO', 'fr-BE', 'fr-FR', 'fr-GF', 'fr-GP', 'fr-MQ', 'fr-RE', 'he-IL', 'hu-HU', 'id-ID', 'it-IT', 'ja-JP', 'kk-KZ', 'kl-GL', 'ko-KR', 'lt-LT', 'ms-MY', 'nb-NO', 'ne-NP', 'nl-BE', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ro-RO', 'ru-RU', 'sl-SI', 'sk-SK', 'sr-RS', 'sv-SE', 'th-TH', 'tr-TR', 'uk-UA', 'uz-UZ', 'vi-VN', 'zh-CN', 'zh-HK', 'zh-MO', 'zh-TW']` OR defaults to 'any'. If 'any' or a falsey value is used, function will check if any of the locales match).
`options` is an optional object that can be supplied with the following keys: `strictMode`, if this is set to `true`, the mobile phone number must be supplied with the country code and therefore must start with `+`. Locale list is `validator.isMobilePhoneLocales`.
+**isMobilePhone(str [, locale [, options]])** | check if the string is a mobile phone number,
(locale is either an array of locales (e.g `['sk-SK', 'sr-RS']`) OR one of `['am-Am', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', ar-JO', 'ar-KW', 'ar-SA', 'ar-SY', 'ar-TN', 'az-AZ', 'bs-BA', 'be-BY', 'bg-BG', 'bn-BD', 'cs-CZ', 'da-DK', 'de-DE', 'de-AT', 'de-CH', 'el-GR', 'en-AU', 'en-CA', 'en-GB', 'en-GG', 'en-GH', 'en-HK', 'en-MO', 'en-IE', 'en-IN', 'en-KE', 'en-MT', 'en-MU', 'en-NG', 'en-NZ', 'en-PK', 'en-PH', 'en-RW', 'en-SG', 'en-SL', 'en-UG', 'en-US', 'en-TZ', 'en-ZA', 'en-ZM', 'en-ZW' , 'es-CL', 'es-CO', 'es-CR', 'es-EC', 'es-ES', 'es-MX', 'es-PA', 'es-PY', 'es-UY', 'et-EE', 'fa-IR', 'fi-FI', 'fj-FJ', 'fo-FO', 'fr-BE', 'fr-FR', 'fr-GF', 'fr-GP', 'fr-MQ', 'fr-RE', 'he-IL', 'hu-HU', 'id-ID', 'it-IT', 'ja-JP', 'kk-KZ', 'kl-GL', 'ko-KR', 'lt-LT', 'ms-MY', 'nb-NO', 'ne-NP', 'nl-BE', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ro-RO', 'ru-RU', 'sl-SI', 'sk-SK', 'sr-RS', 'sv-SE', 'th-TH', 'tr-TR', 'uk-UA', 'uz-UZ', 'vi-VN', 'zh-CN', 'zh-HK', 'zh-MO', 'zh-TW']` OR defaults to 'any'. If 'any' or a falsey value is used, function will check if any of the locales match).
`options` is an optional object that can be supplied with the following keys: `strictMode`, if this is set to `true`, the mobile phone number must be supplied with the country code and therefore must start with `+`. Locale list is `validator.isMobilePhoneLocales`.
**isMongoId(str)** | check if the string is a valid hex-encoded representation of a [MongoDB ObjectId][mongoid].
**isMultibyte(str)** | check if the string contains one or more multibyte chars.
**isNumeric(str [, options])** | check if the string contains only numbers.
`options` is an object which defaults to `{no_symbols: false}` it also has locale as an option. If `no_symbols` is true, the validator will reject numeric strings that feature a symbol (e.g. `+`, `-`, or `.`).
`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', 'sl-SI', 'sr-RS', 'sr-RS@latin', 'sv-SE', 'tr-TR', 'uk-UA']`.
**isOctal(str)** | check if the string is a valid octal number.
**isPassportNumber(str, countryCode)** | check if the string is a valid passport number.
(countryCode is one of `[ 'AM', 'AR', 'AT', 'AU', 'BE', 'BG', 'CA', 'CH', 'CN', 'CY', 'CZ', 'DE', 'DK', 'DZ', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HU', 'IE' 'IN', 'IS', 'IT', 'JP', 'KR', 'LT', 'LU', 'LV', 'MT', 'NL', 'PO', 'PT', 'RO', 'SE', 'SL', 'SK', 'TR', 'UA', 'US' ]`.
**isPort(str)** | check if the string is a valid port number.
-**isPostalCode(str, locale)** | check if the string is a postal code,
(locale is one of `[ 'AD', 'AT', 'AU', 'BE', 'BG', 'BR', 'CA', 'CH', 'CZ', 'DE', 'DK', 'DZ', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HU', 'ID', 'IE' 'IL', 'IN', 'IR', 'IS', 'IT', 'JP', 'KE', 'LI', 'LT', 'LU', 'LV', 'MT', 'MX', 'NL', 'NO', 'NP', 'NZ', 'PL', 'PR', 'PT', 'RO', 'RU', 'SA', 'SE', 'SI', 'TN', 'TW', 'UA', 'US', 'ZA', 'ZM' ]` OR 'any'. If 'any' is used, function will check if any of the locals match. Locale list is `validator.isPostalCodeLocales`.).
+**isPostalCode(str, locale)** | check if the string is a postal code,
(locale is one of `[ 'AD', 'AT', 'AU', 'AZ', 'BE', 'BG', 'BR', 'CA', 'CH', 'CZ', 'DE', 'DK', 'DZ', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HU', 'ID', 'IE' 'IL', 'IN', 'IR', 'IS', 'IT', 'JP', 'KE', 'LI', 'LT', 'LU', 'LV', 'MT', 'MX', 'NL', 'NO', 'NP', 'NZ', 'PL', 'PR', 'PT', 'RO', 'RU', 'SA', 'SE', 'SI', 'TN', 'TW', 'UA', 'US', 'ZA', 'ZM' ]` OR 'any'. If 'any' is used, function will check if any of the locals match. Locale list is `validator.isPostalCodeLocales`.).
**isRFC3339(str)** | check if the string is a valid [RFC 3339](https://tools.ietf.org/html/rfc3339) date.
**isRgbColor(str [, includePercentValues])** | check if the string is a rgb or rgba color.
`includePercentValues` defaults to `true`. If you don't want to allow to set `rgb` or `rgba` values with percents, like `rgb(5%,5%,5%)`, or `rgba(90%,90%,90%,.3)`, then set it to false.
**isSemVer(str)** | check if the string is a Semantic Versioning Specification (SemVer).
diff --git a/es/lib/normalizeEmail.js b/es/lib/normalizeEmail.js
index 301df8311..47d52b9dc 100644
--- a/es/lib/normalizeEmail.js
+++ b/es/lib/normalizeEmail.js
@@ -128,11 +128,11 @@ export default function normalizeEmail(email, options) {
parts[0] = parts[0].toLowerCase();
}
- parts[1] = 'yandex.ru'; // all yandex domains are equal, 1st preffered
+ parts[1] = 'yandex.ru'; // all yandex domains are equal, 1st preferred
} else if (options.all_lowercase) {
// Any other address
parts[0] = parts[0].toLowerCase();
}
return parts.join('@');
-}
\ No newline at end of file
+}
diff --git a/lib/normalizeEmail.js b/lib/normalizeEmail.js
index dcab4b97a..bc3fcff57 100644
--- a/lib/normalizeEmail.js
+++ b/lib/normalizeEmail.js
@@ -138,7 +138,7 @@ function normalizeEmail(email, options) {
parts[0] = parts[0].toLowerCase();
}
- parts[1] = 'yandex.ru'; // all yandex domains are equal, 1st preffered
+ parts[1] = 'yandex.ru'; // all yandex domains are equal, 1st preferred
} else if (options.all_lowercase) {
// Any other address
parts[0] = parts[0].toLowerCase();
@@ -148,4 +148,4 @@ function normalizeEmail(email, options) {
}
module.exports = exports.default;
-module.exports.default = exports.default;
\ No newline at end of file
+module.exports.default = exports.default;
diff --git a/src/lib/isBase32.js b/src/lib/isBase32.js
index 1988ea901..b2e9c8a28 100644
--- a/src/lib/isBase32.js
+++ b/src/lib/isBase32.js
@@ -5,7 +5,7 @@ const base32 = /^[A-Z2-7]+=*$/;
export default function isBase32(str) {
assertString(str);
const len = str.length;
- if (len > 0 && len % 8 === 0 && base32.test(str)) {
+ if (len % 8 === 0 && base32.test(str)) {
return true;
}
return false;
diff --git a/src/lib/isBase64.js b/src/lib/isBase64.js
index 6bfe0310b..02dead0f4 100644
--- a/src/lib/isBase64.js
+++ b/src/lib/isBase64.js
@@ -2,7 +2,7 @@ import assertString from './util/assertString';
import merge from './util/merge';
const notBase64 = /[^A-Z0-9+\/=]/i;
-const urlSafeBase64 = /^[A-Z0-9_\-]+$/i;
+const urlSafeBase64 = /^[A-Z0-9_\-]*$/i;
const defaultBase64Options = {
urlSafe: false,
@@ -17,7 +17,7 @@ export default function isBase64(str, options) {
return urlSafeBase64.test(str);
}
- if (!len || len % 4 !== 0 || notBase64.test(str)) {
+ if (len % 4 !== 0 || notBase64.test(str)) {
return false;
}
diff --git a/src/lib/isMobilePhone.js b/src/lib/isMobilePhone.js
index 987a127cf..d9a9b5900 100644
--- a/src/lib/isMobilePhone.js
+++ b/src/lib/isMobilePhone.js
@@ -14,6 +14,7 @@ const phones = {
'ar-SA': /^(!?(\+?966)|0)?5\d{8}$/,
'ar-SY': /^(!?(\+?963)|0)?9\d{8}$/,
'ar-TN': /^(\+?216)?[2459]\d{7}$/,
+ 'az-AZ': /^(\+994|0)(5[015]|7[07]|99)\d{7}$/,
'bs-BA': /^((((\+|00)3876)|06))((([0-3]|[5-6])\d{6})|(4\d{7}))$/,
'be-BY': /^(\+?375)?(24|25|29|33|44)\d{7}$/,
'bg-BG': /^(\+?359|0)?8[789]\d{7}$/,
diff --git a/src/lib/isPostalCode.js b/src/lib/isPostalCode.js
index f9d81f62d..0435dfb14 100644
--- a/src/lib/isPostalCode.js
+++ b/src/lib/isPostalCode.js
@@ -10,6 +10,7 @@ const patterns = {
AD: /^AD\d{3}$/,
AT: fourDigit,
AU: fourDigit,
+ AZ: /^AZ\d{4}$/,
BE: fourDigit,
BG: fourDigit,
BR: /^\d{5}-\d{3}$/,
diff --git a/src/lib/normalizeEmail.js b/src/lib/normalizeEmail.js
index 2e919831e..a163bed88 100644
--- a/src/lib/normalizeEmail.js
+++ b/src/lib/normalizeEmail.js
@@ -232,7 +232,7 @@ export default function normalizeEmail(email, options) {
if (options.all_lowercase || options.yandex_lowercase) {
parts[0] = parts[0].toLowerCase();
}
- parts[1] = 'yandex.ru'; // all yandex domains are equal, 1st preffered
+ parts[1] = 'yandex.ru'; // all yandex domains are equal, 1st preferred
} else if (options.all_lowercase) {
// Any other address
parts[0] = parts[0].toLowerCase();
diff --git a/test/validators.js b/test/validators.js
index 1587fc81f..7c5a9c0f0 100644
--- a/test/validators.js
+++ b/test/validators.js
@@ -4735,6 +4735,7 @@ describe('Validators', () => {
test({
validator: 'isBase64',
valid: [
+ '',
'Zg==',
'Zm8=',
'Zm9v',
@@ -4754,7 +4755,6 @@ describe('Validators', () => {
],
invalid: [
'12345',
- '',
'Vml2YW11cyBmZXJtZtesting123',
'Zg=',
'Z===',
@@ -4768,6 +4768,7 @@ describe('Validators', () => {
validator: 'isBase64',
args: [{ urlSafe: true }],
valid: [
+ '',
'bGFkaWVzIGFuZCBnZW50bGVtZW4sIHdlIGFyZSBmbG9hdGluZyBpbiBzcGFjZQ',
'1234',
'bXVtLW5ldmVyLXByb3Vk',
@@ -4778,7 +4779,6 @@ describe('Validators', () => {
' AA',
'\tAA',
'\rAA',
- '',
'\nAA',
'This+isa/bad+base64Url==',
'0K3RgtC+INC30LDQutC+0LTQuNGA0L7QstCw0L3QvdCw0Y8g0YHRgtGA0L7QutCw',
@@ -6801,6 +6801,27 @@ describe('Validators', () => {
'0797878674',
],
},
+ {
+ locale: 'az-AZ',
+ valid: [
+ '+994707007070',
+ '0707007070',
+ '+994502111111',
+ '0505436743',
+ '0554328772',
+ '0993301022',
+ '+994776007139',
+ ],
+ invalid: [
+ 'wrong-number',
+ '',
+ '994707007070',
+ '++9945005050',
+ '556007070',
+ '1234566',
+ '+994778008080a',
+ ],
+ },
];
let allValid = [];
@@ -8572,6 +8593,22 @@ describe('Validators', () => {
'00987',
],
},
+ {
+ locale: 'AZ',
+ valid: [
+ 'AZ0100',
+ 'AZ0121',
+ 'AZ3500',
+ ],
+ invalid: [
+ '',
+ ' AZ0100',
+ 'AZ100',
+ 'AZ34340',
+ 'EN2020',
+ 'AY3030',
+ ],
+ },
];
let allValid = [];
@@ -8742,6 +8779,7 @@ describe('Validators', () => {
validator: 'isBase64',
args: [{ urlSafe: true }],
valid: [
+ '',
'bGFkaWVzIGFuZCBnZW50bGVtZW4sIHdlIGFyZSBmbG9hdGluZyBpbiBzcGFjZQ',
'1234',
'bXVtLW5ldmVyLXByb3Vk',
@@ -8754,7 +8792,6 @@ describe('Validators', () => {
'\rAA',
'\nAA',
'123=',
- '',
'This+isa/bad+base64Url==',
'0K3RgtC+INC30LDQutC+0LTQuNGA0L7QstCw0L3QvdCw0Y8g0YHRgtGA0L7QutCw',
],
diff --git a/validator.js b/validator.js
index 753338421..e5e9e8615 100644
--- a/validator.js
+++ b/validator.js
@@ -2954,7 +2954,7 @@ function normalizeEmail(email, options) {
parts[0] = parts[0].toLowerCase();
}
- parts[1] = 'yandex.ru'; // all yandex domains are equal, 1st preffered
+ parts[1] = 'yandex.ru'; // all yandex domains are equal, 1st preferred
} else if (options.all_lowercase) {
// Any other address
parts[0] = parts[0].toLowerCase();