generated from yiisoft/package-template
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ValidatedInputInterface::getValidatedInput()
throws exception when …
…bject is not validated (#17)
- Loading branch information
Showing
5 changed files
with
51 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
# Yii Validating Hydrator Change Log | ||
|
||
## 1.0.1 under development | ||
## 2.0.0 under development | ||
|
||
- no changes in this release. | ||
- Chg #17: Throws `LogicException` on call `ValidatedInputInterface::getValidatedInput()` method when object is not | ||
validated (@vjik) | ||
|
||
## 1.0.0 February 02, 2024 | ||
|
||
- Initial release. | ||
- Initial release. |
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,16 @@ | ||
# Upgrading Instructions for Yii Validating Hydrator | ||
|
||
## Upgrade from 1.x to 2.x | ||
|
||
If you use `ValidatedInputInterface::getValidatedInput()` on non-validated inputs or form models, wrap it with | ||
`try ... catch`: | ||
|
||
```php | ||
$result = $input->getValidatedInput(); | ||
// ↓ | ||
try { | ||
$result = $input->getValidatedInput(); | ||
} catch (LogicException) { | ||
$result = null; | ||
} | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yiisoft\Hydrator\Validator\Tests; | ||
|
||
use LogicException; | ||
use PHPUnit\Framework\TestCase; | ||
use Yiisoft\Hydrator\Validator\Tests\Support\Object\SimpleInput; | ||
|
||
final class ValidatedInputTraitTest extends TestCase | ||
{ | ||
public function testNotValidate(): void | ||
{ | ||
$input = new SimpleInput(); | ||
|
||
$this->expectException(LogicException::class); | ||
$this->expectExceptionMessage('Validation result is not set.'); | ||
$input->getValidationResult(); | ||
} | ||
} |