From 11ae3ce5c6e4f867031983c07a83830598ec3402 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Musa=20Berat=20Bahad=C4=B1r?= Date: Sat, 14 Sep 2024 08:30:26 +0200 Subject: [PATCH] irish pattern added with tests in postal code validation (#88) --- src/Rules/Postalcode.php | 1 + tests/Rules/PostalcodeTest.php | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/src/Rules/Postalcode.php b/src/Rules/Postalcode.php index 4f681e5..baca8cd 100644 --- a/src/Rules/Postalcode.php +++ b/src/Rules/Postalcode.php @@ -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, }; } diff --git a/tests/Rules/PostalcodeTest.php b/tests/Rules/PostalcodeTest.php index 2945105..762869c 100644 --- a/tests/Rules/PostalcodeTest.php +++ b/tests/Rules/PostalcodeTest.php @@ -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'], ]; } }