ValidatorResolver implements SingletonInterface

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

Internal

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

Table of Contents

Interfaces

SingletonInterface
"empty" interface for singletons (marker interface pattern)

Properties

$baseValidatorConjunctions  : array<string|int, mixed>
$reflectionService  : ReflectionService

Methods

__construct()  : mixed
createValidator()  : ValidatorInterface|null
Get a validator for a given data type. Returns a validator implementing the ValidatorInterface or NULL if no validator could be resolved.
getBaseValidatorConjunction()  : ConjunctionValidator
Resolves and returns the base validator conjunction for the given data type.
buildBaseValidatorConjunction()  : void
Builds a base validator conjunction for the given data type.

Properties

$baseValidatorConjunctions

protected array<string|int, mixed> $baseValidatorConjunctions = []

Methods

createValidator()

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

public createValidator(string $validatorType[, array<string|int, mixed> $validatorOptions = [] ][, ServerRequestInterface $request = null ]) : ValidatorInterface|null
Parameters
$validatorType : string

Either one of the built-in data types or fully qualified validator class name

$validatorOptions : array<string|int, mixed> = []

Options to be passed to the validator

$request : ServerRequestInterface = null

PSR-7 request object

Return values
ValidatorInterface|null

getBaseValidatorConjunction()

Resolves and returns the base validator conjunction for the given data type.

public getBaseValidatorConjunction(string $targetClassName[, ServerRequestInterface|null $request = null ]) : ConjunctionValidator

If no validator could be resolved (which usually means that no validation is necessary), NULL is returned.

Parameters
$targetClassName : string

The data type to search a validator for. Usually the fully qualified object name

$request : ServerRequestInterface|null = null
Return values
ConjunctionValidator

buildBaseValidatorConjunction()

Builds a base validator conjunction for the given data type.

protected buildBaseValidatorConjunction(ConjunctionValidator $conjunctionValidator, class-string $targetClassName, ServerRequestInterface|null $request) : void

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

Parameters
$conjunctionValidator : ConjunctionValidator
$targetClassName : class-string

The data type to build the validation conjunction for. Needs to be the fully qualified class name.

$request : ServerRequestInterface|null
Tags
throws
NoSuchValidatorException
throws
InvalidArgumentException

        
On this page

Search results