Skip to content

Commit

Permalink
Merge pull request #836 from agims7/newPostalCodesValidation
Browse files Browse the repository at this point in the history
Added EE, HR, HU, LT, LU, LV SI postal codes validation
  • Loading branch information
chriso authored May 25, 2018
2 parents e218607 + 1ff9804 commit bf34fac
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Validator | Description
**isMultibyte(str)** | check if the string contains one or more multibyte chars.
**isNumeric(str)** | check if the string contains only numbers.
**isPort(str)** | check if the string is a valid port number.
**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', '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`.).
**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`.).
**isSurrogatePair(str)** | check if the string contains any surrogate pairs chars.
**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 }`.
**isUUID(str [, version])** | check if the string is a UUID (version 3, 4 or 5).
Expand Down
7 changes: 7 additions & 0 deletions lib/isPostalCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,24 @@ var patterns = {
DE: fiveDigit,
DK: fourDigit,
DZ: fiveDigit,
EE: fiveDigit,
ES: fiveDigit,
FI: fiveDigit,
FR: /^\d{2}\s?\d{3}$/,
GB: /^(gir\s?0aa|[a-z]{1,2}\d[\da-z]?\s?(\d[a-z]{2})?)$/i,
GR: /^\d{3}\s?\d{2}$/,
HR: /^([1-5]\d{4}$)/,
HU: fourDigit,
IL: fiveDigit,
IN: sixDigit,
IS: threeDigit,
IT: fiveDigit,
JP: /^\d{3}\-\d{4}$/,
KE: fiveDigit,
LI: /^(948[5-9]|949[0-7])$/,
LT: /^LT\-\d{5}$/,
LU: fourDigit,
LV: /^LV\-\d{4}$/,
MX: fiveDigit,
NL: /^\d{4}\s?[a-z]{2}$/i,
NO: fourDigit,
Expand All @@ -67,6 +73,7 @@ var patterns = {
RU: sixDigit,
SA: fiveDigit,
SE: /^\d{3}\s?\d{2}$/,
SI: fourDigit,
SK: /^\d{3}\s?\d{2}$/,
TN: fourDigit,
TW: /^\d{3}(\d{2})?$/,
Expand Down
7 changes: 7 additions & 0 deletions src/lib/isPostalCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,24 @@ const patterns = {
DE: fiveDigit,
DK: fourDigit,
DZ: fiveDigit,
EE: fiveDigit,
ES: fiveDigit,
FI: fiveDigit,
FR: /^\d{2}\s?\d{3}$/,
GB: /^(gir\s?0aa|[a-z]{1,2}\d[\da-z]?\s?(\d[a-z]{2})?)$/i,
GR: /^\d{3}\s?\d{2}$/,
HR: /^([1-5]\d{4}$)/,
HU: fourDigit,
IL: fiveDigit,
IN: sixDigit,
IS: threeDigit,
IT: fiveDigit,
JP: /^\d{3}\-\d{4}$/,
KE: fiveDigit,
LI: /^(948[5-9]|949[0-7])$/,
LT: /^LT\-\d{5}$/,
LU: fourDigit,
LV: /^LV\-\d{4}$/,
MX: fiveDigit,
NL: /^\d{4}\s?[a-z]{2}$/i,
NO: fourDigit,
Expand All @@ -38,6 +44,7 @@ const patterns = {
RU: sixDigit,
SA: fiveDigit,
SE: /^\d{3}\s?\d{2}$/,
SI: fourDigit,
SK: /^\d{3}\s?\d{2}$/,
TN: fourDigit,
TW: /^\d{3}(\d{2})?$/,
Expand Down
7 changes: 7 additions & 0 deletions validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -1303,18 +1303,24 @@ var patterns = {
DE: fiveDigit,
DK: fourDigit,
DZ: fiveDigit,
EE: fiveDigit,
ES: fiveDigit,
FI: fiveDigit,
FR: /^\d{2}\s?\d{3}$/,
GB: /^(gir\s?0aa|[a-z]{1,2}\d[\da-z]?\s?(\d[a-z]{2})?)$/i,
GR: /^\d{3}\s?\d{2}$/,
HR: /^([1-5]\d{4}$)/,
HU: fourDigit,
IL: fiveDigit,
IN: sixDigit,
IS: threeDigit,
IT: fiveDigit,
JP: /^\d{3}\-\d{4}$/,
KE: fiveDigit,
LI: /^(948[5-9]|949[0-7])$/,
LT: /^LT\-\d{5}$/,
LU: fourDigit,
LV: /^LV\-\d{4}$/,
MX: fiveDigit,
NL: /^\d{4}\s?[a-z]{2}$/i,
NO: fourDigit,
Expand All @@ -1324,6 +1330,7 @@ var patterns = {
RU: sixDigit,
SA: fiveDigit,
SE: /^\d{3}\s?\d{2}$/,
SI: fourDigit,
SK: /^\d{3}\s?\d{2}$/,
TN: fourDigit,
TW: /^\d{3}(\d{2})?$/,
Expand Down
2 changes: 1 addition & 1 deletion validator.min.js

Large diffs are not rendered by default.

0 comments on commit bf34fac

Please sign in to comment.