Skip to content

Commit 394eebf

Browse files
authored
fix(isPostalCode): fix overly permissive IR regexp (#2136)
* fix(isPostalCode): fix overly permissive IR regexp replace "word boundary" anchor `\b` with start/end of line anchors `^` / `$`, to fix this fixes #2135 * test(validators): add invalid tests for isPostalCode locale IR
1 parent f394da0 commit 394eebf

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

src/lib/isPostalCode.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const patterns = {
3737
IE: /^(?!.*(?:o))[A-Za-z]\d[\dw]\s\w{4}$/i,
3838
IL: /^(\d{5}|\d{7})$/,
3939
IN: /^((?!10|29|35|54|55|65|66|86|87|88|89)[1-9][0-9]{5})$/,
40-
IR: /\b(?!(\d)\1{3})[13-9]{4}[1346-9][013-9]{5}\b/,
40+
IR: /^(?!(\d)\1{3})[13-9]{4}[1346-9][013-9]{5}$/,
4141
IS: threeDigit,
4242
IT: fiveDigit,
4343
JP: /^\d{3}\-\d{4}$/,

test/validators.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11471,6 +11471,9 @@ describe('Validators', () => {
1147111471
'43516 6456',
1147211472
'123443516 6456',
1147311473
'891123',
11474+
'test 4351666456',
11475+
'4351666456 test',
11476+
'test 4351666456 test',
1147411477
],
1147511478
},
1147611479
{

0 commit comments

Comments
 (0)