diff --git a/src/Formatter/SEFormatter.php b/src/Formatter/SEFormatter.php index ee42480..e0a3c5b 100644 --- a/src/Formatter/SEFormatter.php +++ b/src/Formatter/SEFormatter.php @@ -14,7 +14,6 @@ * Validates and formats postcodes in Sweden. * * Postcode format is NNN NN. - * The lowest number is 100 00 and the highest number is 984 99. * * @see https://en.wikipedia.org/wiki/List_of_postal_codes * @see https://en.wikipedia.org/wiki/Postal_codes_in_Sweden @@ -24,11 +23,7 @@ final class SEFormatter implements CountryPostcodeFormatter #[Override] public function format(string $postcode): ?string { - if (preg_match('/^[0-9]{5}$/', $postcode) !== 1) { - return null; - } - - if ($postcode < '10000' || $postcode > '98499') { + if (preg_match('/^[1-9][0-9]{4}$/', $postcode) !== 1) { return null; } diff --git a/tests/Formatter/SEFormatterTest.php b/tests/Formatter/SEFormatterTest.php index d8b0231..aead3a7 100644 --- a/tests/Formatter/SEFormatterTest.php +++ b/tests/Formatter/SEFormatterTest.php @@ -26,7 +26,8 @@ public static function providerFormat(): array ['10000', '100 00'], ['12345', '123 45'], ['98499', '984 99'], - ['98500', null], + ['98531', '985 31'], + ['98631', '986 31'], ['123456', null], ['A', null],