Skip to content

Commit e09fc71

Browse files
authored
Merge pull request #861 from Draeriel/master
Added AD postalcode validation
2 parents 7dfcc22 + 95b9eb2 commit e09fc71

File tree

6 files changed

+17
-2
lines changed

6 files changed

+17
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ Validator | Description
108108
**isMultibyte(str)** | check if the string contains one or more multibyte chars.
109109
**isNumeric(str [, options])** | check if the string contains only numbers.<br/><br/>`options` is an object which defaults to `{no_symbols: false}`. If `no_symbols` is true, the validator will reject numeric strings that feature a symbol (e.g. `+`, `-`, or `.`).
110110
**isPort(str)** | check if the string is a valid port number.
111-
**isPostalCode(str, locale)** | check if the string is a postal code,<br/><br/>(locale is one of `[ 'AT', 'AU', 'BE', 'BG', 'CA', 'CH', 'CZ', 'DE', 'DK', 'DZ', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HU', 'IL', 'IN', 'IS', 'IT', 'JP', 'KE', 'LI', 'LT', 'LU', 'LV', 'MX', 'NL', 'NO', 'PL', 'PT', 'RO', 'RU', 'SA', 'SE', 'SI', 'TN', 'TW', 'US', 'ZA', 'ZM' ]` OR 'any'. If 'any' is used, function will check if any of the locals match. locale list is `validator.isPostalCodeLocales`.).
111+
**isPostalCode(str, locale)** | check if the string is a postal code,<br/><br/>(locale is one of `[ 'AD', 'AT', 'AU', 'BE', 'BG', 'CA', 'CH', 'CZ', 'DE', 'DK', 'DZ', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HU', 'IL', 'IN', 'IS', 'IT', 'JP', 'KE', 'LI', 'LT', 'LU', 'LV', 'MX', 'NL', 'NO', 'PL', 'PT', 'RO', 'RU', 'SA', 'SE', 'SI', 'TN', 'TW', 'US', 'ZA', 'ZM' ]` OR 'any'. If 'any' is used, function will check if any of the locals match. locale list is `validator.isPostalCodeLocales`.).
112112
**isSurrogatePair(str)** | check if the string contains any surrogate pairs chars.
113113
**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 }`.
114114
**isUUID(str [, version])** | check if the string is a UUID (version 3, 4 or 5).

lib/isPostalCode.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ var fiveDigit = /^\d{5}$/;
3636
var sixDigit = /^\d{6}$/;
3737

3838
var patterns = {
39+
AD: /^AD\d{3}$/,
3940
AT: fourDigit,
4041
AU: fourDigit,
4142
BE: fourDigit,

src/lib/isPostalCode.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const fiveDigit = /^\d{5}$/;
77
const sixDigit = /^\d{6}$/;
88

99
const patterns = {
10+
AD: /^AD\d{3}$/,
1011
AT: fourDigit,
1112
AU: fourDigit,
1213
BE: fourDigit,

test/validators.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5699,6 +5699,18 @@ describe('Validators', () => {
56995699
'499 49',
57005700
],
57015701
},
5702+
{
5703+
locale: 'AD',
5704+
valid: [
5705+
'AD100',
5706+
'AD200',
5707+
'AD300',
5708+
'AD400',
5709+
'AD500',
5710+
'AD600',
5711+
'AD700',
5712+
],
5713+
},
57025714
];
57035715

57045716
let allValid = [];

validator.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,6 +1357,7 @@ var fiveDigit = /^\d{5}$/;
13571357
var sixDigit = /^\d{6}$/;
13581358

13591359
var patterns = {
1360+
AD: /^AD\d{3}$/,
13601361
AT: fourDigit,
13611362
AU: fourDigit,
13621363
BE: fourDigit,

validator.min.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.

0 commit comments

Comments
 (0)