Skip to content

Commit

Permalink
Update Serbian postal code validation
Browse files Browse the repository at this point in the history
According to Wikipedia, also known as the most reliable source of
information on the whole Internet, Serbian postal codes consist of five
digits [1].

Even though it mentions that a six-digit postal code format has been in
place since 1 January 2005 [2], I have not found any Serbian postal code
which consists of six digits.

Maybe someone would prove us wrong, but we will keep the validation as
six-digits from now one.

[1]: https://en.wikipedia.org/wiki/Postal_codes_in_Serbia
[2]: https://web.archive.org/web/20090917083620/http://www.posta.rs/postanskamreza/postanskamreza.asp

Co-authored-by: Henrique Moody <[email protected]>
  • Loading branch information
DanielAlt and henriquemoody committed Jul 14, 2020
1 parent e2783d4 commit 0a3f4c6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion library/Rules/PostalCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ final class PostalCode extends AbstractEnvelope
'PY' => '/^(\d{4})$/',
'RE' => '/^((97|98)(4|7|8)\d{2})$/',
'RO' => '/^(\d{6})$/',
'RS' => '/^(\d{6})$/',
'RS' => '/^(\d{5})$/',
'RU' => '/^(\d{6})$/',
'SA' => '/^(\d{5})$/',
'SD' => '/^(\d{5})$/',
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/Rules/PostalCodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public function providerForValidInput(): array
[new PostalCode('KY'), 'KY2-2001'],
[new PostalCode('KY'), 'KY3-2500'],
[new PostalCode('AM'), '0010'],
[new PostalCode('RS'), '24430'],
];
}

Expand All @@ -111,6 +112,7 @@ public function providerForInvalidInput(): array
[new PostalCode('EC'), 'A1234B'],
[new PostalCode('KY'), 'KY4-2500'],
[new PostalCode('AM'), '375010'],
[new PostalCode('RS'), '244300'],
];
}
}

0 comments on commit 0a3f4c6

Please sign in to comment.