AbstractValidator

abstract class \TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator

Implements
ValidatorInterface

Abstract validator

Table of Contents

Interfaces

ValidatorInterface
Contract for a validator

Properties

$acceptsEmptyValues  : bool
Specifies whether this validator accepts empty values.
$options  : array
$result  : Result
$supportedOptions  : array
This contains the supported options, their default values, types and descriptions.

Methods

__construct()  : mixed
Constructs the validator and sets validation options
getOptions()  : array
Returns the options of this validator
validate()  : Result
Checks if the given value is valid according to the validator, and returns the error messages object which occurred.
addError()  : mixed
Creates a new validation error object and adds it to $this->result
addErrorForProperty()  : mixed
Creates a new validation error object for a property and adds it to the proper sub result of $this->result
initializeDefaultOptions()  : void
Initialize default options.
isEmpty()  : bool
isValid()  : mixed
Check if $value is valid. If it is not valid, needs to add an error to result.
translateErrorMessage()  : string
Wrap static call to LocalizationUtility to simplify unit testing

Properties

$acceptsEmptyValues

Specifies whether this validator accepts empty values.

protected bool $acceptsEmptyValues = true

If this is TRUE, the validators isValid() method is not called in case of an empty value Note: A value is considered empty if it is NULL or an empty string! By default all validators except for NotEmpty and the Composite Validators accept empty values

$supportedOptions

This contains the supported options, their default values, types and descriptions.

protected array $supportedOptions = []

Methods

__construct()

Constructs the validator and sets validation options

public __construct([array $options = [] ]) : mixed

Parameters

$options : array = []

Options for the validator

Tags

throws
InvalidValidationOptionsException
todo:

__construct() will vanish in v12, this abstract will implement setOptions() to set and initialize default options.

getOptions()

Returns the options of this validator

public getOptions() : array

Return values

array

validate()

Checks if the given value is valid according to the validator, and returns the error messages object which occurred.

public validate(mixed $value) : Result

Parameters

$value : mixed

The value that should be validated

Return values

Result

addError()

Creates a new validation error object and adds it to $this->result

protected addError(string $message, int $code[, array $arguments = [] ][, string $title = '' ]) : mixed

Parameters

$message : string

The error message

$code : int

The error code (a unix timestamp)

$arguments : array = []

Arguments to be replaced in message

$title : string = ''

title of the error

addErrorForProperty()

Creates a new validation error object for a property and adds it to the proper sub result of $this->result

protected addErrorForProperty(mixed $propertyPath, string $message, int $code[, array $arguments = [] ][, string $title = '' ]) : mixed

Parameters

$propertyPath : mixed
$message : string

The error message

$code : int

The error code (a unix timestamp)

$arguments : array = []

Arguments to be replaced in message

$title : string = ''

title of the error

isEmpty()

protected final isEmpty(mixed $value) : bool

Parameters

$value : mixed

Return values

bool —

TRUE if the given $value is NULL or an empty string ('')

isValid()

Check if $value is valid. If it is not valid, needs to add an error to result.

protected abstract isValid(mixed $value) : mixed

Parameters

$value : mixed

translateErrorMessage()

Wrap static call to LocalizationUtility to simplify unit testing

protected translateErrorMessage(string $translateKey, string $extensionName[, array $arguments = [] ]) : string

Parameters

$translateKey : string
$extensionName : string
$arguments : array = []

Return values

string
On this page