Skip to content

Commit

Permalink
Fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
arogachev committed Aug 10, 2024
1 parent dcd162b commit 08eb9bd
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ composer require yiisoft/hydrator-validator

## General usage

Validating hydrator is a [hydrator](https://github.com/yiisoft/hydrator) decorator that allows to validate
raw data before passing it to the decorated hydrator and to validate object after creating or populating it.
Validating hydrator is a decorator for [hydrator](https://github.com/yiisoft/hydrator) that allows to validate object
after creating or populating with the decorated hydrator.

To use it, the object being validated must implement `ValidatedInputInterface`. You can use `ValidatedInputTrait` to
easily create such object. The validation rules for raw values of the object are defined with `Validate` PHP attribute.
To use it, the object being validated must implement `ValidatedInputInterface`. You can use `ValidatedInputTrait` to
easily create such object. The validation rules for raw values of the object that must be validated before hydration are
defined with `Validate` PHP attribute.

Example of object:

Expand All @@ -60,7 +61,8 @@ final class InputDto implements ValidatedInputInterface
}
```

Validation result could be obtained via `getValidationResult()` method.
Validation result could be obtained via `getValidationResult()` method. For further working with result, refer to
corresponding [validator's guide section](https://github.com/yiisoft/validator/blob/master/docs/guide/en/result.md).

Validating hydrator usage example:

Expand Down
4 changes: 2 additions & 2 deletions src/Attribute/Validate.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
use Yiisoft\Validator\RuleInterface;

/**
* Added to either property or parameter to indicate that raw values should be validated. Validation rules are passed
* as arguments to the attribute.
* Added to either property or parameter to indicate that raw values should be validated. Validation rules are passed as
* arguments to the attribute.
*/
#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER | Attribute::IS_REPEATABLE)]
final class Validate implements ParameterAttributeInterface
Expand Down
3 changes: 1 addition & 2 deletions src/ValidatedInputInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
use Yiisoft\Validator\Result;

/**
* `ValidatedInputInterface` is an interface for objects that can be validated.
* It provides a method to get validation result.
* Used for objects that can be validated. It provides a method to get validation result.
*
* You can use {@see ValidatedInputTrait} to implement this interface.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/ValidatingHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Yiisoft\Validator\ValidatorInterface;

/**
* `ValidatingHydrator` is a decorator for {@see HydratorInterface} that validates data before hydration.
* `ValidatingHydrator` is a decorator for {@see HydratorInterface} that validates data after hydration.
*/
final class ValidatingHydrator implements HydratorInterface
{
Expand Down

0 comments on commit 08eb9bd

Please sign in to comment.