From 33b444625282df2134095dfc54ed0b1d8850410a Mon Sep 17 00:00:00 2001 From: Niels van Dijk Date: Sat, 18 Jan 2020 16:11:24 +0100 Subject: [PATCH] fix(isPostalCode): add better validation for EirCode IE (#1234) --- es/lib/isPostalCode.js | 4 ++-- lib/isPostalCode.js | 4 ++-- src/lib/isPostalCode.js | 2 +- test/validators.js | 1 + 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/es/lib/isPostalCode.js b/es/lib/isPostalCode.js index 6a3a07056..6f7ca0feb 100644 --- a/es/lib/isPostalCode.js +++ b/es/lib/isPostalCode.js @@ -26,7 +26,7 @@ var patterns = { HR: /^([1-5]\d{4}$)/, HU: fourDigit, ID: fiveDigit, - IE: /^[A-z]\d[\d|w]\s\w{4}$/i, + IE: /^(?!.*(?:o))[A-z]\d[\dw]\s\w{4}$/i, IL: fiveDigit, IN: /^((?!10|29|35|54|55|65|66|86|87|88|89)[1-9][0-9]{5})$/, IS: threeDigit, @@ -81,4 +81,4 @@ export default function (str, locale) { } throw new Error("Invalid locale '".concat(locale, "'")); -} \ No newline at end of file +} diff --git a/lib/isPostalCode.js b/lib/isPostalCode.js index ab29e36d0..766caf05e 100644 --- a/lib/isPostalCode.js +++ b/lib/isPostalCode.js @@ -37,7 +37,7 @@ var patterns = { HR: /^([1-5]\d{4}$)/, HU: fourDigit, ID: fiveDigit, - IE: /^[A-z]\d[\d|w]\s\w{4}$/i, + IE: /^(?!.*(?:o))[A-z]\d[\dw]\s\w{4}$/i, IL: fiveDigit, IN: /^((?!10|29|35|54|55|65|66|86|87|88|89)[1-9][0-9]{5})$/, IS: threeDigit, @@ -94,4 +94,4 @@ function _default(str, locale) { } throw new Error("Invalid locale '".concat(locale, "'")); -} \ No newline at end of file +} diff --git a/src/lib/isPostalCode.js b/src/lib/isPostalCode.js index 4176d5a21..626c6b997 100644 --- a/src/lib/isPostalCode.js +++ b/src/lib/isPostalCode.js @@ -28,7 +28,7 @@ const patterns = { HR: /^([1-5]\d{4}$)/, HU: fourDigit, ID: fiveDigit, - IE: /^[A-z]\d[\d|w]\s\w{4}$/i, + IE: /^(?!.*(?:o))[A-z]\d[\dw]\s\w{4}$/i, IL: fiveDigit, IN: /^((?!10|29|35|54|55|65|66|86|87|88|89)[1-9][0-9]{5})$/, IS: threeDigit, diff --git a/test/validators.js b/test/validators.js index cf3f09d10..79bfa3de2 100644 --- a/test/validators.js +++ b/test/validators.js @@ -6937,6 +6937,7 @@ describe('Validators', () => { 'AW5 TF12', '756 90HG', 'A65T F12', + 'O62 O1O2', ], }, {