Skip to content

Commit

Permalink
irish pattern added with tests in postal code validation (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
musaberatbahadir authored Sep 14, 2024
1 parent 9ab80e5 commit 11ae3ce
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Rules/Postalcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ private function getPattern(string $countrycode): ?string
'tw' => "/^[0-9]{3}([0-9]{2})?$/",
'gb' => "/^(([a-z][0-9])|([a-z][0-9]{2})|([a-z][0-9][a-z])|([a-z]{2}[0-9])" .
"|([a-z]{2}[0-9]{2})|([a-z]{2}[0-9][a-z])) [0-9][a-z]{2}$/i",
'ie' => "/^[A-Za-z][A-Za-z0-9]{2} [A-Za-z0-9]{4}$/i",
default => null,
};
}
Expand Down
9 changes: 9 additions & 0 deletions tests/Rules/PostalcodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,15 @@ public static function dataProvider(): array
[false, 'gb', '1234'],
[false, 'gb', '12345'],
[false, 'gb', '123456'],

[true, 'ie', 'A65 F4E2'],
[true, 'ie', 'D02 X285'],
[true, 'ie', 'T12 A7KX'],
[false, 'ie', '123456'],
[false, 'ie', 'A65F4E2'],
[false, 'ie', 'A6 5F4E2'],
[false, 'ie', 'D02X28'],
[false, 'ie', 'AB12 C345'],
];
}
}

0 comments on commit 11ae3ce

Please sign in to comment.