Skip to content

Commit de68a5e

Browse files
authored
Merge pull request #23 from crazyfactory/10453-Postcode-Validator
fix(Validator): add valiation for 'IE' and fix 'MT'
2 parents 8056586 + ed2fee0 commit de68a5e

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

src/ZipCode/Validator.php

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class Validator
2929
'GR' => ['11111'],
3030
'HR' => ['11111'],
3131
'HU' => ['1111'],
32-
// 'IE' See above
32+
'IE' => ['A11 A111','A11 AA11', 'A11 AAA1','A11 AAAA','A11 A11A','A11 A1A1','D6W A111','D6W AA11','D6W AAA1','D6W AAAA','D6W A11A','D6W A1A1'],
3333
'IT' => ['11111'],
3434
'LT' => ['11111'],
3535
'LU' => ['1111'],
@@ -69,13 +69,13 @@ class Validator
6969
'GR' => '[1-9]{1}[0-9]{4}',
7070
'HR' => '[0-9]{5}',
7171
'HU' => '\\d{4}',
72-
// 'IE' => '[-1-9]{1}', See above
72+
'IE' => '(D6W|[A-HK-PR-TW-Y]{1}[0-9]{2})\\s[A-Z]{1}[A-Z0-9]{3}',
7373
'IT' => '\\d{5}',
7474
'LT' => '\\d{5}',
7575
'LU' => '[0-9]\\d{3}',
7676
'LV' => '(LV-)?[1-9]{1}\\d{3}',
7777
'MC' => '98[0-9]{3}',
78-
'MT' => '[A-Z]{3}\\s[1-9]{1}[0-9]{3}',
78+
'MT' => '[A-Z]{3}\\s[0-9]{4}',
7979
'NL' => '[1-9]\\d{3}\\s[A-Z]{2}',
8080
'NO' => '\\d{4}',
8181
'PL' => '\\d{2}-\\d{3}',
@@ -96,11 +96,6 @@ class Validator
9696
*/
9797
public function validate(string $zipCode, string $countryCode): bool
9898
{
99-
// See above
100-
if ($countryCode === 'IE') {
101-
return true;
102-
}
103-
10499
// No need zip code countries
105100
if (in_array($countryCode, [
106101
'AE',
@@ -128,11 +123,6 @@ public function validate(string $zipCode, string $countryCode): bool
128123
*/
129124
public static function isValid(string $zipCode, string $countryCode): bool
130125
{
131-
// See above
132-
if ($countryCode === 'IE') {
133-
return true;
134-
}
135-
136126
static $instance;
137127

138128
if (!$instance) {

0 commit comments

Comments
 (0)