Skip to content

Commit c30126b

Browse files
authored
Merge pull request #830 from stevula/master
Export the locales list for isPostalCode
2 parents 843fd1e + 92e771a commit c30126b

File tree

6 files changed

+8
-4
lines changed

6 files changed

+8
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ Validator | Description
107107
**isMultibyte(str)** | check if the string contains one or more multibyte chars.
108108
**isNumeric(str)** | check if the string contains only numbers.
109109
**isPort(str)** | check if the string is a valid port number.
110-
**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', 'ES', 'FI', 'FR', 'GB', 'GR', 'IL', 'IN', 'IS', 'IT', 'JP', 'KE', 'LI', 'MX', 'NL', 'NO', 'PL', 'PT', 'RO', 'RU', 'SA', 'SE', 'TW', 'US', 'ZA', 'ZM' ]` OR 'any'. If 'any' is used, function will check if any of the locals match).
110+
**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', 'ES', 'FI', 'FR', 'GB', 'GR', 'IL', 'IN', 'IS', 'IT', 'JP', 'KE', 'LI', 'MX', 'NL', 'NO', 'PL', 'PT', 'RO', 'RU', 'SA', 'SE', 'TW', 'US', 'ZA', 'ZM' ]` OR 'any'. If 'any' is used, function will check if any of the locals match. locale list is `validator.isPostalCodeLocales`.).
111111
**isSurrogatePair(str)** | check if the string contains any surrogate pairs chars.
112112
**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 }`.
113113
**isUUID(str [, version])** | check if the string is a UUID (version 3, 4 or 5).

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ var validator = {
335335
isISSN: _isISSN2.default,
336336
isMobilePhone: _isMobilePhone2.default,
337337
isPostalCode: _isPostalCode2.default,
338+
isPostalCodeLocales: _isPostalCode.locales,
338339
isCurrency: _isCurrency2.default,
339340
isISO8601: _isISO2.default,
340341
isRFC3339: _isRFC2.default,

src/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ import isDataURI from './lib/isDataURI';
7575
import isMimeType from './lib/isMimeType';
7676

7777
import isLatLong from './lib/isLatLong';
78-
import isPostalCode from './lib/isPostalCode';
78+
import isPostalCode, { locales as isPostalCodeLocales } from './lib/isPostalCode';
7979

8080
import ltrim from './lib/ltrim';
8181
import rtrim from './lib/rtrim';
@@ -144,6 +144,7 @@ const validator = {
144144
isISSN,
145145
isMobilePhone,
146146
isPostalCode,
147+
isPostalCodeLocales,
147148
isCurrency,
148149
isISO8601,
149150
isRFC3339,

test/exports.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@ describe('Exports', function () {
2222

2323
it('should export isPostalCode\'s supported locales', function () {
2424
assert.ok(isPostalCodeLocales instanceof Array);
25+
assert.ok(validator.isPostalCodeLocales instanceof Array);
2526
});
2627
});

validator.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1337,7 +1337,7 @@ var patterns = {
13371337
ZM: fiveDigit
13381338
};
13391339

1340-
1340+
var locales = Object.keys(patterns);
13411341

13421342
var isPostalCode = function (str, locale) {
13431343
assertString(str);
@@ -1605,6 +1605,7 @@ var validator = {
16051605
isISSN: isISSN,
16061606
isMobilePhone: isMobilePhone,
16071607
isPostalCode: isPostalCode,
1608+
isPostalCodeLocales: locales,
16081609
isCurrency: isCurrency,
16091610
isISO8601: isISO8601,
16101611
isRFC3339: isRFC3339,

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)