Skip to content

Commit dd3f803

Browse files
committed
[Messenger] Document the validation middleware
1 parent 66ad276 commit dd3f803

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

messenger.rst

+8
Original file line numberDiff line numberDiff line change
@@ -2256,6 +2256,7 @@ when building absolute URLs.
22562256
command_bus:
22572257
middleware:
22582258
- router_context
2259+
- validation
22592260
22602261
.. code-block:: xml
22612262
@@ -2273,6 +2274,7 @@ when building absolute URLs.
22732274
<framework:messenger>
22742275
<framework:bus name="command_bus">
22752276
<framework:middleware id="router_context"/>
2277+
<framework:middleware id="validation"/>
22762278
</framework:bus>
22772279
</framework:messenger>
22782280
</framework:config>
@@ -2288,9 +2290,15 @@ when building absolute URLs.
22882290
22892291
$bus = $messenger->bus('command_bus');
22902292
$bus->middleware()->id('router_context');
2293+
$bus->middleware()->id('validation');
22912294
};
22922295
22932296
2297+
Add the ``validation`` middleware if you need to validate the message object before handling it.
2298+
Internally it uses the Symfony's validator. If validation fails, a ``ValidationFailedException``
2299+
will be thrown that you can catch and read errors from.
2300+
2301+
22942302
Messenger Events
22952303
~~~~~~~~~~~~~~~~
22962304

0 commit comments

Comments
 (0)