Project

General

Profile

Actions

Bug #101541

open

The type of validator options is not respected

Added by S P over 1 year ago. Updated 9 months ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
Extbase
Target version:
-
Start date:
2023-08-03
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
12
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

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/Domain/Validator.html has nothing about it. What is the intention of this configuration? Is this a left-over or planned to be used in the future?

Actions

Also available in: Atom PDF