Skip to content

Commit f37ba9e

Browse files
authored
Merge branch 'master' into angola
2 parents c07f275 + 243f6c5 commit f37ba9e

7 files changed

Lines changed: 228 additions & 123 deletions

File tree

CHANGELOG.md

Lines changed: 160 additions & 116 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ Validator | Description
145145
**isLocale(str)** | check if the string is a locale.
146146
**isLowercase(str)** | check if the string is lowercase.
147147
**isLuhnNumber(str)** | check if the string passes the [Luhn algorithm check](https://en.wikipedia.org/wiki/Luhn_algorithm).
148-
**isMACAddress(str [, options])** | check if the string is a MAC address.<br/><br/>`options` is an object which defaults to `{ no_separators: false }`. If `no_separators` is true, the validator will allow MAC addresses without separators. Also, it allows the use of hyphens, spaces or dots e.g. '01 02 03 04 05 ab', '01-02-03-04-05-ab' or '0102.0304.05ab'. The options also allow a `eui` property to specify if it needs to be validated against EUI-48 or EUI-64. The accepted values of `eui` are: 48, 64.
148+
**isMACAddress(str [, options])** | check if the string is a MAC address.<br/><br/>`options` is an object which defaults to `{ no_separators: false }`. It allows the use of hyphens, spaces or dots e.g. '01 02 03 04 05 ab', '01-02-03-04-05-ab' or '0102.0304.05ab'. If `no_separators` is true, the validator will then only check MAC addresses without separators. The options also allow a `eui` property to specify if it needs to be validated against EUI-48 or EUI-64. The accepted values of `eui` are: 48, 64.
149149
**isMagnetURI(str)** | check if the string is a [Magnet URI format][Magnet URI Format].
150150
**isMailtoURI(str, [, options])** | check if the string is a [Mailto URI format][Mailto URI Format].<br/><br/>`options` is an object of validating emails inside the URI (check `isEmail`s options for details).
151151
**isMD5(str)** | check if the string is a MD5 hash.<br/><br/>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).
@@ -157,7 +157,7 @@ Validator | Description
157157
**isOctal(str)** | check if the string is a valid octal number.
158158
**isPassportNumber(str, countryCode)** | check if the string is a valid passport number.<br/><br/>`countryCode` is one of `['AM', 'AR', 'AO', 'AT', 'AU', 'AZ', 'BE', 'BG', 'BY', 'BR', 'CA', 'CH', 'CN', 'CY', 'CZ', 'DE', 'DK', 'DZ', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HU', 'IE', 'IN', 'IR', 'ID', 'IS', 'IT', 'JM', 'JP', 'KR', 'KZ', 'LI', 'LT', 'LU', 'LV', 'LY', 'MT', 'MX', 'MY', 'MZ', 'NL', 'NZ', 'PH', 'PK', 'PL', 'PT', 'RO', 'RU', 'SE', 'SL', 'SK', 'TH', 'TR', 'UA', 'US', 'ZA']`. Locale list is `validator.passportNumberLocales`.
159159
**isPort(str)** | check if the string is a valid port number.
160-
**isPostalCode(str, locale)** | check if the string is a postal code.<br/><br/>`locale` is one of `['AD', 'AT', 'AU', 'AZ', 'BA', 'BE', 'BG', 'BR', 'BY', 'CA', 'CH', 'CN', 'CO', 'CZ', 'DE', 'DK', 'DO', 'DZ', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HT', 'HU', 'ID', 'IE', 'IL', 'IN', 'IR', 'IS', 'IT', 'JP', 'KE', 'KR', 'LI', 'LK', 'LT', 'LU', 'LV', 'MG', 'MT', 'MX', 'MY', 'NL', 'NO', 'NP', 'NZ', 'PK', 'PL', 'PR', 'PT', 'RO', 'RU', 'SA', 'SE', 'SG', 'SI', 'SK', 'TH', 'TN', 'TW', 'UA', 'US', 'ZA', 'ZM']` OR `'any'`. If 'any' is used, function will check if any of the locales match. Locale list is `validator.isPostalCodeLocales`.
160+
**isPostalCode(str, locale)** | check if the string is a postal code.<br/><br/>`locale` is one of `['AD', 'AT', 'AU', 'AZ', 'BA', 'BD', 'BE', 'BG', 'BR', 'BY', 'CA', 'CH', 'CN', 'CO', 'CZ', 'DE', 'DK', 'DO', 'DZ', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HT', 'HU', 'ID', 'IE', 'IL', 'IN', 'IR', 'IS', 'IT', 'JP', 'KE', 'KR', 'LI', 'LK', 'LT', 'LU', 'LV', 'MG', 'MT', 'MX', 'MY', 'NL', 'NO', 'NP', 'NZ', 'PK', 'PL', 'PR', 'PT', 'RO', 'RU', 'SA', 'SE', 'SG', 'SI', 'SK', 'TH', 'TN', 'TW', 'UA', 'US', 'ZA', 'ZM']` OR `'any'`. If 'any' is used, function will check if any of the locales match. Locale list is `validator.isPostalCodeLocales`.
161161
**isRFC3339(str)** | check if the string is a valid [RFC 3339][RFC 3339] date.
162162
**isRgbColor(str [,options])** | check if the string is a rgb or rgba color.<br/></br>`options` is an object with the following properties<br/><br/>`includePercentValues` defaults to `true`. If you don't want to allow to set `rgb` or `rgba` values with percents, like `rgb(5%,5%,5%)`, or `rgba(90%,90%,90%,.3)`, then set it to false.<br/><br/>`allowSpaces` defaults to `true`, which prohibits whitespace. If set to false, whitespace between color values is allowed, such as `rgb(255, 255, 255)` or even `rgba(255, 128, 0, 0.7)`.
163163
**isSemVer(str)** | check if the string is a Semantic Versioning Specification (SemVer).

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "validator",
33
"description": "String validation and sanitization",
4-
"version": "13.15.0",
4+
"version": "13.15.15",
55
"sideEffects": false,
66
"homepage": "https://github.com/validatorjs/validator.js",
77
"files": [

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ import isStrongPassword from './lib/isStrongPassword';
130130

131131
import isVAT from './lib/isVAT';
132132

133-
const version = '13.15.0';
133+
const version = '13.15.15';
134134

135135
const validator = {
136136
version,

src/lib/isLicensePlate.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lib/isPostalCode.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const patterns = {
1212
AU: fourDigit,
1313
AZ: /^AZ\d{4}$/,
1414
BA: /^([7-8]\d{4}$)/,
15+
BD: /^([1-8][0-9]{3}|9[0-4][0-9]{2})$/,
1516
BE: fourDigit,
1617
BG: fourDigit,
1718
BR: /^\d{5}-?\d{3}$/,

test/validators.test.js

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12431,7 +12431,41 @@ describe('Validators', () => {
1243112431
'2017',
1243212432
'0800',
1243312433
],
12434-
}, {
12434+
},
12435+
{
12436+
locale: 'BD',
12437+
valid: [
12438+
'1000',
12439+
'1200',
12440+
'1300',
12441+
'1400',
12442+
'1500',
12443+
'2000',
12444+
'3000',
12445+
'4000',
12446+
'5000',
12447+
'6000',
12448+
'7000',
12449+
'8000',
12450+
'9000',
12451+
'9400',
12452+
'9499',
12453+
],
12454+
invalid: [
12455+
'0999',
12456+
'9500',
12457+
'10000',
12458+
'12345',
12459+
'123',
12460+
'123456',
12461+
'abcd',
12462+
'123a',
12463+
'a123',
12464+
'12 34',
12465+
'12-34',
12466+
],
12467+
},
12468+
{
1243512469
locale: 'BY',
1243612470
valid: [
1243712471
'225320',
@@ -14296,16 +14330,42 @@ describe('Validators', () => {
1429614330
args: ['pt-PT'],
1429714331
valid: [
1429814332
'AA-12-34',
14299-
'12·34·AB',
14333+
'12-AA-34',
14334+
'12-34-AA',
14335+
'AA-12-AA',
14336+
'AA·12·34',
1430014337
'12·AB·34',
14338+
'12·34·AB',
14339+
'AB·34·AB',
14340+
'AA 12 34',
14341+
'12 AA 34',
14342+
'12 34 AA',
1430114343
'AB 12 CD',
14344+
'AA1234',
14345+
'12AA34',
14346+
'1234AA',
1430214347
'AB12CD',
1430314348
],
1430414349
invalid: [
1430514350
'',
1430614351
'notalicenseplate',
14352+
'AA-AA-00',
14353+
'00-AA-AA',
14354+
'AA-AA-AA',
14355+
'00-00-00',
14356+
'AA·AA·00',
14357+
'00·AA·AA',
14358+
'AA·AA·AA',
14359+
'00·00·00',
14360+
'AA AA 00',
14361+
'00 AA AA',
14362+
'AA AA AA',
14363+
'00 00 00',
1430714364
'A1-B2-C3',
14365+
'1A-2B-3C',
1430814366
'ABC-1-EF',
14367+
'AB-C1D-EF',
14368+
'AB-C1-DEF',
1430914369
],
1431014370
});
1431114371
test({

0 commit comments

Comments
 (0)