‪TYPO3CMS  11.5
TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator Class Reference
Inheritance diagram for TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator:
TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface ExtbaseTeam\ActionControllerArgumentTest\Domain\Validation\Validator\FailingValidator ExtbaseTeam\BlogExample\Domain\Validator\PostValidator ExtbaseTeam\TestValidators\Validation\Validator\CustomNotInjectableValidator ExtbaseTeam\TestValidators\Validation\Validator\CustomValidator TYPO3\CMS\Extbase\Tests\Functional\Mvc\Controller\Fixture\Validation\Validator\CustomValidator TYPO3\CMS\Extbase\Tests\Unit\Validation\Fixtures\Validation\Validator\CustomValidator TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\Fixture\AbstractValidatorClass TYPO3\CMS\Extbase\Validation\Validator\AlphanumericValidator TYPO3\CMS\Extbase\Validation\Validator\BooleanValidator TYPO3\CMS\Extbase\Validation\Validator\DateTimeValidator TYPO3\CMS\Extbase\Validation\Validator\EmailAddressValidator TYPO3\CMS\Extbase\Validation\Validator\FloatValidator TYPO3\CMS\Extbase\Validation\Validator\GenericObjectValidator TYPO3\CMS\Extbase\Validation\Validator\IntegerValidator TYPO3\CMS\Extbase\Validation\Validator\NotEmptyValidator TYPO3\CMS\Extbase\Validation\Validator\NumberRangeValidator TYPO3\CMS\Extbase\Validation\Validator\NumberValidator TYPO3\CMS\Extbase\Validation\Validator\RegularExpressionValidator TYPO3\CMS\Extbase\Validation\Validator\StringLengthValidator TYPO3\CMS\Extbase\Validation\Validator\StringValidator TYPO3\CMS\Extbase\Validation\Validator\TextValidator TYPO3\CMS\Extbase\Validation\Validator\UrlValidator TYPO3\CMS\Form\Mvc\Validation\CountValidator TYPO3\CMS\Form\Mvc\Validation\DateRangeValidator TYPO3\CMS\Form\Mvc\Validation\EmptyValidator TYPO3\CMS\Form\Mvc\Validation\FileSizeValidator TYPO3\CMS\Form\Mvc\Validation\MimeTypeValidator TYPO3\CMS\Form\Tests\Unit\Mvc\Fixtures\AnotherTestValidator TYPO3\CMS\Form\Tests\Unit\Mvc\Validation\Fixtures\TestValidator

Public Member Functions

 __construct (array $options=[])
 
TYPO3 CMS Extbase Error Result validate ($value)
 
array getOptions ()
 

Protected Member Functions

 isValid ($value)
 
 addError ($message, $code, array $arguments=[], $title='')
 
 addErrorForProperty ($propertyPath, $message, $code, array $arguments=[], $title='')
 
bool isEmpty ($value)
 
string translateErrorMessage ($translateKey, $extensionName, $arguments=[])
 
 initializeDefaultOptions (array $options)
 

Protected Attributes

bool $acceptsEmptyValues = true
 
array $supportedOptions = array( )
 
array $options = array( )
 
TYPO3 CMS Extbase Error Result $result
 

Detailed Description

Abstract validator

Definition at line 26 of file AbstractValidator.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator::__construct ( array  $options = [])

Constructs the validator and sets validation options

Parameters
array$options‪Options for the validator
Exceptions
InvalidValidationOptionsException
Todo:
‪: __construct() will vanish in v12, this abstract will implement setOptions() to set and initialize default options.

Reimplemented in TYPO3\CMS\Extbase\Validation\Validator\CollectionValidator, and ExtbaseTeam\TestValidators\Validation\Validator\CustomValidator.

Definition at line 59 of file AbstractValidator.php.

References TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator\initializeDefaultOptions().

Member Function Documentation

◆ addError()

TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator::addError (   $message,
  $code,
array  $arguments = [],
  $title = '' 
)
protected

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

Parameters
string$message‪The error message
int$code‪The error code (a unix timestamp)
array$arguments‪Arguments to be replaced in message
string$title‪title of the error

Definition at line 96 of file AbstractValidator.php.

Referenced by TYPO3\CMS\Extbase\Validation\Validator\AlphanumericValidator\isValid(), TYPO3\CMS\Extbase\Validation\Validator\IntegerValidator\isValid(), TYPO3\CMS\Extbase\Validation\Validator\NumberValidator\isValid(), TYPO3\CMS\Extbase\Validation\Validator\FloatValidator\isValid(), TYPO3\CMS\Extbase\Validation\Validator\StringValidator\isValid(), TYPO3\CMS\Extbase\Validation\Validator\DateTimeValidator\isValid(), ExtbaseTeam\ActionControllerArgumentTest\Domain\Validation\Validator\FailingValidator\isValid(), TYPO3\CMS\Extbase\Validation\Validator\EmailAddressValidator\isValid(), TYPO3\CMS\Form\Tests\Unit\Mvc\Fixtures\AnotherTestValidator\isValid(), TYPO3\CMS\Form\Tests\Unit\Mvc\Validation\Fixtures\TestValidator\isValid(), TYPO3\CMS\Extbase\Validation\Validator\UrlValidator\isValid(), TYPO3\CMS\Extbase\Validation\Validator\TextValidator\isValid(), TYPO3\CMS\Extbase\Validation\Validator\NotEmptyValidator\isValid(), TYPO3\CMS\Extbase\Validation\Validator\NumberRangeValidator\isValid(), TYPO3\CMS\Extbase\Validation\Validator\RegularExpressionValidator\isValid(), TYPO3\CMS\Extbase\Validation\Validator\StringLengthValidator\isValid(), TYPO3\CMS\Form\Mvc\Validation\EmptyValidator\isValid(), TYPO3\CMS\Form\Mvc\Validation\DateRangeValidator\isValid(), TYPO3\CMS\Extbase\Validation\Validator\BooleanValidator\isValid(), TYPO3\CMS\Form\Mvc\Validation\CountValidator\isValid(), TYPO3\CMS\Form\Mvc\Validation\FileSizeValidator\isValid(), TYPO3\CMS\Form\Mvc\Validation\MimeTypeValidator\isValid(), TYPO3\CMS\Extbase\Validation\Validator\GenericObjectValidator\validate(), and TYPO3\CMS\Extbase\Validation\Validator\CollectionValidator\validate().

◆ addErrorForProperty()

TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator::addErrorForProperty (   $propertyPath,
  $message,
  $code,
array  $arguments = [],
  $title = '' 
)
protected

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

Parameters
string | array$message‪The property path (string or array)
string$message‪The error message
int$code‪The error code (a unix timestamp)
array$arguments‪Arguments to be replaced in message
string$title‪title of the error

Definition at line 110 of file AbstractValidator.php.

◆ getOptions()

array TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator::getOptions ( )

Returns the options of this validator

Returns
‪array

Implements TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface.

Definition at line 122 of file AbstractValidator.php.

References TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator\$options.

◆ initializeDefaultOptions()

TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator::initializeDefaultOptions ( array  $options)
protected

◆ isEmpty()

bool TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator::isEmpty (   $value)
finalprotected

◆ isValid()

TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator::isValid (   $value)
abstractprotected

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

Parameters
mixed$value

Reimplemented in TYPO3\CMS\Extbase\Validation\Validator\CollectionValidator, ExtbaseTeam\TestValidators\Validation\Validator\CustomValidator, TYPO3\CMS\Form\Mvc\Validation\CountValidator, TYPO3\CMS\Extbase\Validation\Validator\BooleanValidator, TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\Fixture\AbstractValidatorClass, TYPO3\CMS\Form\Mvc\Validation\DateRangeValidator, TYPO3\CMS\Form\Mvc\Validation\EmptyValidator, TYPO3\CMS\Extbase\Validation\Validator\StringLengthValidator, TYPO3\CMS\Extbase\Validation\Validator\RegularExpressionValidator, TYPO3\CMS\Extbase\Validation\Validator\NotEmptyValidator, TYPO3\CMS\Extbase\Validation\Validator\NumberRangeValidator, ExtbaseTeam\BlogExample\Domain\Validator\PostValidator, ExtbaseTeam\TestValidators\Validation\Validator\CustomNotInjectableValidator, TYPO3\CMS\Extbase\Validation\Validator\TextValidator, TYPO3\CMS\Extbase\Validation\Validator\UrlValidator, TYPO3\CMS\Extbase\Validation\Validator\EmailAddressValidator, ExtbaseTeam\ActionControllerArgumentTest\Domain\Validation\Validator\FailingValidator, TYPO3\CMS\Extbase\Tests\Functional\Mvc\Controller\Fixture\Validation\Validator\CustomValidator, TYPO3\CMS\Form\Tests\Unit\Mvc\Fixtures\AnotherTestValidator, TYPO3\CMS\Form\Tests\Unit\Mvc\Validation\Fixtures\TestValidator, TYPO3\CMS\Extbase\Validation\Validator\DateTimeValidator, TYPO3\CMS\Extbase\Validation\Validator\AlphanumericValidator, TYPO3\CMS\Extbase\Validation\Validator\FloatValidator, TYPO3\CMS\Extbase\Validation\Validator\IntegerValidator, TYPO3\CMS\Extbase\Validation\Validator\NumberValidator, TYPO3\CMS\Extbase\Validation\Validator\StringValidator, TYPO3\CMS\Extbase\Tests\Unit\Validation\Fixtures\Validation\Validator\CustomValidator, TYPO3\CMS\Form\Mvc\Validation\MimeTypeValidator, TYPO3\CMS\Form\Mvc\Validation\FileSizeValidator, and TYPO3\CMS\Extbase\Validation\Validator\GenericObjectValidator.

Referenced by TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator\validate().

◆ translateErrorMessage()

string TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator::translateErrorMessage (   $translateKey,
  $extensionName,
  $arguments = [] 
)
protected

Wrap static call to LocalizationUtility to simplify unit testing

Parameters
string$translateKey
string$extensionName
array$arguments
Returns
‪string

Definition at line 145 of file AbstractValidator.php.

References TYPO3\CMS\Extbase\Utility\LocalizationUtility\translate().

Referenced by TYPO3\CMS\Extbase\Validation\Validator\RegularExpressionValidator\getErrorMessage(), TYPO3\CMS\Extbase\Validation\Validator\AlphanumericValidator\isValid(), TYPO3\CMS\Extbase\Validation\Validator\NumberValidator\isValid(), TYPO3\CMS\Extbase\Validation\Validator\FloatValidator\isValid(), TYPO3\CMS\Extbase\Validation\Validator\IntegerValidator\isValid(), TYPO3\CMS\Extbase\Validation\Validator\StringValidator\isValid(), TYPO3\CMS\Extbase\Validation\Validator\DateTimeValidator\isValid(), TYPO3\CMS\Extbase\Validation\Validator\EmailAddressValidator\isValid(), TYPO3\CMS\Extbase\Validation\Validator\UrlValidator\isValid(), TYPO3\CMS\Extbase\Validation\Validator\TextValidator\isValid(), TYPO3\CMS\Extbase\Validation\Validator\NumberRangeValidator\isValid(), TYPO3\CMS\Extbase\Validation\Validator\NotEmptyValidator\isValid(), TYPO3\CMS\Extbase\Validation\Validator\StringLengthValidator\isValid(), TYPO3\CMS\Form\Mvc\Validation\DateRangeValidator\isValid(), TYPO3\CMS\Form\Mvc\Validation\EmptyValidator\isValid(), TYPO3\CMS\Extbase\Validation\Validator\BooleanValidator\isValid(), TYPO3\CMS\Form\Mvc\Validation\CountValidator\isValid(), TYPO3\CMS\Form\Mvc\Validation\FileSizeValidator\isValid(), and TYPO3\CMS\Form\Mvc\Validation\MimeTypeValidator\isValid().

◆ validate()

TYPO3 CMS Extbase Error Result TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator::validate (   $value)

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

Parameters
mixed$value‪The value that should be validated
Returns
‪\TYPO3\CMS\Extbase\Error\Result

Implements TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface.

Reimplemented in TYPO3\CMS\Extbase\Validation\Validator\CollectionValidator, and TYPO3\CMS\Extbase\Validation\Validator\GenericObjectValidator.

Definition at line 71 of file AbstractValidator.php.

References TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator\$result, TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator\isEmpty(), and TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator\isValid().

Member Data Documentation

◆ $acceptsEmptyValues

bool TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator::$acceptsEmptyValues = true
protected

Specifies whether this validator accepts empty values.

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

Definition at line 36 of file AbstractValidator.php.

◆ $options

◆ $result

◆ $supportedOptions

array TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator::$supportedOptions = array( )
protected

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

Definition at line 42 of file AbstractValidator.php.

Referenced by TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator\initializeDefaultOptions().