ImageDimensionsValidator extends AbstractValidator

FinalYes

Validator to validate image dimensions of a given UploadedFile or ObjectStorage of UploadedFile objects.

Table of Contents

Properties

$acceptsEmptyValues  : bool
Specifies whether this validator accepts empty values.
$heightMessage  : string
$maxHeightMessage  : string
$maxWidthMessage  : string
$minHeightMessage  : string
$minWidthMessage  : string
$options  : array<string|int, mixed>
$request  : ServerRequestInterface|null
$result  : Result
$supportedOptions  : array<string|int, mixed>
This contains the supported options, their default values, types and descriptions.
$translationOptions  : array<string|int, mixed>
Contains an array of property names used for translation handling of error messages.
$widthMessage  : string

Methods

getOptions()  : array<string|int, mixed>
Returns the options of this validator
getRequest()  : ServerRequestInterface|null
isValid()  : void
Check if $value is valid. If it is not valid, needs to add an error to result.
setOptions()  : void
Receive validator options from framework.
setRequest()  : void
validate()  : Result
Checks if the given value is valid according to the validator, and returns the error messages object which occurred.
addError()  : void
Creates a new validation error object and adds it to $this->result
addErrorForProperty()  : void
Creates a new validation error object for a property and adds it to the proper sub result of $this->result
ensureFileUploadTypes()  : void
Ensures that the provided value is either an instance of UploadedFile or an ObjectStorage containing only UploadedFile instances.
getImageInfo()  : ImageInfo
initializeDefaultOptions()  : void
Initialize default options.
initializeTranslationOptions()  : void
Initializes all registered translation options with custom translation options from the given options array
isEmpty()  : bool
TRUE if the given $value is NULL or an empty string ('')
translateErrorMessage()  : string
Translates an error message using LocalizationUtility::translate() method. If the translate key does not start with 'LLL:', the original translate key is returned.
validateOptions()  : void
Checks if this validator is correctly configured
validateUploadedFile()  : void

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.

$heightMessage

protected string $heightMessage = 'LLL:EXT:extbase/Resources/Private/Language/locallang.xlf:validation.imagedimensions.height.notvalid'

$maxHeightMessage

protected string $maxHeightMessage = 'LLL:EXT:extbase/Resources/Private/Language/locallang.xlf:validation.imagedimensions.maxheight.notvalid'

$maxWidthMessage

protected string $maxWidthMessage = 'LLL:EXT:extbase/Resources/Private/Language/locallang.xlf:validation.imagedimensions.maxwidth.notvalid'

$minHeightMessage

protected string $minHeightMessage = 'LLL:EXT:extbase/Resources/Private/Language/locallang.xlf:validation.imagedimensions.minheight.notvalid'

$minWidthMessage

protected string $minWidthMessage = 'LLL:EXT:extbase/Resources/Private/Language/locallang.xlf:validation.imagedimensions.minwidth.notvalid'

$options

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

$request

protected ServerRequestInterface|null $request = null

$supportedOptions

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

protected array<string|int, mixed> $supportedOptions = ['width' => [null, 'The exact width of the image', 'int'], 'height' => [null, 'The exact height of the image', 'int'], 'minWidth' => [0, 'The minimum width of the image', 'int'], 'maxWidth' => [PHP_INT_MAX, 'The maximum width of the image', 'int'], 'minHeight' => [0, 'The minimum height of the image', 'int'], 'maxHeight' => [PHP_INT_MAX, 'The maximum heigt of the image', 'int'], 'heightMessage' => [null, 'Translation key or message for invalid height', 'string'], 'widthMessage' => [null, 'Translation key or message for invalid width', 'string'], 'minWidthMessage' => [null, 'Translation key or message for invalid minimum width', 'string'], 'maxWidthMessage' => [null, 'Translation key or message for invalid maximum width', 'string'], 'minHeightMessage' => [null, 'Translation key or message for invalid minimum height', 'string'], 'maxHeightMessage' => [null, 'Translation key or message for invalid maximum height', 'string']]

$translationOptions

Contains an array of property names used for translation handling of error messages.

protected array<string|int, mixed> $translationOptions = ['message']

$widthMessage

protected string $widthMessage = 'LLL:EXT:extbase/Resources/Private/Language/locallang.xlf:validation.imagedimensions.width.notvalid'

Methods

getOptions()

Returns the options of this validator

public getOptions() : array<string|int, mixed>
Return values
array<string|int, mixed>

getRequest()

public getRequest() : ServerRequestInterface|null
Tags
todo:

Add to ValidatorInterface in TYPO3 v14

Return values
ServerRequestInterface|null

isValid()

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

public isValid(mixed $value) : void
Parameters
$value : mixed

setOptions()

Receive validator options from framework.

public setOptions(array<string|int, mixed> $options) : void
Parameters
$options : array<string|int, mixed>

setRequest()

public setRequest(ServerRequestInterface|null $request) : void
Parameters
$request : ServerRequestInterface|null
Tags
todo:

Add to ValidatorInterface in TYPO3 v14

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<string|int, mixed> $arguments = [] ][, string $title = '' ]) : void
Parameters
$message : string

The error message

$code : int

The error code (a unix timestamp)

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

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(string|array<string|int, mixed> $propertyPath, string $message, int $code[, array<string|int, mixed> $arguments = [] ][, string $title = '' ]) : void
Parameters
$propertyPath : string|array<string|int, mixed>

The property path (string or array)

$message : string

The error message

$code : int

The error code (a unix timestamp)

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

Arguments to be replaced in message

$title : string = ''

Title of the error

ensureFileUploadTypes()

Ensures that the provided value is either an instance of UploadedFile or an ObjectStorage containing only UploadedFile instances.

protected ensureFileUploadTypes(mixed $value) : void
Parameters
$value : mixed

initializeDefaultOptions()

Initialize default options.

protected initializeDefaultOptions(array<string|int, mixed> $options) : void
Parameters
$options : array<string|int, mixed>
Tags
throws
InvalidValidationOptionsException

initializeTranslationOptions()

Initializes all registered translation options with custom translation options from the given options array

protected initializeTranslationOptions(array<string|int, mixed> $options) : void
Parameters
$options : array<string|int, mixed>

isEmpty()

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

protected final isEmpty(mixed $value) : bool
Parameters
$value : mixed
Return values
bool

translateErrorMessage()

Translates an error message using LocalizationUtility::translate() method. If the translate key does not start with 'LLL:', the original translate key is returned.

protected translateErrorMessage(string $translateKey[, string $extensionName = '' ][, array<string|int, mixed> $arguments = [] ]) : string
Parameters
$translateKey : string
$extensionName : string = ''
$arguments : array<string|int, mixed> = []
Return values
string

validateOptions()

Checks if this validator is correctly configured

protected validateOptions() : void

validateUploadedFile()

protected validateUploadedFile(UploadedFile $uploadedFile[, int|null $index = null ]) : void
Parameters
$uploadedFile : UploadedFile
$index : int|null = null

        
On this page

Search results