Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor docs' improvements #27

Merged
merged 5 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@ 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):

- it allows to validate raw data of properties marked with `Validate` PHP attribute before passing it to the decorated
arogachev marked this conversation as resolved.
Show resolved Hide resolved
hydrator;
- it allows to validate object after creating or populating it.

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.
Expand All @@ -60,7 +63,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
6 changes: 5 additions & 1 deletion src/ValidatingHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
use Yiisoft\Validator\ValidatorInterface;

/**
* `ValidatingHydrator` is a decorator for {@see HydratorInterface} that validates data before hydration.
* `ValidatingHydrator` is a decorator for {@see HydratorInterface}:
*
* - it allows to validate raw data of properties marked with {@see Validate} PHP attribute before passing it to the
* decorated hydrator;
* - it allows to validate object after creating or populating it.
*/
final class ValidatingHydrator implements HydratorInterface
{
Expand Down
Loading