Skip to content

Commit c20c5df

Browse files
committed
Update readme
1 parent d56f97b commit c20c5df

File tree

1 file changed

+34
-33
lines changed

1 file changed

+34
-33
lines changed

README.md

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ A validation library for PHP that uses the [notification pattern](https://martin
1616
* [Usage](#usage)
1717
* [Validating form data](#validating-form-data)
1818
* [Validating JSON](#validating-json)
19-
* [Transformer](#transformer)
2019
* [Validators](#validators)
2120
* [CakePHP Validator](#cakephp-validator)
2221
* [Symfony Validator](#symfony-validator)
22+
* [Transformer](#transformer)
23+
* [License](#license)
2324

2425
## Requirements
2526

@@ -193,7 +194,7 @@ $app->add(ValidationExceptionMiddleware::class);
193194
$app->run();
194195
```
195196

196-
#### Usage
197+
#### Usage in Slim
197198

198199
```php
199200
<?php
@@ -215,37 +216,6 @@ if ($validation->isFailed()) {
215216
}
216217
```
217218

218-
## Transformer
219-
220-
If you want to implement a custom response data structure,
221-
you can implement a custom transformer against the
222-
`\Selective\Validation\Transformer\ResultTransformerInterface` interface.
223-
224-
**Example**
225-
226-
```php
227-
<?php
228-
229-
namespace App\Transformer;
230-
231-
use Selective\Validation\Exception\ValidationException;
232-
use Selective\Validation\Transformer\ResultTransformerInterface;
233-
use Selective\Validation\ValidationResult;
234-
235-
final class MyValidationTransformer implements ResultTransformerInterface
236-
{
237-
public function transform(
238-
ValidationResult $validationResult,
239-
ValidationException $exception = null
240-
): array {
241-
// Implement your own data structure for the response
242-
// ...
243-
244-
return [];
245-
}
246-
}
247-
```
248-
249219
## Validators
250220

251221
You can combine this library with a validator that is doing the actual validation of your input data.
@@ -377,6 +347,37 @@ if ($validationResult->isFailed()) {
377347
}
378348
```
379349

350+
## Transformer
351+
352+
If you want to implement a custom response data structure,
353+
you can implement a custom transformer against the
354+
`\Selective\Validation\Transformer\ResultTransformerInterface` interface.
355+
356+
**Example**
357+
358+
```php
359+
<?php
360+
361+
namespace App\Transformer;
362+
363+
use Selective\Validation\Exception\ValidationException;
364+
use Selective\Validation\Transformer\ResultTransformerInterface;
365+
use Selective\Validation\ValidationResult;
366+
367+
final class MyValidationTransformer implements ResultTransformerInterface
368+
{
369+
public function transform(
370+
ValidationResult $validationResult,
371+
ValidationException $exception = null
372+
): array {
373+
// Implement your own data structure for the response
374+
// ...
375+
376+
return [];
377+
}
378+
}
379+
```
380+
380381
## License
381382

382383
The MIT License (MIT). Please see [License File](LICENSE) for more information.

0 commit comments

Comments
 (0)