Issue Bug Closed

#66335Can not pass options to a Domain Model Validator

Taras Zakus 04/09/15, 09:43 updated 11/21/20, 10:13

Description

In the method \TYPO3\CMS\Extbase\Validation\ValidatorResolver::addCustomValidators the corresponding Validator (based on the model name) instance is created without any options passed to it:

    protected function addCustomValidators($targetClassName, ConjunctionValidator &$conjunctionValidator) {

        $addedValidatorClassName = NULL;
        // @todo: get rid of ClassNamingUtility usage once we dropped underscored class name support
        $possibleValidatorClassName = ClassNamingUtility::translateModelNameToValidatorName($targetClassName);

        $customValidator = $this->createValidator($possibleValidatorClassName);
        if ($customValidator !== NULL) {
            $conjunctionValidator->addValidator($customValidator);
            $addedValidatorClassName = get_class($customValidator);
        }

        // @todo: find polytype validator for class
    }

So if we have a such Validator with some required options – the exception \TYPO3\CMS\Extbase\Validation\Exception\InvalidValidationOptionsException with code:1379981891 will be throwed while constructing the validator (if it extends \TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator of course).

Now the only way to avoid this, is to give some specific name to the Validator and assign it manually in the Controller.
Maybe, if there is no obvious way how to construct the Validator with an options – this method should be removed, since it doesn’t provide enough flexibility, as manual assignment does?

Reviews 0

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