Skip to content
Snippets Groups Projects
Commit 7f21ba47 authored by Alexander Schnitzler's avatar Alexander Schnitzler Committed by Benni Mack
Browse files

[!!!][TASK] Do not magically register validators

This patch removes the automatical registration of two types
of validators.

- model validators
- type validators

Model validators are those validators that follow a specific
namespace and class naming derived from domain models.

Given a model \Vendor\Extension\Domain\Model\Foo, extbase searched
for a valiator \Vendor\Extension\Domain\Validator\FooValidator.

If it existed, it had been registered automatically and could not
be disabled at all.

Type validators are similiar to model validators. Given a non
model action parameter or model property like int, string, float,
DateTime and such, extbase searched for validators in the
namespace TYPO3\CMS\Extbase\Validation\Validator.

There is a TYPO3\CMS\Extbase\Validation\Validator\StringValidator
for example which had been registered for string type params and
properties.

Said validators could not be disabled at all.

There are several reasons why the automatic registration has been
removed:

- First of all, this behaviour led to an unknown amount of actual
  registered validators. Developers that are new or simply not
  familiar with the concept of validation magic could easily
  become frustrated.

- Then there is the problem that validation takes place, no matter
  if it was needed or wanted. A domain validator, which looked
  quite handy in the first place, had to be reduced to the
  validation logic that would fit all cases where according
  objects had been passed into methods. No matter the context.
  The context however matters a lot. One might want to have
  different validation rules depending on if objects are
  created, updated or deleted. This distinction was impossible
  and therefore model validators could be a burden.

- Last but not least, the automatic registration is a problem
  when introducing validation groups. Validation groups cover
  the context aspect mentioned earlier. By grouping validations
  one can create and register different validators and apply
  them given by contexts like create, update, delete and such.

Releases: master
Resolves: #87957
Change-Id: If8f590a1bedb428c8884cd61828d8cc671ee92e1
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/60298


Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: default avatarStefan Froemken <froemken@gmail.com>
Tested-by: default avatarBenni Mack <benni@typo3.org>
Reviewed-by: default avatarStefan Froemken <froemken@gmail.com>
Reviewed-by: default avatarBenni Mack <benni@typo3.org>
parent 72d857f3
No related merge requests found
Showing
with 172 additions and 151 deletions
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment