Skip to content

Commit

Permalink
Merge pull request #162 from maxmind/greg/updates-for-respect-validat…
Browse files Browse the repository at this point in the history
…ion-2.3

Updates for Respect/Validation 2.3
  • Loading branch information
faktas2 authored Feb 5, 2024
2 parents b046112 + 694fd25 commit 8f093c5
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"ext-json": "*",
"geoip2/geoip2": "^v3.0.0",
"maxmind/web-service-common": "^0.9.0",
"respect/validation": "^2.2.4"
"respect/validation": "^2.3.1"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "3.*",
Expand Down
2 changes: 0 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,3 @@ parameters:
- src
- tests
checkMissingIterableValueType: false
ignoreErrors:
- '/Parameter \#\d+ \.\.\.\$rule of static method Respect\\Validation\\StaticValidator::keySet\(\) expects Respect\\Validation\\Rules\\Key, Respect\\Validation\\ChainedValidator given\./'
2 changes: 1 addition & 1 deletion src/MinFraud/Validation/Rules/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static function keys(): array
v::key('address_2', new IntOrString(), false),
v::key('city', v::stringType(), false),
v::key('company', v::stringType(), false),
v::key('country', v::countryCode(), false),
v::key('country', v::allOf(v::countryCode(), v::uppercase()), false),
v::key('first_name', v::stringType(), false),
v::key('last_name', v::stringType(), false),
v::key('phone_country_code', new TelephoneCountryCode(), false),
Expand Down
2 changes: 1 addition & 1 deletion src/MinFraud/Validation/Rules/CreditCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct()
v::key('bank_name', v::stringType(), false),
v::key('bank_phone_country_code', new TelephoneCountryCode(), false),
v::key('bank_phone_number', v::stringType(), false),
v::key('country', v::countryCode(), false),
v::key('country', v::allOf(v::countryCode(), v::uppercase()), false),
v::key('cvv_result', v::stringType()->length(1, 1), false),
v::key('issuer_id_number', v::regex('/^(?:[0-9]{6}|[0-9]{8})$/'), false),
v::key('last_digits', v::regex('/^(?:[0-9]{2}|[0-9]{4})$/'), false),
Expand Down
7 changes: 6 additions & 1 deletion src/MinFraud/Validation/Rules/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ public function __construct()
'time',
v::anyOf(
v::dateTime(\DateTime::RFC3339),
v::dateTime(\DateTime::RFC3339_EXTENDED)
v::dateTime(\DateTime::RFC3339_EXTENDED),
// Respect/Validation no longer correctly supports the RFC 3339
// formats as of 2.3. See
// https://github.com/Respect/Validation/issues/1442.
v::dateTime('Y-m-d\TH:i:sp'),
v::dateTime('Y-m-d\TH:i:s.vp'),
),
false
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public static function requestsMissingRequiredFields(): array
public function testUnknownKey(): void
{
$this->expectException(InvalidInputException::class);
$this->expectExceptionMessage('Must have keys');
$this->expectExceptionMessage('Must not have keys');

$req = array_merge(
Data::minimalRequest(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use MaxMind\MinFraud\Validation\Rules\CreditCard;
use PHPUnit\Framework\TestCase;
use Respect\Validation\Exceptions\CountryCodeException;

/**
* @coversNothing
Expand All @@ -24,7 +23,7 @@ public function testInvalidCountry($code): void
{
$validator = new CreditCard();

$this->expectException(CountryCodeException::class);
$this->expectExceptionMessageMatches('/^country must be a valid country|country must be uppercase$/');

$validator->check([
'country' => $code,
Expand Down
4 changes: 2 additions & 2 deletions tests/MaxMind/Test/MinFraudTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public function testMissingIpAddressWithoutValidation(string $class, string $ser
public function testUnknownKeys(string $method): void
{
$this->expectException(InvalidInputException::class);
$this->expectExceptionMessage('Must have keys');
$this->expectExceptionMessage('Must not have keys');

$this->createMinFraudRequestWithFullResponse(
'insights',
Expand Down Expand Up @@ -996,7 +996,7 @@ public static function invalidQuantities(): array
public function testBadShoppingCartItemWithDoubleArray(): void
{
$this->expectException(InvalidInputException::class);
$this->expectExceptionMessage('Must have keys');
$this->expectExceptionMessage('Must not have keys');

$this->createMinFraudRequestWithFullResponse(
'insights',
Expand Down

0 comments on commit 8f093c5

Please sign in to comment.