Skip to content

Commit

Permalink
README: updated
Browse files Browse the repository at this point in the history
  • Loading branch information
charjr committed Dec 15, 2022
1 parent 394a392 commit 932c4db
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,32 @@ To publish a copy to your own config, use the following:
php artisan vendor:publish --tag="membrane"
```

### Global Usage
### Usage

#### Request Validation

The `RequestValidation` middleware will validate or invalidate incoming requests and let you decide how to react.
You can precede it with your own custom middleware or precede it with one of the following built-in options:

#### Nested Json Response

The `ResponseJsonNested` MUST precede the `RequestValidation` middleware
as it relies on the container containing the result.
It will check whether the request has passed or failed validation.
Invalid requests will return a response detailing the reasons the request was invalid.

To validate requests for all your routes, add the `RequestValidation` middleware to `$middleware` property
of `app/Http/Kernel.php` class:
#### Flat Json Response

The `ResponseJsonFlat` MUST precede the `RequestValidation` middleware
as it relies on the container containing the result.
It will check whether the request has passed or failed validation.
Invalid requests will return a response detailing the reasons the request was invalid.

### Global Usage

```php
protected $middleware = [
\Membrane\Laravel\RequestValidation::class,
// ...
];
```

**Please note:** It is not required to be at the top of your middleware,
but it must precede anything that relies on receiving a valid request.

0 comments on commit 932c4db

Please sign in to comment.