Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ class BlogController extends ActionController
*
* @throws NoBlogAdminAccessException
*/
#[Validate([
'param' => 'blog',
'validator' => BlogValidator::class,
])]
public function updateAction(Blog $blog): ResponseInterface
{
public function updateAction(
#[Validate([
'validator' => BlogValidator::class,
])]
Blog $blog,
): ResponseInterface {
// do something
return $this->htmlResponse();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,12 @@ is applied with one argument.
.. _extbase-validation-controller:

Validation of controller arguments
===================================
==================================

.. deprecated:: 14.0
Applying controller argument validation at **method level** has been
deprecated. Define validators at **argument level** from
TYPO3 v14.

You can also define controller argument validators:

Expand All @@ -110,8 +115,12 @@ You can also define controller argument validators:
.. code-block:: php
:caption: Examples for controller argument validators

#[Validate(['validator' => 'EmailAddress', 'param' => 'email'])]
public function submitAction(string $email): ResponseInterface
public function submitAction(
#[Validate(validator: 'EmailAddress')]
string $email,
): ResponseInterface {
// Do something...
}

The following rules validate each controller argument:

Expand Down Expand Up @@ -154,5 +163,5 @@ Manually call a validator
It is possible to call a validator in your own code with the method
:php:`\TYPO3\CMS\Extbase\Validation\ValidatorResolver::createValidator()`.

However please note that the class :php:`ValidatorResolver` is marked as
However please note that the class :php-short:`\TYPO3\CMS\Extbase\Validation\ValidatorResolver` is marked as
:php:`@internal` and it is therefore not advisable to use it.