Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions src/Formatter/SEFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}

Expand Down
3 changes: 2 additions & 1 deletion tests/Formatter/SEFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
Loading