Skip to content

Commit df15506

Browse files
authored
Fix: Validate Austrian post codes to exclude invalid values starting with 0 (#15)
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).
1 parent ef8ab8f commit df15506

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/Formatter/ATFormatter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
/**
1010
* Validates and formats postcodes in Austria.
1111
*
12-
* Postcodes consist of 4 digits, without separator.
12+
* Postcodes consist of 4 digits, without separator. The first digit must be 1-9.
1313
*
1414
* @see https://en.wikipedia.org/wiki/List_of_postal_codes
1515
* @see https://en.wikipedia.org/wiki/Postal_codes_in_Austria
@@ -21,7 +21,7 @@ class ATFormatter implements CountryPostcodeFormatter
2121
*/
2222
public function format(string $postcode) : ?string
2323
{
24-
if (preg_match('/^[0-9]{4}$/', $postcode) !== 1) {
24+
if (preg_match('/^[1-9][0-9]{3}$/', $postcode) !== 1) {
2525
return null;
2626
}
2727

0 commit comments

Comments
 (0)