Skip to content

Commit

Permalink
Merge pull request #29 from mpscholten/readme-inline-exception-messages
Browse files Browse the repository at this point in the history
Update README.md
  • Loading branch information
mpscholten authored Aug 5, 2016
2 parents 73d4561 + a9b7650 commit 853388c
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 853388c

Please sign in to comment.