diff --git a/repo/rest-api/src/Application/UseCaseRequestValidation/ItemDescriptionEditRequestValidatingDeserializer.php b/repo/rest-api/src/Application/UseCaseRequestValidation/ItemDescriptionEditRequestValidatingDeserializer.php index 10337eaffca..3c724e8283b 100644 --- a/repo/rest-api/src/Application/UseCaseRequestValidation/ItemDescriptionEditRequestValidatingDeserializer.php +++ b/repo/rest-api/src/Application/UseCaseRequestValidation/ItemDescriptionEditRequestValidatingDeserializer.php @@ -37,7 +37,7 @@ public function validateAndDeserialize( ItemDescriptionEditRequest $request ): T case ItemDescriptionValidator::CODE_INVALID: throw new UseCaseError( UseCaseError::INVALID_DESCRIPTION, - "Not a valid description: {$context[ItemDescriptionValidator::CONTEXT_VALUE]}" + "Not a valid description: {$context[ItemDescriptionValidator::CONTEXT_DESCRIPTION]}" ); case ItemDescriptionValidator::CODE_EMPTY: throw new UseCaseError( @@ -50,7 +50,7 @@ public function validateAndDeserialize( ItemDescriptionEditRequest $request ): T UseCaseError::DESCRIPTION_TOO_LONG, "Description must be no more than $limit characters long", [ - UseCaseError::CONTEXT_VALUE => $context[ItemDescriptionValidator::CONTEXT_VALUE], + UseCaseError::CONTEXT_VALUE => $context[ItemDescriptionValidator::CONTEXT_DESCRIPTION], UseCaseError::CONTEXT_CHARACTER_LIMIT => $limit, ] ); diff --git a/repo/rest-api/src/Application/UseCaseRequestValidation/ItemLabelEditRequestValidatingDeserializer.php b/repo/rest-api/src/Application/UseCaseRequestValidation/ItemLabelEditRequestValidatingDeserializer.php index 790b4ac3a40..313758d4d50 100644 --- a/repo/rest-api/src/Application/UseCaseRequestValidation/ItemLabelEditRequestValidatingDeserializer.php +++ b/repo/rest-api/src/Application/UseCaseRequestValidation/ItemLabelEditRequestValidatingDeserializer.php @@ -34,7 +34,7 @@ public function validateAndDeserialize( ItemLabelEditRequest $request ): Term { case ItemLabelValidator::CODE_INVALID: throw new UseCaseError( UseCaseError::INVALID_LABEL, - "Not a valid label: {$context[ItemLabelValidator::CONTEXT_VALUE]}" + "Not a valid label: {$context[ItemLabelValidator::CONTEXT_LABEL]}" ); case ItemLabelValidator::CODE_EMPTY: throw new UseCaseError( UseCaseError::LABEL_EMPTY, 'Label must not be empty' ); @@ -44,7 +44,7 @@ public function validateAndDeserialize( ItemLabelEditRequest $request ): Term { UseCaseError::LABEL_TOO_LONG, "Label must be no more than $maxLabelLength characters long", [ - UseCaseError::CONTEXT_VALUE => $context[ItemLabelValidator::CONTEXT_VALUE], + UseCaseError::CONTEXT_VALUE => $context[ItemLabelValidator::CONTEXT_LABEL], UseCaseError::CONTEXT_CHARACTER_LIMIT => $maxLabelLength, ] ); diff --git a/repo/rest-api/src/Application/UseCases/PatchItemDescriptions/PatchedDescriptionsValidator.php b/repo/rest-api/src/Application/UseCases/PatchItemDescriptions/PatchedDescriptionsValidator.php index 39eb2079ce4..beeee6ab1b2 100644 --- a/repo/rest-api/src/Application/UseCases/PatchItemDescriptions/PatchedDescriptionsValidator.php +++ b/repo/rest-api/src/Application/UseCases/PatchItemDescriptions/PatchedDescriptionsValidator.php @@ -101,7 +101,7 @@ private function validateDescription( ItemId $itemId, Term $description ): void $context = $validationError->getContext(); switch ( $validationError->getCode() ) { case ItemDescriptionValidator::CODE_INVALID: - $descriptionText = $context[ ItemDescriptionValidator::CONTEXT_VALUE ]; + $descriptionText = $context[ ItemDescriptionValidator::CONTEXT_DESCRIPTION ]; throw new UseCaseError( UseCaseError::PATCHED_DESCRIPTION_INVALID, "Changed description for '{$description->getLanguageCode()}' is invalid: $descriptionText", @@ -118,7 +118,7 @@ private function validateDescription( ItemId $itemId, Term $description ): void "Changed description for '$languageCode' must not be more than $maxDescriptionLength characters long", [ UseCaseError::CONTEXT_LANGUAGE => $languageCode, - UseCaseError::CONTEXT_VALUE => $context[ ItemDescriptionValidator::CONTEXT_VALUE ], + UseCaseError::CONTEXT_VALUE => $context[ ItemDescriptionValidator::CONTEXT_DESCRIPTION ], UseCaseError::CONTEXT_CHARACTER_LIMIT => $context[ ItemDescriptionValidator::CONTEXT_LIMIT ], ] ); diff --git a/repo/rest-api/src/Application/UseCases/PatchItemLabels/PatchedLabelsValidator.php b/repo/rest-api/src/Application/UseCases/PatchItemLabels/PatchedLabelsValidator.php index 69a346ed2d8..7f7d1fc2293 100644 --- a/repo/rest-api/src/Application/UseCases/PatchItemLabels/PatchedLabelsValidator.php +++ b/repo/rest-api/src/Application/UseCases/PatchItemLabels/PatchedLabelsValidator.php @@ -108,7 +108,7 @@ private function validateLabel( ItemId $itemId, Term $label ): void { "Changed label for '{$label->getLanguageCode()}' must not be more than $maxLabelLength characters long", [ UseCaseError::CONTEXT_LANGUAGE => $label->getLanguageCode(), - UseCaseError::CONTEXT_VALUE => $context[ItemLabelValidator::CONTEXT_VALUE], + UseCaseError::CONTEXT_VALUE => $context[ItemLabelValidator::CONTEXT_LABEL], UseCaseError::CONTEXT_CHARACTER_LIMIT => $context[ItemLabelValidator::CONTEXT_LIMIT], ] ); diff --git a/repo/rest-api/src/Application/Validation/ItemDescriptionValidator.php b/repo/rest-api/src/Application/Validation/ItemDescriptionValidator.php index c4caf3a786d..5a29c0f77a8 100644 --- a/repo/rest-api/src/Application/Validation/ItemDescriptionValidator.php +++ b/repo/rest-api/src/Application/Validation/ItemDescriptionValidator.php @@ -15,7 +15,6 @@ interface ItemDescriptionValidator { public const CODE_LABEL_DESCRIPTION_EQUAL = 'label-description-equal'; public const CODE_LABEL_DESCRIPTION_DUPLICATE = 'label-description-duplicate'; - public const CONTEXT_VALUE = 'value'; public const CONTEXT_LIMIT = 'character-limit'; public const CONTEXT_LANGUAGE = 'language'; public const CONTEXT_LABEL = 'label'; diff --git a/repo/rest-api/src/Application/Validation/ItemLabelValidator.php b/repo/rest-api/src/Application/Validation/ItemLabelValidator.php index 8e42968f671..14c252cb702 100644 --- a/repo/rest-api/src/Application/Validation/ItemLabelValidator.php +++ b/repo/rest-api/src/Application/Validation/ItemLabelValidator.php @@ -19,7 +19,6 @@ interface ItemLabelValidator { public const CONTEXT_LABEL = 'label'; public const CONTEXT_DESCRIPTION = 'description'; public const CONTEXT_MATCHING_ITEM_ID = 'matching-item-id'; - public const CONTEXT_VALUE = 'value'; public const CONTEXT_LIMIT = 'character-limit'; public function validate( ItemId $itemId, string $language, string $label ): ?ValidationError; diff --git a/repo/rest-api/src/Infrastructure/TermValidatorFactoryLabelTextValidator.php b/repo/rest-api/src/Infrastructure/TermValidatorFactoryLabelTextValidator.php index 5230300ed2c..05ac6845a7e 100644 --- a/repo/rest-api/src/Infrastructure/TermValidatorFactoryLabelTextValidator.php +++ b/repo/rest-api/src/Infrastructure/TermValidatorFactoryLabelTextValidator.php @@ -31,14 +31,14 @@ public function validate( string $labelText ): ?ValidationError { return new ValidationError( ItemLabelValidator::CODE_TOO_LONG, [ - ItemLabelValidator::CONTEXT_VALUE => $labelText, + ItemLabelValidator::CONTEXT_LABEL => $labelText, ItemLabelValidator::CONTEXT_LIMIT => $error->getParameters()[0], ] ); default: return new ValidationError( ItemLabelValidator::CODE_INVALID, - [ ItemLabelValidator::CONTEXT_VALUE => $labelText ] + [ ItemLabelValidator::CONTEXT_LABEL => $labelText ] ); } } diff --git a/repo/rest-api/src/Infrastructure/WikibaseRepoItemDescriptionValidator.php b/repo/rest-api/src/Infrastructure/WikibaseRepoItemDescriptionValidator.php index 528f8c59888..dc35c8049aa 100644 --- a/repo/rest-api/src/Infrastructure/WikibaseRepoItemDescriptionValidator.php +++ b/repo/rest-api/src/Infrastructure/WikibaseRepoItemDescriptionValidator.php @@ -46,14 +46,14 @@ private function validateDescription( string $description ): ?ValidationError { return new ValidationError( self::CODE_TOO_LONG, [ - self::CONTEXT_VALUE => $description, + self::CONTEXT_DESCRIPTION => $description, self::CONTEXT_LIMIT => $error->getParameters()[0], ] ); default: return new ValidationError( self::CODE_INVALID, - [ self::CONTEXT_VALUE => $description ] + [ self::CONTEXT_DESCRIPTION => $description ] ); } } diff --git a/repo/rest-api/tests/phpunit/Application/UseCaseRequestValidation/ItemDescriptionEditRequestValidatingDeserializerTest.php b/repo/rest-api/tests/phpunit/Application/UseCaseRequestValidation/ItemDescriptionEditRequestValidatingDeserializerTest.php index cb9b8e97ebe..b86297a5814 100644 --- a/repo/rest-api/tests/phpunit/Application/UseCaseRequestValidation/ItemDescriptionEditRequestValidatingDeserializerTest.php +++ b/repo/rest-api/tests/phpunit/Application/UseCaseRequestValidation/ItemDescriptionEditRequestValidatingDeserializerTest.php @@ -74,7 +74,7 @@ public static function invalidDescriptionProvider(): Generator { new ValidationError( ItemDescriptionValidator::CODE_TOO_LONG, [ - ItemDescriptionValidator::CONTEXT_VALUE => $description, + ItemDescriptionValidator::CONTEXT_DESCRIPTION => $description, ItemDescriptionValidator::CONTEXT_LIMIT => $limit, ] ), @@ -90,7 +90,7 @@ public static function invalidDescriptionProvider(): Generator { yield 'invalid description' => [ new ValidationError( ItemDescriptionValidator::CODE_INVALID, - [ ItemDescriptionValidator::CONTEXT_VALUE => $description ], + [ ItemDescriptionValidator::CONTEXT_DESCRIPTION => $description ], ), UseCaseError::INVALID_DESCRIPTION, "Not a valid description: $description", diff --git a/repo/rest-api/tests/phpunit/Application/UseCaseRequestValidation/ItemLabelEditRequestValidatingDeserializerTest.php b/repo/rest-api/tests/phpunit/Application/UseCaseRequestValidation/ItemLabelEditRequestValidatingDeserializerTest.php index 7029cc1f9bd..72ac6e3b745 100644 --- a/repo/rest-api/tests/phpunit/Application/UseCaseRequestValidation/ItemLabelEditRequestValidatingDeserializerTest.php +++ b/repo/rest-api/tests/phpunit/Application/UseCaseRequestValidation/ItemLabelEditRequestValidatingDeserializerTest.php @@ -66,7 +66,7 @@ public static function invalidLabelProvider(): Generator { yield 'invalid label' => [ new ValidationError( ItemLabelValidator::CODE_INVALID, - [ ItemLabelValidator::CONTEXT_VALUE => $label ], + [ ItemLabelValidator::CONTEXT_LABEL => $label ], ), UseCaseError::INVALID_LABEL, "Not a valid label: $label", @@ -82,7 +82,7 @@ public static function invalidLabelProvider(): Generator { $limit = 250; yield 'label too long' => [ new ValidationError( ItemLabelValidator::CODE_TOO_LONG, [ - ItemLabelValidator::CONTEXT_VALUE => $label, + ItemLabelValidator::CONTEXT_LABEL => $label, ItemLabelValidator::CONTEXT_LIMIT => $limit, ] ), UseCaseError::LABEL_TOO_LONG, diff --git a/repo/rest-api/tests/phpunit/Application/UseCases/PatchItemDescriptions/PatchedDescriptionsValidatorTest.php b/repo/rest-api/tests/phpunit/Application/UseCases/PatchItemDescriptions/PatchedDescriptionsValidatorTest.php index b1697b0b059..3cb4d9bfe65 100644 --- a/repo/rest-api/tests/phpunit/Application/UseCases/PatchItemDescriptions/PatchedDescriptionsValidatorTest.php +++ b/repo/rest-api/tests/phpunit/Application/UseCases/PatchItemDescriptions/PatchedDescriptionsValidatorTest.php @@ -114,7 +114,7 @@ public static function invalidDescriptionsProvider(): Generator { [ $language => $description ], new ValidationError( ItemDescriptionValidator::CODE_INVALID, - [ ItemDescriptionValidator::CONTEXT_VALUE => $description ], + [ ItemDescriptionValidator::CONTEXT_DESCRIPTION => $description ], ), UseCaseError::PATCHED_DESCRIPTION_INVALID, "Changed description for '$language' is invalid: {$description}", @@ -130,7 +130,7 @@ public static function invalidDescriptionsProvider(): Generator { new ValidationError( ItemDescriptionValidator::CODE_TOO_LONG, [ - ItemDescriptionValidator::CONTEXT_VALUE => $tooLongDescription, + ItemDescriptionValidator::CONTEXT_DESCRIPTION => $tooLongDescription, ItemDescriptionValidator::CONTEXT_LIMIT => 250, ItemDescriptionValidator::CONTEXT_LANGUAGE => $language, ] diff --git a/repo/rest-api/tests/phpunit/Application/UseCases/PatchItemLabels/PatchedLabelsValidatorTest.php b/repo/rest-api/tests/phpunit/Application/UseCases/PatchItemLabels/PatchedLabelsValidatorTest.php index 94de0a6aae9..ada73230c4a 100644 --- a/repo/rest-api/tests/phpunit/Application/UseCases/PatchItemLabels/PatchedLabelsValidatorTest.php +++ b/repo/rest-api/tests/phpunit/Application/UseCases/PatchItemLabels/PatchedLabelsValidatorTest.php @@ -114,7 +114,7 @@ public static function invalidLabelsProvider(): Generator { [ $language => $label ], new ValidationError( ItemLabelValidator::CODE_INVALID, - [ ItemLabelValidator::CONTEXT_VALUE => $label ], + [ ItemLabelValidator::CONTEXT_LABEL => $label ], ), UseCaseError::PATCHED_LABEL_INVALID, "Changed label for '$language' is invalid: {$label}", @@ -130,7 +130,7 @@ public static function invalidLabelsProvider(): Generator { new ValidationError( ItemLabelValidator::CODE_TOO_LONG, [ - ItemLabelValidator::CONTEXT_VALUE => $tooLongLabel, + ItemLabelValidator::CONTEXT_LABEL => $tooLongLabel, ItemLabelValidator::CONTEXT_LIMIT => 250, ItemLabelValidator::CONTEXT_LANGUAGE => $language, ] diff --git a/repo/rest-api/tests/phpunit/Infrastructure/TermValidatorFactoryLabelTextValidatorTest.php b/repo/rest-api/tests/phpunit/Infrastructure/TermValidatorFactoryLabelTextValidatorTest.php index ae7a3c330eb..63636ff9606 100644 --- a/repo/rest-api/tests/phpunit/Infrastructure/TermValidatorFactoryLabelTextValidatorTest.php +++ b/repo/rest-api/tests/phpunit/Infrastructure/TermValidatorFactoryLabelTextValidatorTest.php @@ -33,16 +33,16 @@ public function testEmptyLabel_returnsValidationError(): void { } public function testLabelTooLong_returnsValidationError(): void { - $tooLonglabel = str_repeat( 'a', self::MAX_LENGTH + 1 ); + $tooLongLabel = str_repeat( 'a', self::MAX_LENGTH + 1 ); $this->assertEquals( new ValidationError( ItemLabelValidator::CODE_TOO_LONG, [ - ItemLabelValidator::CONTEXT_VALUE => $tooLonglabel, + ItemLabelValidator::CONTEXT_LABEL => $tooLongLabel, ItemLabelValidator::CONTEXT_LIMIT => self::MAX_LENGTH, ] ), - $this->newValidator()->validate( $tooLonglabel ) + $this->newValidator()->validate( $tooLongLabel ) ); } @@ -51,7 +51,7 @@ public function testInvalidLabel_returnsValidationError(): void { $this->assertEquals( new ValidationError( ItemLabelValidator::CODE_INVALID, - [ ItemLabelValidator::CONTEXT_VALUE => $invalidLabel ] + [ ItemLabelValidator::CONTEXT_LABEL => $invalidLabel ] ), $this->newValidator()->validate( $invalidLabel ) ); diff --git a/repo/rest-api/tests/phpunit/Infrastructure/WikibaseRepoItemDescriptionValidatorTest.php b/repo/rest-api/tests/phpunit/Infrastructure/WikibaseRepoItemDescriptionValidatorTest.php index fd39ec3e2bd..644e0a9a311 100644 --- a/repo/rest-api/tests/phpunit/Infrastructure/WikibaseRepoItemDescriptionValidatorTest.php +++ b/repo/rest-api/tests/phpunit/Infrastructure/WikibaseRepoItemDescriptionValidatorTest.php @@ -95,7 +95,7 @@ public static function provideInvalidDescription(): Generator { $description, ItemDescriptionValidator::CODE_TOO_LONG, [ - ItemDescriptionValidator::CONTEXT_VALUE => $description, + ItemDescriptionValidator::CONTEXT_DESCRIPTION => $description, ItemDescriptionValidator::CONTEXT_LIMIT => self::MAX_LENGTH, ], ]; @@ -104,7 +104,7 @@ public static function provideInvalidDescription(): Generator { yield 'description has invalid character' => [ $description, ItemDescriptionValidator::CODE_INVALID, - [ ItemDescriptionValidator::CONTEXT_VALUE => $description ], + [ ItemDescriptionValidator::CONTEXT_DESCRIPTION => $description ], ]; }