Skip to content

Commit 951e56a

Browse files
[FEATURE] Make validation attributes usable for method parameters (#6270)
* [FEATURE] Make validation attributes usable for method parameters Resolves: TYPO3-Documentation/Changelog-To-Doc#1488 Releases: main * [TASK] Language check Releases: main --------- Co-authored-by: Sarah McCarthy <sarahmccarthy123@yahoo.com>
1 parent d64d653 commit 951e56a

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

Documentation/ExtensionArchitecture/Extbase/Reference/Validation/CustomValidator/_ObjectValidatorUsage.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ class BlogController extends ActionController
2121
*
2222
* @throws NoBlogAdminAccessException
2323
*/
24-
#[Validate([
25-
'param' => 'blog',
26-
'validator' => BlogValidator::class,
27-
])]
28-
public function updateAction(Blog $blog): ResponseInterface
29-
{
24+
public function updateAction(
25+
#[Validate([
26+
'validator' => BlogValidator::class,
27+
])]
28+
Blog $blog,
29+
): ResponseInterface {
3030
// do something
3131
return $this->htmlResponse();
3232
}

Documentation/ExtensionArchitecture/Extbase/Reference/Validation/Index.rst

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,12 @@ is applied with one argument.
101101
.. _extbase-validation-controller:
102102

103103
Validation of controller arguments
104-
===================================
104+
==================================
105+
106+
.. deprecated:: 14.0
107+
Applying controller argument validation at **method level** has been
108+
deprecated. Define validators at **argument level** from
109+
TYPO3 v14.
105110

106111
You can also define controller argument validators:
107112

@@ -110,8 +115,12 @@ You can also define controller argument validators:
110115
.. code-block:: php
111116
:caption: Examples for controller argument validators
112117
113-
#[Validate(['validator' => 'EmailAddress', 'param' => 'email'])]
114-
public function submitAction(string $email): ResponseInterface
118+
public function submitAction(
119+
#[Validate(validator: 'EmailAddress')]
120+
string $email,
121+
): ResponseInterface {
122+
// Do something...
123+
}
115124
116125
The following rules validate each controller argument:
117126

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

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

0 commit comments

Comments
 (0)