Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
odan committed Feb 10, 2021
1 parent 3e09f00 commit b8197ac
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,14 +226,8 @@ class into instances of another class.

### CakePHP Validator

The [cakephp/validation](https://github.com/cakephp/validation) library provides features to build validators that can
validate arbitrary arrays of data with ease.

The `$validator->validate()` method will return a non-empty array when there are validation failures. The returned array
of errors then can be converted into a `ValidationResult`
using the `CakeValidationErrorCollector`.

For example, if you wanted to validate a contact form before creating and sending an email you could do the following.
The [cakephp/validation](https://github.com/cakephp/validation) library provides features
to build validators that can validate arbitrary arrays of data with ease.

**Installation**

Expand All @@ -243,10 +237,12 @@ composer require cakephp/validation

**Usage**

The `CakeValidationFactory` class to simplifies the validation handling.
Please note: In real life the `CakeValidationFactory` should be injected via constructor.
The `Cake\Validation\Validator::validate()` method returns a non-empty array when
there are validation failures. The list of errors then can be converted into
a `ValidationResult` using the `Selective\Validation\Factory\CakeValidationFactory`
or `Selective\Validation\Converter\CakeValidationConverter`.

**Factory usage**
For example, if you want to validate a login form you could do the following:

```php
use Selective\Validation\Factory\CakeValidationFactory;
Expand All @@ -273,6 +269,8 @@ if ($validationResult->fails()) {
}
```

Please note: The `CakeValidationFactory` should be injected via constructor.

**Read more:** <https://odan.github.io/2020/10/18/slim4-cakephp-validation.html>

### Symfony Validator
Expand Down

0 comments on commit b8197ac

Please sign in to comment.