Skip to content

Commit 52f7673

Browse files
Maxim-Mazurokchriso
authored andcommittedDec 23, 2018
feat(isPostalCode): added UA locale (#947)
1 parent 285f58d commit 52f7673

File tree

6 files changed

+13
-2
lines changed

6 files changed

+13
-2
lines changed
 

‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ Validator | Description
111111
**isMultibyte(str)** | check if the string contains one or more multibyte chars.
112112
**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 `.`).
113113
**isPort(str)** | check if the string is a valid port number.
114-
**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`.).
114+
**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', 'UA', 'US', 'ZA', 'ZM' ]` OR 'any'. If 'any' is used, function will check if any of the locals match. Locale list is `validator.isPostalCodeLocales`.).
115115
**isSurrogatePair(str)** | check if the string contains any surrogate pairs chars.
116116
**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, disallow_auth: false }`.
117117
**isUUID(str [, version])** | check if the string is a UUID (version 3, 4 or 5).

‎lib/isPostalCode.js

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ var patterns = {
5858
SK: /^\d{3}\s?\d{2}$/,
5959
TN: fourDigit,
6060
TW: /^\d{3}(\d{2})?$/,
61+
UA: fiveDigit,
6162
US: /^\d{5}(-\d{4})?$/,
6263
ZA: fourDigit,
6364
ZM: fiveDigit

‎src/lib/isPostalCode.js

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const patterns = {
4949
SK: /^\d{3}\s?\d{2}$/,
5050
TN: fourDigit,
5151
TW: /^\d{3}(\d{2})?$/,
52+
UA: fiveDigit,
5253
US: /^\d{5}(-\d{4})?$/,
5354
ZA: fourDigit,
5455
ZM: fiveDigit,

‎test/validators.js

+8
Original file line numberDiff line numberDiff line change
@@ -6102,6 +6102,14 @@ describe('Validators', () => {
61026102
'AD700',
61036103
],
61046104
},
6105+
{
6106+
locale: 'UA',
6107+
valid: [
6108+
'65000',
6109+
'65080',
6110+
'01000',
6111+
],
6112+
},
61056113
];
61066114

61076115
let allValid = [];

‎validator.js

+1
Original file line numberDiff line numberDiff line change
@@ -1783,6 +1783,7 @@ var patterns = {
17831783
SK: /^\d{3}\s?\d{2}$/,
17841784
TN: fourDigit,
17851785
TW: /^\d{3}(\d{2})?$/,
1786+
UA: fiveDigit,
17861787
US: /^\d{5}(-\d{4})?$/,
17871788
ZA: fourDigit,
17881789
ZM: fiveDigit

‎validator.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.