‪TYPO3CMS  ‪main
TYPO3\CMS\Extbase\Validation\ValidatorResolver Class Reference
Inheritance diagram for TYPO3\CMS\Extbase\Validation\ValidatorResolver:

Public Member Functions

 __construct (protected readonly ReflectionService $reflectionService)
 createValidator (string $validatorType, array $validatorOptions=[])
 getBaseValidatorConjunction (string $targetClassName)

Protected Member Functions

 buildBaseValidatorConjunction (ConjunctionValidator $conjunctionValidator, string $targetClassName)

Protected Attributes

array $baseValidatorConjunctions = []

Detailed Description

Validator resolver to automatically find an appropriate validator for a given subject.

only to be used within Extbase, not part of TYPO3 Core API.

Definition at line 37 of file ValidatorResolver.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Extbase\Validation\ValidatorResolver::__construct ( protected readonly ReflectionService  $reflectionService)

Definition at line 41 of file ValidatorResolver.php.

Member Function Documentation

◆ buildBaseValidatorConjunction()

TYPO3\CMS\Extbase\Validation\ValidatorResolver::buildBaseValidatorConjunction ( ConjunctionValidator  $conjunctionValidator,
string  $targetClassName 

Builds a base validator conjunction for the given data type.

The base validation rules are those which were declared directly in a class (typically a model) through some validate annotations on properties.

If a property holds a class for which a base validator exists, that property will be checked as well, regardless of a validation annotation.

Additionally, if a custom validator was defined for the class in question, it will be added to the end of the conjunction. A custom validator is found if it follows the naming convention "Replace '\Model\' by '\Validator\' and append 'Validator'".

Example: $targetClassName is TYPO3\Foo\Domain\Model\Quux, then the validator will be found if it has the name TYPO3\Foo\Domain\Validator\QuuxValidator

class-string$targetClassName‪The data type to build the validation conjunction for. Needs to be the fully qualified class name.

Definition at line 103 of file ValidatorResolver.php.

References TYPO3\CMS\Extbase\Validation\Validator\AbstractCompositeValidator\addValidator(), TYPO3\CMS\Extbase\Validation\ValidatorResolver\createValidator(), TYPO3\CMS\Extbase\Validation\ValidatorResolver\getBaseValidatorConjunction(), TYPO3\CMS\Extbase\Utility\TypeHandlingUtility\isCoreType(), and TYPO3\CMS\Extbase\Utility\TypeHandlingUtility\isSimpleType().

Referenced by TYPO3\CMS\Extbase\Validation\ValidatorResolver\getBaseValidatorConjunction().

◆ createValidator()

TYPO3\CMS\Extbase\Validation\ValidatorResolver::createValidator ( string  $validatorType,
array  $validatorOptions = [] 

Get a validator for a given data type. Returns a validator implementing the ValidatorInterface or NULL if no validator could be resolved.

string$validatorType‪Either one of the built-in data types or fully qualified validator class name
array$validatorOptions‪Options to be passed to the validator

Definition at line 50 of file ValidatorResolver.php.

References $validator, and TYPO3\CMS\Extbase\Validation\ValidatorClassNameResolver\resolve().

Referenced by TYPO3\CMS\Form\Mvc\ProcessingRule\__construct(), and TYPO3\CMS\Extbase\Validation\ValidatorResolver\buildBaseValidatorConjunction().

◆ getBaseValidatorConjunction()

TYPO3\CMS\Extbase\Validation\ValidatorResolver::getBaseValidatorConjunction ( string  $targetClassName)

Resolves and returns the base validator conjunction for the given data type. If no validator could be resolved (which usually means that no validation is necessary), NULL is returned.

string$targetClassName‪The data type to search a validator for. Usually the fully qualified object name

Definition at line 70 of file ValidatorResolver.php.

References TYPO3\CMS\Extbase\Validation\ValidatorResolver\buildBaseValidatorConjunction(), and TYPO3\CMS\Extbase\Utility\TypeHandlingUtility\isSimpleType().

Referenced by TYPO3\CMS\Extbase\Validation\ValidatorResolver\buildBaseValidatorConjunction().

Member Data Documentation

◆ $baseValidatorConjunctions

array TYPO3\CMS\Extbase\Validation\ValidatorResolver::$baseValidatorConjunctions = []

Definition at line 39 of file ValidatorResolver.php.