Update list of postal code validations

This commit will update the list of postal codes using the command
below:

curl -L http://download.geonames.org/export/dump/countryInfo.txt |
  sed 's,\t,\;,g' |
  sort --unique |
  cut --delimiter ';' --field 1,15 |
  sed --regexp-extended "/^#/d; /^[A-Z]{2}\;$/d; s,([A-Z]{2})\;(.+),'\1' => '/\2/'\,,g"

The changes that broke existing tests were reverted.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
This commit is contained in:
Henrique Moody 2020-05-18 22:21:03 +02:00
parent 6e2b3e599e
commit 37746f3a6d
No known key found for this signature in database
GPG key ID: 221E9281655813A6
2 changed files with 12 additions and 4 deletions

View file

@ -88,8 +88,8 @@ final class PostalCode extends AbstractEnvelope
'HT' => '/^(?:HT)*(\d{4})$/',
'HU' => '/^(\d{4})$/',
'ID' => '/^(\d{5})$/',
'IE' => '/^([AC-FHKNPRTV-Y][0-9]{2}|D6W) ?[0-9AC-FHKNPRTV-Y]{4}$/',
'IL' => '/^(\d{5}|\d{7})$/',
'IE' => '/^(D6W|[AC-FHKNPRTV-Y][0-9]{2})\s?([AC-FHKNPRTV-Y0-9]{4})/',
'IL' => '/^(\d{7}|\d{5})$/',
'IM' => '/^((?:(?:[A-PR-UWYZ][A-HK-Y]\d[ABEHMNPRV-Y0-9]|[A-PR-UWYZ]\d[A-HJKPS-UW0-9])\s\d[ABD-HJLNP-UW-Z]{2})|GIR\s?0AA)$/',
'IN' => '/^(\d{6})$/',
'IQ' => '/^(\d{5})$/',
@ -130,6 +130,7 @@ final class PostalCode extends AbstractEnvelope
'MQ' => '/^(\d{5})$/',
'MT' => '/^[A-Z]{3}\s?\d{4}$/',
'MV' => '/^(\d{5})$/',
'MW' => '/^(\d{6})$/',
'MX' => '/^(\d{5})$/',
'MY' => '/^(\d{5})$/',
'MZ' => '/^(\d{4})$/',

View file

@ -18,6 +18,7 @@ use Respect\Validation\Message\Formatter;
use Respect\Validation\Message\Stringifier\KeepOriginalStringName;
use Respect\Validation\Validatable;
use function realpath;
use function Respect\Stringifier\stringify;
use function sprintf;
/**
@ -153,7 +154,10 @@ abstract class RuleTestCase extends TestCase
*/
public static function assertValidInput(Validatable $rule, $input): void
{
self::assertTrue($rule->validate($input));
self::assertTrue(
$rule->validate($input),
sprintf('Validation with input %s is expected to pass', stringify($input))
);
}
/**
@ -161,6 +165,9 @@ abstract class RuleTestCase extends TestCase
*/
public static function assertInvalidInput(Validatable $rule, $input): void
{
self::assertFalse($rule->validate($input));
self::assertFalse(
$rule->validate($input),
sprintf('Validation with input %s it not expected to pass', stringify($input))
);
}
}