Issue Bug New Stale

#101541The data type of validator options is neither respected nor documented, the required flag is not documented

S P 08/03/23, 07:31 updated 06/12/26, 05:42

Description

When extending \TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator to write a custom validator having options, for example when doing this in combination with ext:form, one has to specifiy the $supportedOptions array inside the validator class, like so

protected $supportedOptions = [
    'optionOne' => [1, 'Some option', 'int'],
    'optionTwo' => [5, 'another option', 'int']
];

Containing the type of the value as the third array element.

When I dump what is in the final values in my options ($this->getOptions() or directly $this->options) I can see that the int cast is not happening. For example, when using this in combination with ext:form the option values come from the YAML which contains strings. So my options does contain '5' instead of 5.

Shouldn’t the configured option types in some way be respected (at least in the documentation of this API)? What I’m saying: I’m not even sure whether I just made a bug report, or even a feature request or simply reported missing/inconsistent documentation.

https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ExtensionArchitecture/Extbase/Reference/Validation/Index.html (and subpages) has nothing about it. What is the intention of this configuration? Is this a left-over or planned to be used in the future?

And the fourth flag (“option required or not”) is also not documented, but it is respected in code.

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.

Fix this issue

Start the commit message of your patch with this. Add what the patch does, and the versions it goes to in "Releases:". How to create a patch

Commit message
[BUGFIX] The data type of validator options is neither respected nor documented, the required flag is not documented Resolves: #101541 Releases: main