Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge pull request #80 from vaclavvanik/master
Browse files Browse the repository at this point in the history
LV post code accepts LV- prefix
  • Loading branch information
weierophinney committed Apr 25, 2018
2 parents f5a8ab3 + 2f29c2d commit 4f63c43
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Validator/PostCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class PostCode extends AbstractValidator
'KE' => '\d{5}',
'KW' => '\d{5}',
'LA' => '\d{5}',
'LV' => '\d{4}',
'LV' => '(LV-)?\d{4}',
'LB' => '(\d{4}([ ]?\d{4})?)?',
'LI' => '(948[5-9])|(949[0-7])',
'LT' => '\d{5}',
Expand Down
17 changes: 17 additions & 0 deletions test/Validator/PostCodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,21 @@ public function testNoPostCodes()
$this->assertTrue($validator->isValid('9910')); // BJØRNEVATN
$this->assertFalse($validator->isValid('0000')); // Postal code 0000
}

/**
* Postal codes in Latvia are 4 digit numeric and use a mandatory ISO 3166-1 alpha-2 country code (LV) in front,
* i.e. the format is “LV-NNNN”.
* To prevent BC break LV- prefix is optional
* https://en.wikipedia.org/wiki/Postal_codes_in_Latvia
*/
public function testLvPostCodes()
{
$validator = $this->validator;
$validator->setLocale('en_LV');

$this->assertTrue($validator->isValid('LV-0000'));
$this->assertTrue($validator->isValid('0000'));
$this->assertFalse($validator->isValid('ABCD'));
$this->assertFalse($validator->isValid('LV-ABCD'));
}
}

0 comments on commit 4f63c43

Please sign in to comment.