From 9f0cbc052abc4631a99847fe7ccf0b6f4702161b Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Tue, 20 Dec 2022 00:53:21 +0100 Subject: [PATCH 1/2] fix(isPostalCode): fix overly permissive IR regexp replace "word boundary" anchor `\b` with start/end of line anchors `^` / `$`, to fix this fixes #2135 --- src/lib/isPostalCode.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/isPostalCode.js b/src/lib/isPostalCode.js index cf5b50d25..1c45ca1c1 100644 --- a/src/lib/isPostalCode.js +++ b/src/lib/isPostalCode.js @@ -37,7 +37,7 @@ const patterns = { IE: /^(?!.*(?:o))[A-Za-z]\d[\dw]\s\w{4}$/i, IL: /^(\d{5}|\d{7})$/, IN: /^((?!10|29|35|54|55|65|66|86|87|88|89)[1-9][0-9]{5})$/, - IR: /\b(?!(\d)\1{3})[13-9]{4}[1346-9][013-9]{5}\b/, + IR: /^(?!(\d)\1{3})[13-9]{4}[1346-9][013-9]{5}$/, IS: threeDigit, IT: fiveDigit, JP: /^\d{3}\-\d{4}$/, From c9dfce2c4d523bd565013d05f6ceb3795ccc76f9 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Tue, 20 Dec 2022 21:06:51 +0100 Subject: [PATCH 2/2] test(validators): add invalid tests for isPostalCode locale IR --- test/validators.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/validators.js b/test/validators.js index c0e36bec7..0591250fb 100644 --- a/test/validators.js +++ b/test/validators.js @@ -11447,6 +11447,9 @@ describe('Validators', () => { '43516 6456', '123443516 6456', '891123', + 'test 4351666456', + '4351666456 test', + 'test 4351666456 test', ], }, {