From a9b7650670544b3cbbc4019459ac8e8caa254c69 Mon Sep 17 00:00:00 2001 From: Marc Scholten Date: Tue, 2 Aug 2016 20:59:13 +0200 Subject: [PATCH] Update README.md --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index 1967f0c..2ed50f5 100644 --- a/README.md +++ b/README.md @@ -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