diff --git a/composer.json b/composer.json index c1c0e3d..111768a 100644 --- a/composer.json +++ b/composer.json @@ -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.*", diff --git a/phpstan.neon b/phpstan.neon index c823f0e..06f84c2 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -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\./' diff --git a/src/MinFraud/Validation/Rules/Address.php b/src/MinFraud/Validation/Rules/Address.php index 6aadebb..78fb3ef 100644 --- a/src/MinFraud/Validation/Rules/Address.php +++ b/src/MinFraud/Validation/Rules/Address.php @@ -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), diff --git a/src/MinFraud/Validation/Rules/CreditCard.php b/src/MinFraud/Validation/Rules/CreditCard.php index 0f55bd5..e11c21f 100644 --- a/src/MinFraud/Validation/Rules/CreditCard.php +++ b/src/MinFraud/Validation/Rules/CreditCard.php @@ -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), diff --git a/src/MinFraud/Validation/Rules/Event.php b/src/MinFraud/Validation/Rules/Event.php index ea2a33c..7f6548f 100644 --- a/src/MinFraud/Validation/Rules/Event.php +++ b/src/MinFraud/Validation/Rules/Event.php @@ -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 ), diff --git a/tests/MaxMind/Test/MinFraud/ReportTransaction/ReportTransactionTest.php b/tests/MaxMind/Test/MinFraud/ReportTransaction/ReportTransactionTest.php index 388c2e8..1635c63 100644 --- a/tests/MaxMind/Test/MinFraud/ReportTransaction/ReportTransactionTest.php +++ b/tests/MaxMind/Test/MinFraud/ReportTransaction/ReportTransactionTest.php @@ -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(), diff --git a/tests/MaxMind/Test/MinFraud/Validation/Rules/CreditCardTest.php b/tests/MaxMind/Test/MinFraud/Validation/Rules/CreditCardTest.php index df6147e..6637666 100644 --- a/tests/MaxMind/Test/MinFraud/Validation/Rules/CreditCardTest.php +++ b/tests/MaxMind/Test/MinFraud/Validation/Rules/CreditCardTest.php @@ -6,7 +6,6 @@ use MaxMind\MinFraud\Validation\Rules\CreditCard; use PHPUnit\Framework\TestCase; -use Respect\Validation\Exceptions\CountryCodeException; /** * @coversNothing @@ -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, diff --git a/tests/MaxMind/Test/MinFraudTest.php b/tests/MaxMind/Test/MinFraudTest.php index fbc85d8..9ec89cc 100644 --- a/tests/MaxMind/Test/MinFraudTest.php +++ b/tests/MaxMind/Test/MinFraudTest.php @@ -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', @@ -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',