Skip to content

Commit

Permalink
13.1.17 (#1440)
Browse files Browse the repository at this point in the history
ready for npm release
  • Loading branch information
profnandaa committed Sep 18, 2020
1 parent d5bbcf5 commit f492d89
Show file tree
Hide file tree
Showing 23 changed files with 148 additions and 52 deletions.
31 changes: 30 additions & 1 deletion CHANGELOG.md
@@ -1,7 +1,36 @@
#### 13.1.17

- **New features**:
- None
- **Fixes and chores**:
- [#1425](https://github.com/validatorjs/validator.js/pull/1425) fix validation for _userinfo_ part for `isURL` @heanzyzabala
- [#1419](https://github.com/validatorjs/validator.js/pull/1419) fix `isBase32` and `isBase64` to validate empty strings properly @AberDerBart
- [#1408](https://github.com/validatorjs/validator.js/pull/1408) tests for `isTaxId` @dspinellis
- [#1397](https://github.com/validatorjs/validator.js/pull/1397) added `validate_length` option for `isURL` @tomgrossman
- [#1383](https://github.com/validatorjs/validator.js/pull/1383) [#1428](https://github.com/validatorjs/validator.js/pull/1428) doc typos @0xflotus @timgates42
- [#1376](https://github.com/validatorjs/validator.js/pull/1376) add missing tests and switch to Coverall @tux-tn
- [#1373](https://github.com/validatorjs/validator.js/pull/1373) improve code coverage @ezkemboi
- [#1357](https://github.com/validatorjs/validator.js/pull/1357) add Node v6 on build pipeline @profnandaa

- **New and Improved locales**:
- [#1439](https://github.com/validatorjs/validator.js/pull/1439) @saidfagan
- [#1420](https://github.com/validatorjs/validator.js/pull/1420) @icyice0217
- [#1411](https://github.com/validatorjs/validator.js/pull/1411) @stinkymonkeyph
- [#1394](https://github.com/validatorjs/validator.js/pull/1394) @heanzyzabala
- [#1391](https://github.com/validatorjs/validator.js/pull/1391) @heanzyzabala
- [#1388](https://github.com/validatorjs/validator.js/pull/1388) @stinkymonkeyph
- [#1384](https://github.com/validatorjs/validator.js/pull/1384) @lorenzodb1
- [#1371](https://github.com/validatorjs/validator.js/pull/1371) @rubiin
- [#1370](https://github.com/validatorjs/validator.js/pull/1370) @rubiin
- [#1367](https://github.com/validatorjs/validator.js/pull/1367) @rubiin
- [#1356](https://github.com/validatorjs/validator.js/pull/1356) @MladenZeljic
- [#1303](https://github.com/validatorjs/validator.js/pull/1301) @heathcliff-hu


#### 13.1.1

- Hotfix for a regex incompatibility in some browsers
([#1355](https://github.com/chriso/validator.js/pull/1355))
([#1355](https://github.com/chriso/validator.js/pull/1355)

#### 13.1.0

Expand Down
2 changes: 1 addition & 1 deletion es/index.js
Expand Up @@ -86,7 +86,7 @@ import blacklist from './lib/blacklist';
import isWhitelisted from './lib/isWhitelisted';
import normalizeEmail from './lib/normalizeEmail';
import isSlug from './lib/isSlug';
var version = '13.1.1';
var version = '13.1.17';
var validator = {
version: version,
toDate: toDate,
Expand Down
24 changes: 17 additions & 7 deletions es/lib/alpha.js
Expand Up @@ -26,7 +26,7 @@ export var alpha = {
'ku-IQ': /^[ئابپتجچحخدرڕزژسشعغفڤقکگلڵمنوۆھەیێيطؤثآإأكضصةظذ]+$/i,
ar: /^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/,
he: /^[א-ת]+$/,
'fa-IR': /^['آابپتثجچهخدذرزژسشصضطظعغفقکگلمنوهی']+$/i
fa: /^['آاءأؤئبپتثجچحخدذرزژسشصضطظعغفقکگلمنوهةی']+$/i
};
export var alphanumeric = {
'en-US': /^[0-9A-Z]+$/i,
Expand Down Expand Up @@ -56,11 +56,12 @@ export var alphanumeric = {
'vi-VN': /^[0-9A-ZÀÁẠẢÃÂẦẤẬẨẪĂẰẮẶẲẴĐÈÉẸẺẼÊỀẾỆỂỄÌÍỊỈĨÒÓỌỎÕÔỒỐỘỔỖƠỜỚỢỞỠÙÚỤỦŨƯỪỨỰỬỮỲÝỴỶỸ]+$/i,
ar: /^[٠١٢٣٤٥٦٧٨٩0-9ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/,
he: /^[0-9א-ת]+$/,
'fa-IR': /^['0-9آابپتثجچهخدذرزژسشصضطظعغفقکگلمنوهی۱۲۳۴۵۶۷۸۹۰']+$/i
fa: /^['0-9آاءأؤئبپتثجچحخدذرزژسشصضطظعغفقکگلمنوهةی۱۲۳۴۵۶۷۸۹۰']+$/i
};
export var decimal = {
'en-US': '.',
ar: '٫'
ar: '٫',
fa: '٫'
};
export var englishLocales = ['AU', 'GB', 'HK', 'IN', 'NZ', 'ZA', 'ZM'];

Expand All @@ -79,18 +80,27 @@ for (var _locale, _i = 0; _i < arabicLocales.length; _i++) {
alpha[_locale] = alpha.ar;
alphanumeric[_locale] = alphanumeric.ar;
decimal[_locale] = decimal.ar;
}

export var farsiLocales = ['IR', 'AF'];

for (var _locale2, _i2 = 0; _i2 < farsiLocales.length; _i2++) {
_locale2 = "fa-".concat(farsiLocales[_i2]);
alpha[_locale2] = alpha.fa;
alphanumeric[_locale2] = alphanumeric.fa;
decimal[_locale2] = decimal.fa;
} // Source: https://en.wikipedia.org/wiki/Decimal_mark


export var dotDecimal = ['ar-EG', 'ar-LB', 'ar-LY'];
export var commaDecimal = ['bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en-ZM', 'es-ES', 'fr-FR', 'it-IT', 'ku-IQ', 'hu-HU', 'nb-NO', 'nn-NO', 'nl-NL', 'pl-PL', 'pt-PT', 'ru-RU', 'sl-SI', 'sr-RS@latin', 'sr-RS', 'sv-SE', 'tr-TR', 'uk-UA', 'vi-VN'];

for (var _i2 = 0; _i2 < dotDecimal.length; _i2++) {
decimal[dotDecimal[_i2]] = decimal['en-US'];
for (var _i3 = 0; _i3 < dotDecimal.length; _i3++) {
decimal[dotDecimal[_i3]] = decimal['en-US'];
}

for (var _i3 = 0; _i3 < commaDecimal.length; _i3++) {
decimal[commaDecimal[_i3]] = ',';
for (var _i4 = 0; _i4 < commaDecimal.length; _i4++) {
decimal[commaDecimal[_i4]] = ',';
}

alpha['pt-BR'] = alpha['pt-PT'];
Expand Down
2 changes: 1 addition & 1 deletion es/lib/isBase32.js
Expand Up @@ -4,7 +4,7 @@ export default function isBase32(str) {
assertString(str);
var len = str.length;

if (len > 0 && len % 8 === 0 && base32.test(str)) {
if (len % 8 === 0 && base32.test(str)) {
return true;
}

Expand Down
4 changes: 2 additions & 2 deletions es/lib/isBase64.js
@@ -1,7 +1,7 @@
import assertString from './util/assertString';
import merge from './util/merge';
var notBase64 = /[^A-Z0-9+\/=]/i;
var urlSafeBase64 = /^[A-Z0-9_\-]+$/i;
var urlSafeBase64 = /^[A-Z0-9_\-]*$/i;
var defaultBase64Options = {
urlSafe: false
};
Expand All @@ -14,7 +14,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;
}

Expand Down
2 changes: 2 additions & 0 deletions es/lib/isIBAN.js
Expand Up @@ -25,6 +25,7 @@ var ibanRegexThroughCountryCode = {
DK: /^(DK[0-9]{2})\d{14}$/,
DO: /^(DO[0-9]{2})[A-Z]{4}\d{20}$/,
EE: /^(EE[0-9]{2})\d{16}$/,
EG: /^(EG[0-9]{2})\d{25}$/,
ES: /^(ES[0-9]{2})\d{20}$/,
FI: /^(FI[0-9]{2})\d{14}$/,
FO: /^(FO[0-9]{2})\d{14}$/,
Expand Down Expand Up @@ -74,6 +75,7 @@ var ibanRegexThroughCountryCode = {
SI: /^(SI[0-9]{2})\d{15}$/,
SK: /^(SK[0-9]{2})\d{20}$/,
SM: /^(SM[0-9]{2})[A-Z]{1}\d{10}[A-Z0-9]{12}$/,
SV: /^(SV[0-9]{2})[A-Z0-9]{4}\d{20}$/,
TL: /^(TL[0-9]{2})\d{19}$/,
TN: /^(TN[0-9]{2})\d{20}$/,
TR: /^(TR[0-9]{2})\d{5}[A-Z0-9]{17}$/,
Expand Down
4 changes: 3 additions & 1 deletion es/lib/isMobilePhone.js
Expand Up @@ -14,13 +14,14 @@ var 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}$/,
'bn-BD': /^(\+?880|0)1[13456789][0-9]{8}$/,
'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)?0?1(5[0-25-9]\d|6([23]|0\d?)|7([0-57-9]|6\d))\d{7}$/,
'de-DE': /^(\+49)?0?[1|3]([0|5][0-45-9]\d|6([23]|0\d?)|7([0-57-9]|6\d))\d{7}$/,
'de-AT': /^(\+43|0)\d{1,4}\d{3,12}$/,
'de-CH': /^(\+41|0)(7[5-9])\d{1,7}$/,
'el-GR': /^(\+?30|0)?(69\d{8})$/,
Expand Down Expand Up @@ -94,6 +95,7 @@ var phones = {
'th-TH': /^(\+66|66|0)\d{9}$/,
'tr-TR': /^(\+?90|0)?5\d{9}$/,
'uk-UA': /^(\+?38|8)?0\d{9}$/,
'uz-UZ': /^(\+?998)?(6[125-79]|7[1-69]|88|9\d)\d{7}$/,
'vi-VN': /^(\+?84|0)((3([2-9]))|(5([2689]))|(7([0|6-9]))|(8([1-6|89]))|(9([0-9])))([0-9]{7})$/,
'zh-CN': /^((\+|00)86)?1([3568][0-9]|4[579]|6[67]|7[01235678]|9[012356789])[0-9]{8}$/,
'zh-TW': /^(\+?886\-?|0)?9\d{8}$/
Expand Down
1 change: 1 addition & 0 deletions es/lib/isPostalCode.js
Expand Up @@ -8,6 +8,7 @@ var patterns = {
AD: /^AD\d{3}$/,
AT: fourDigit,
AU: fourDigit,
AZ: /^AZ\d{4}$/,
BE: fourDigit,
BG: fourDigit,
BR: /^\d{5}-\d{3}$/,
Expand Down
13 changes: 10 additions & 3 deletions es/lib/isURL.js
Expand Up @@ -10,6 +10,7 @@ require_valid_protocol - isURL will check if the URL's protocol is present in th
protocols - valid protocols can be modified with this option
require_host - if set as false isURL will not check if host is present in the URL
allow_protocol_relative_urls - if set as true protocol relative URLs will be allowed
validate_length - if set as false isURL will skip string length validation (IE maximum is 2083)
*/

Expand All @@ -21,7 +22,8 @@ var default_url_options = {
require_valid_protocol: true,
allow_underscores: false,
allow_trailing_dot: false,
allow_protocol_relative_urls: false
allow_protocol_relative_urls: false,
validate_length: true
};
var wrapped_ipv6 = /^\[([^\]]+)\](?::([0-9]+))?$/;

Expand All @@ -44,7 +46,7 @@ function checkHost(host, matches) {
export default function isURL(url, options) {
assertString(url);

if (!url || url.length >= 2083 || /[\s<>]/.test(url)) {
if (!url || /[\s<>]/.test(url)) {
return false;
}

Expand All @@ -53,6 +55,11 @@ export default function isURL(url, options) {
}

options = merge(options, default_url_options);

if (options.validate_length && url.length >= 2083) {
return false;
}

var protocol, auth, host, hostname, port, port_str, split, ipv6;
split = url.split('#');
url = split.shift();
Expand Down Expand Up @@ -98,7 +105,7 @@ export default function isURL(url, options) {

auth = split.shift();

if (auth.indexOf(':') >= 0 && auth.split(':').length > 2) {
if (auth.indexOf(':') === -1 || auth.indexOf(':') >= 0 && auth.split(':').length > 2) {
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion es/lib/normalizeEmail.js
Expand Up @@ -135,4 +135,4 @@ export default function normalizeEmail(email, options) {
}

return parts.join('@');
}
}
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -189,7 +189,7 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var version = '13.1.1';
var version = '13.1.17';
var validator = {
version: version,
toDate: _toDate.default,
Expand Down
27 changes: 19 additions & 8 deletions lib/alpha.js
Expand Up @@ -3,7 +3,7 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.commaDecimal = exports.dotDecimal = exports.arabicLocales = exports.englishLocales = exports.decimal = exports.alphanumeric = exports.alpha = void 0;
exports.commaDecimal = exports.dotDecimal = exports.farsiLocales = exports.arabicLocales = exports.englishLocales = exports.decimal = exports.alphanumeric = exports.alpha = void 0;
var alpha = {
'en-US': /^[A-Z]+$/i,
'bg-BG': /^[А-Я]+$/i,
Expand Down Expand Up @@ -32,7 +32,7 @@ var alpha = {
'ku-IQ': /^[ئابپتجچحخدرڕزژسشعغفڤقکگلڵمنوۆھەیێيطؤثآإأكضصةظذ]+$/i,
ar: /^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/,
he: /^[א-ת]+$/,
'fa-IR': /^['آابپتثجچهخدذرزژسشصضطظعغفقکگلمنوهی']+$/i
fa: /^['آاءأؤئبپتثجچحخدذرزژسشصضطظعغفقکگلمنوهةی']+$/i
};
exports.alpha = alpha;
var alphanumeric = {
Expand Down Expand Up @@ -63,12 +63,13 @@ var alphanumeric = {
'vi-VN': /^[0-9A-ZÀÁẠẢÃÂẦẤẬẨẪĂẰẮẶẲẴĐÈÉẸẺẼÊỀẾỆỂỄÌÍỊỈĨÒÓỌỎÕÔỒỐỘỔỖƠỜỚỢỞỠÙÚỤỦŨƯỪỨỰỬỮỲÝỴỶỸ]+$/i,
ar: /^[٠١٢٣٤٥٦٧٨٩0-9ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/,
he: /^[0-9א-ת]+$/,
'fa-IR': /^['0-9آابپتثجچهخدذرزژسشصضطظعغفقکگلمنوهی۱۲۳۴۵۶۷۸۹۰']+$/i
fa: /^['0-9آاءأؤئبپتثجچحخدذرزژسشصضطظعغفقکگلمنوهةی۱۲۳۴۵۶۷۸۹۰']+$/i
};
exports.alphanumeric = alphanumeric;
var decimal = {
'en-US': '.',
ar: '٫'
ar: '٫',
fa: '٫'
};
exports.decimal = decimal;
var englishLocales = ['AU', 'GB', 'HK', 'IN', 'NZ', 'ZA', 'ZM'];
Expand All @@ -90,6 +91,16 @@ for (var _locale, _i = 0; _i < arabicLocales.length; _i++) {
alpha[_locale] = alpha.ar;
alphanumeric[_locale] = alphanumeric.ar;
decimal[_locale] = decimal.ar;
}

var farsiLocales = ['IR', 'AF'];
exports.farsiLocales = farsiLocales;

for (var _locale2, _i2 = 0; _i2 < farsiLocales.length; _i2++) {
_locale2 = "fa-".concat(farsiLocales[_i2]);
alpha[_locale2] = alpha.fa;
alphanumeric[_locale2] = alphanumeric.fa;
decimal[_locale2] = decimal.fa;
} // Source: https://en.wikipedia.org/wiki/Decimal_mark


Expand All @@ -98,12 +109,12 @@ exports.dotDecimal = dotDecimal;
var commaDecimal = ['bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en-ZM', 'es-ES', 'fr-FR', 'it-IT', 'ku-IQ', 'hu-HU', 'nb-NO', 'nn-NO', 'nl-NL', 'pl-PL', 'pt-PT', 'ru-RU', 'sl-SI', 'sr-RS@latin', 'sr-RS', 'sv-SE', 'tr-TR', 'uk-UA', 'vi-VN'];
exports.commaDecimal = commaDecimal;

for (var _i2 = 0; _i2 < dotDecimal.length; _i2++) {
decimal[dotDecimal[_i2]] = decimal['en-US'];
for (var _i3 = 0; _i3 < dotDecimal.length; _i3++) {
decimal[dotDecimal[_i3]] = decimal['en-US'];
}

for (var _i3 = 0; _i3 < commaDecimal.length; _i3++) {
decimal[commaDecimal[_i3]] = ',';
for (var _i4 = 0; _i4 < commaDecimal.length; _i4++) {
decimal[commaDecimal[_i4]] = ',';
}

alpha['pt-BR'] = alpha['pt-PT'];
Expand Down
2 changes: 1 addition & 1 deletion lib/isBase32.js
Expand Up @@ -15,7 +15,7 @@ function isBase32(str) {
(0, _assertString.default)(str);
var len = str.length;

if (len > 0 && len % 8 === 0 && base32.test(str)) {
if (len % 8 === 0 && base32.test(str)) {
return true;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/isBase64.js
Expand Up @@ -12,7 +12,7 @@ var _merge = _interopRequireDefault(require("./util/merge"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var notBase64 = /[^A-Z0-9+\/=]/i;
var urlSafeBase64 = /^[A-Z0-9_\-]+$/i;
var urlSafeBase64 = /^[A-Z0-9_\-]*$/i;
var defaultBase64Options = {
urlSafe: false
};
Expand All @@ -26,7 +26,7 @@ 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;
}

Expand Down
2 changes: 2 additions & 0 deletions lib/isIBAN.js
Expand Up @@ -34,6 +34,7 @@ var ibanRegexThroughCountryCode = {
DK: /^(DK[0-9]{2})\d{14}$/,
DO: /^(DO[0-9]{2})[A-Z]{4}\d{20}$/,
EE: /^(EE[0-9]{2})\d{16}$/,
EG: /^(EG[0-9]{2})\d{25}$/,
ES: /^(ES[0-9]{2})\d{20}$/,
FI: /^(FI[0-9]{2})\d{14}$/,
FO: /^(FO[0-9]{2})\d{14}$/,
Expand Down Expand Up @@ -83,6 +84,7 @@ var ibanRegexThroughCountryCode = {
SI: /^(SI[0-9]{2})\d{15}$/,
SK: /^(SK[0-9]{2})\d{20}$/,
SM: /^(SM[0-9]{2})[A-Z]{1}\d{10}[A-Z0-9]{12}$/,
SV: /^(SV[0-9]{2})[A-Z0-9]{4}\d{20}$/,
TL: /^(TL[0-9]{2})\d{19}$/,
TN: /^(TN[0-9]{2})\d{20}$/,
TR: /^(TR[0-9]{2})\d{5}[A-Z0-9]{17}$/,
Expand Down
4 changes: 3 additions & 1 deletion lib/isMobilePhone.js
Expand Up @@ -24,13 +24,14 @@ var 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}$/,
'bn-BD': /^(\+?880|0)1[13456789][0-9]{8}$/,
'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)?0?1(5[0-25-9]\d|6([23]|0\d?)|7([0-57-9]|6\d))\d{7}$/,
'de-DE': /^(\+49)?0?[1|3]([0|5][0-45-9]\d|6([23]|0\d?)|7([0-57-9]|6\d))\d{7}$/,
'de-AT': /^(\+43|0)\d{1,4}\d{3,12}$/,
'de-CH': /^(\+41|0)(7[5-9])\d{1,7}$/,
'el-GR': /^(\+?30|0)?(69\d{8})$/,
Expand Down Expand Up @@ -104,6 +105,7 @@ var phones = {
'th-TH': /^(\+66|66|0)\d{9}$/,
'tr-TR': /^(\+?90|0)?5\d{9}$/,
'uk-UA': /^(\+?38|8)?0\d{9}$/,
'uz-UZ': /^(\+?998)?(6[125-79]|7[1-69]|88|9\d)\d{7}$/,
'vi-VN': /^(\+?84|0)((3([2-9]))|(5([2689]))|(7([0|6-9]))|(8([1-6|89]))|(9([0-9])))([0-9]{7})$/,
'zh-CN': /^((\+|00)86)?1([3568][0-9]|4[579]|6[67]|7[01235678]|9[012356789])[0-9]{8}$/,
'zh-TW': /^(\+?886\-?|0)?9\d{8}$/
Expand Down
1 change: 1 addition & 0 deletions lib/isPostalCode.js
Expand Up @@ -19,6 +19,7 @@ var patterns = {
AD: /^AD\d{3}$/,
AT: fourDigit,
AU: fourDigit,
AZ: /^AZ\d{4}$/,
BE: fourDigit,
BG: fourDigit,
BR: /^\d{5}-\d{3}$/,
Expand Down

0 comments on commit f492d89

Please sign in to comment.