Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
mpscholten authored Aug 2, 2016
1 parent 38ea9f1 commit a9b7650
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,22 @@ class MyController

#### Using Custom Exception Messages

##### Overriding Single Messages
If you need to override the exception message thrown by the library just once or twice, you can do this by passing the exception messages as the first and second argument to `->required()`:

```php
class DashboardController
{
public function show()
{
$dashboardId = $this->queryParameter('id')->int()->required("The dashboard id has to be a valid number", "No dashboard id given");
}
}
```

##### Overriding All Messages
If you don't want to specify a custom exception message for all your actions, but still don't want to use the built-in exception messages, you can provide your own exception message generator:

```php

class FriendlyExceptionMessageFactory extends \MPScholten\RequestParser\ExceptionMessageFactory
Expand Down

0 comments on commit a9b7650

Please sign in to comment.