Skip to content

Commit

Permalink
fix(isPostalCode): fix overly permissive IR regexp (#2136)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
pano9000 authored Jan 22, 2023
1 parent f394da0 commit 394eebf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/isPostalCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}$/,
Expand Down
3 changes: 3 additions & 0 deletions test/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -11471,6 +11471,9 @@ describe('Validators', () => {
'43516 6456',
'123443516 6456',
'891123',
'test 4351666456',
'4351666456 test',
'test 4351666456 test',
],
},
{
Expand Down

0 comments on commit 394eebf

Please sign in to comment.