From 2807cf2f7ab7bdc092e81b3ed26b17174ff35d3d Mon Sep 17 00:00:00 2001 From: Andreas Weswaldi <37552851+weswaldix@users.noreply.github.com> Date: Mon, 9 Sep 2024 14:22:32 +0200 Subject: [PATCH 1/2] Fix: Validate Austrian postal codes to exclude invalid values starting with 0 Previously, postal codes such as '0000' or '0999' were considered valid, but in reality, Austrian postal codes always start with digits from 1 to 9. This update corrects the validation to ensure compliance with the Austrian postal code system (see: https://en.wikipedia.org/wiki/Postal_codes_in_Austria#System). --- src/Formatter/ATFormatter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Formatter/ATFormatter.php b/src/Formatter/ATFormatter.php index d010f47..bb714cd 100644 --- a/src/Formatter/ATFormatter.php +++ b/src/Formatter/ATFormatter.php @@ -21,7 +21,7 @@ class ATFormatter implements CountryPostcodeFormatter */ public function format(string $postcode) : ?string { - if (preg_match('/^[0-9]{4}$/', $postcode) !== 1) { + if (preg_match('/^[1-9][0-9]{3}$/', $postcode) !== 1) { return null; } From fe22bfb7a2fd7c8b3c0740be8695300422e63d05 Mon Sep 17 00:00:00 2001 From: Andreas Weswaldi <37552851+weswaldix@users.noreply.github.com> Date: Mon, 16 Sep 2024 09:40:46 +0200 Subject: [PATCH 2/2] Fix: Validate Austrian post codes to exclude invalid values starting with 0 Updated docblock --- src/Formatter/ATFormatter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Formatter/ATFormatter.php b/src/Formatter/ATFormatter.php index bb714cd..80c199a 100644 --- a/src/Formatter/ATFormatter.php +++ b/src/Formatter/ATFormatter.php @@ -9,7 +9,7 @@ /** * Validates and formats postcodes in Austria. * - * Postcodes consist of 4 digits, without separator. + * Postcodes consist of 4 digits, without separator. The first digit must be 1-9. * * @see https://en.wikipedia.org/wiki/List_of_postal_codes * @see https://en.wikipedia.org/wiki/Postal_codes_in_Austria