Skip to content

Commit

Permalink
NL postcodes cannot start with 0
Browse files Browse the repository at this point in the history
Fixes #18.
  • Loading branch information
BenMorel committed Dec 5, 2024
1 parent 590857e commit 9ebae28
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Formatter/NLFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class NLFormatter implements CountryPostcodeFormatter
{
public function format(string $postcode) : ?string
{
if (preg_match('/^([0-9]{4})([A-Z]{2})$/', $postcode, $matches) !== 1) {
if (preg_match('/^([1-9][0-9]{3})([A-Z]{2})$/', $postcode, $matches) !== 1) {
return null;
}

Expand Down
1 change: 1 addition & 0 deletions tests/Formatter/NLFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public function providerFormat() : array
return [
['', null],

['0123AB', null],
['1234AB', '1234 AB'],
['1234SS', null],
['1234SD', null],
Expand Down

0 comments on commit 9ebae28

Please sign in to comment.