-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge "REST: Use term type specific validators"
- Loading branch information
Showing
32 changed files
with
197 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
repo/rest-api/src/Application/Validation/AliasLanguageCodeValidator.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php declare( strict_types=1 ); | ||
|
||
namespace Wikibase\Repo\RestApi\Application\Validation; | ||
|
||
/** | ||
* @license GPL-2.0-or-later | ||
*/ | ||
interface AliasLanguageCodeValidator extends LanguageCodeValidator { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
repo/rest-api/src/Application/Validation/LabelLanguageCodeValidator.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php declare( strict_types=1 ); | ||
|
||
namespace Wikibase\Repo\RestApi\Application\Validation; | ||
|
||
/** | ||
* @license GPL-2.0-or-later | ||
*/ | ||
interface LabelLanguageCodeValidator extends LanguageCodeValidator { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 0 additions & 32 deletions
32
repo/rest-api/src/Infrastructure/TermValidatorFactoryDescriptionLanguageCodeValidator.php
This file was deleted.
Oops, something went wrong.
35 changes: 35 additions & 0 deletions
35
repo/rest-api/src/Infrastructure/ValueValidatorLanguageCodeValidator.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php declare( strict_types=1 ); | ||
|
||
namespace Wikibase\Repo\RestApi\Infrastructure; | ||
|
||
use ValueValidators\ValueValidator; | ||
use Wikibase\Repo\RestApi\Application\Validation\AliasLanguageCodeValidator; | ||
use Wikibase\Repo\RestApi\Application\Validation\DescriptionLanguageCodeValidator; | ||
use Wikibase\Repo\RestApi\Application\Validation\LabelLanguageCodeValidator; | ||
use Wikibase\Repo\RestApi\Application\Validation\ValidationError; | ||
|
||
/** | ||
* @license GPL-2.0-or-later | ||
*/ | ||
class ValueValidatorLanguageCodeValidator | ||
implements LabelLanguageCodeValidator, DescriptionLanguageCodeValidator, AliasLanguageCodeValidator { | ||
|
||
private ValueValidator $validator; | ||
|
||
public function __construct( ValueValidator $validator ) { | ||
$this->validator = $validator; | ||
} | ||
|
||
public function validate( string $language ): ?ValidationError { | ||
$result = $this->validator->validate( $language ); | ||
if ( !$result->isValid() ) { | ||
return new ValidationError( | ||
self::CODE_INVALID_LANGUAGE_CODE, | ||
[ self::CONTEXT_LANGUAGE_CODE => $language ] | ||
); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
} |
Oops, something went wrong.