Skip to content

isPostalCode: Iran (IR) RegExp is too permissive, matches invalid postal codes #2135

@pano9000

Description

@pano9000

The current regexp is too permissive, so it will match strings that should not be valid postal codes by themselves
This is caused by a missing "Start of String" and "End of String" anchors in the current Regexp, where it currently rather checks for a word boundary:

\b(?!(\d)\1{3})[13-9]{4}[1346-9][013-9]{5}\b

This results in the following strings being passed as valid postalcodes:

  • test123 4351666456 test456
  • this should not be 5614736867 a valid post code

PR with a fix is coming in a few moments

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions