From 66fd55bfe9dc0b980f901aa22637e57ab36648f9 Mon Sep 17 00:00:00 2001 From: Nimantha Cooray Date: Thu, 14 Oct 2021 08:55:23 +0530 Subject: [PATCH 1/3] Add `LK` locale to `isPostalCode` --- src/lib/isPostalCode.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib/isPostalCode.js b/src/lib/isPostalCode.js index 915c27f2b..7ef17abcf 100644 --- a/src/lib/isPostalCode.js +++ b/src/lib/isPostalCode.js @@ -46,6 +46,7 @@ const patterns = { LT: /^LT\-\d{5}$/, LU: fourDigit, LV: /^LV\-\d{4}$/, + LK: fiveDigit, MX: fiveDigit, MT: /^[A-Za-z]{3}\s{0,1}\d{4}$/, MY: fiveDigit, From 311ffcdcb974a879455b9da06161023ead154344 Mon Sep 17 00:00:00 2001 From: Nimantha Cooray Date: Thu, 14 Oct 2021 08:58:11 +0530 Subject: [PATCH 2/3] Add tests for `LK` locale of `isPostalCode` --- test/validators.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/validators.js b/test/validators.js index 91794d521..c81b11d17 100644 --- a/test/validators.js +++ b/test/validators.js @@ -10004,6 +10004,20 @@ describe('Validators', () => { 'ab1234', ], }, + { + locale: 'LK', + valid: [ + '11500', + '22200', + '10370', + '43000', + ], + invalid: [ + '1234', + '789389', + '982', + ], + }, ]; let allValid = []; From 8201312cc4ac7359ebf08cc1190d038261bf9ee9 Mon Sep 17 00:00:00 2001 From: Nimantha Cooray Date: Thu, 14 Oct 2021 09:02:01 +0530 Subject: [PATCH 3/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1ff1e00dc..9c4928889 100644 --- a/README.md +++ b/README.md @@ -147,7 +147,7 @@ Validator | Description **isOctal(str)** | check if the string is a valid octal number. **isPassportNumber(str, countryCode)** | check if the string is a valid passport number.

(countryCode is one of `[ 'AM', 'AR', 'AT', 'AU', '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', 'JP', 'KR', 'LT', 'LU', 'LV', 'LY', 'MT', 'MY', 'MZ', 'NL', 'PO', 'PT', 'RO', 'RU', 'SE', 'SL', 'SK', 'TR', 'UA', 'US' ]`. **isPort(str)** | check if the string is a valid port number. -**isPostalCode(str, locale)** | check if the string is a postal code,

(locale is one of `[ 'AD', 'AT', 'AU', 'AZ', 'BE', 'BG', 'BR', 'BY', 'CA', 'CH', 'CN', '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', 'LT', 'LU', 'LV', 'MT', 'MX', 'MY', 'NL', 'NO', 'NP', 'NZ', 'PL', 'PR', 'PT', 'RO', 'RU', 'SA', 'SE', 'SG', 'SI', 'TH', '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`.). +**isPostalCode(str, locale)** | check if the string is a postal code,

(locale is one of `[ 'AD', 'AT', 'AU', 'AZ', 'BE', 'BG', 'BR', 'BY', 'CA', 'CH', 'CN', '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', 'MT', 'MX', 'MY', 'NL', 'NO', 'NP', 'NZ', 'PL', 'PR', 'PT', 'RO', 'RU', 'SA', 'SE', 'SG', 'SI', 'TH', '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`.). **isRFC3339(str)** | check if the string is a valid [RFC 3339](https://tools.ietf.org/html/rfc3339) date. **isRgbColor(str [, includePercentValues])** | check if the string is a rgb or rgba color.

`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. **isSemVer(str)** | check if the string is a Semantic Versioning Specification (SemVer).