Validator for the image size of a image file

category Zend
package Zend_Validator

 Methods

Sets validator options

__construct(array | \Traversable $options) 

Accepts the following option keys: - minheight - minwidth - maxheight - maxwidth

Parameters

$options

array\Traversable

Magic function returns the value of the requested property, if and only if it is the value or a message variable.

__get(string $property) : mixed
Inherited

inherited_from \Zend\Validator\AbstractValidator::__get()

Parameters

$property

string

Exceptions

\Zend\Validator\Exception\InvalidArgumentException

Returns

mixed

Invoke as command

__invoke(mixed $value) : bool
Inherited

inherited_from \Zend\Validator\AbstractValidator::__invoke()

Parameters

$value

mixed

Returns

bool

Get default translation object for all validate objects

getDefaultTranslator() : \Zend\I18n\Translator\Translator | null
Inherited

inherited_from \Zend\Validator\AbstractValidator::getDefaultTranslator()

Returns

Get default translation text domain for all validate objects

getDefaultTranslatorTextDomain() : string
Inherited

inherited_from \Zend\Validator\AbstractValidator::getDefaultTranslatorTextDomain()

Returns

string

Returns the set image height sizes

getImageHeight() : array

Returns

array

Returns the set maximum image sizes

getImageMax() : array

Returns

array

Returns the set minimum image sizes

getImageMin() : array

Returns

array

Returns the set image width sizes

getImageWidth() : array

Returns

array

Returns the maximum allowed height

getMaxHeight() : integer

Returns

integer

Returns the maximum allowed width

getMaxWidth() : integer

Returns

integer

Returns the maximum allowed message length

getMessageLength() : integer
Inherited

inherited_from \Zend\Validator\AbstractValidator::getMessageLength()

Returns

integer

Returns the message templates from the validator

getMessageTemplates() : array
Inherited

inherited_from \Zend\Validator\AbstractValidator::getMessageTemplates()

Returns

array

Returns an array of the names of variables that are used in constructing validation failure messages

getMessageVariables() : array
Inherited

inherited_from \Zend\Validator\AbstractValidator::getMessageVariables()

Returns

array

Returns array of validation failure messages

getMessages() : array
Inherited

The array keys are validation failure message identifiers, and the array values are the corresponding human-readable message strings.

If isValid() was never called or if the most recent isValid() call returned true, then this method returns an empty array.

inherited_from \Zend\Validator\AbstractValidator::getMessages()

Returns

array

Returns the minimum allowed height

getMinHeight() : integer

Returns

integer

Returns the minimum allowed width

getMinWidth() : integer

Returns

integer

Returns an option

getOption(string $option) : mixed
Inherited

inherited_from \Zend\Validator\AbstractValidator::getOption()

Parameters

$option

string

Option to be returned

Exceptions

\Zend\Validator\Exception\InvalidArgumentException

Returns

mixedReturned option

Returns all available options

getOptions() : array
Inherited

inherited_from \Zend\Validator\AbstractValidator::getOptions()

Returns

arrayArray with all available options

Return translation object

getTranslator() : \Zend\I18n\Translator\Translator | null
Inherited

inherited_from \Zend\Validator\AbstractValidator::getTranslator()

Returns

Return the translation text domain

getTranslatorTextDomain() : string
Inherited

inherited_from \Zend\Validator\AbstractValidator::getTranslatorTextDomain()

Returns

string

Is there a default translation object set?

hasDefaultTranslator() : bool
Inherited

inherited_from \Zend\Validator\AbstractValidator::hasDefaultTranslator()

Returns

bool

Does this validator have its own specific translator?

hasTranslator() : bool
Inherited

inherited_from \Zend\Validator\AbstractValidator::hasTranslator()

Returns

bool

Is translation enabled?

isTranslatorEnabled() : bool
Inherited

inherited_from \Zend\Validator\AbstractValidator::isTranslatorEnabled()

Returns

bool

Returns true if and only if the image size of $value is at least min and not bigger than max

isValid(string $value, array $file) : bool

If $value fails validation, then this method returns false, and getMessages() will return an array of messages that explain why the validation failed.

Parameters

$value

string

Real file to check for image size

$file

array

File data from \Zend\File\Transfer\Transfer

Exceptions

\Zend\Validator\Exception\RuntimeException If validation of $value is impossible

Returns

bool

Retrieve flag indicating whether or not value should be obfuscated in messages

isValueObscured() : bool
Inherited

inherited_from \Zend\Validator\AbstractValidator::isValueObscured()

Returns

bool

Set default translation object for all validate objects

setDefaultTranslator(\Zend\I18n\Translator\Translator $translator, string $textDomain) : void
Inherited

inherited_from \Zend\Validator\AbstractValidator::setDefaultTranslator()

Parameters

$textDomain

string

(optional)

Exceptions

\Zend\Validator\Exception\InvalidArgumentException

Set default translation text domain for all validate objects

setDefaultTranslatorTextDomain(string $textDomain) : void
Inherited

inherited_from \Zend\Validator\AbstractValidator::setDefaultTranslatorTextDomain()

Parameters

$textDomain

string

Sets the minimum and maximum image height

setImageHeight(array $options) : \Zend\Validator\File\ImageSize

Parameters

$options

array

The image height dimensions

Returns

\Zend\Validator\File\ImageSizeProvides a fluent interface

Sets the maximum image size

setImageMax(array | \Traversable $options) : \Zend\Validator\File\ImageSize

Parameters

$options

array\Traversable

The maximum image dimensions

Returns

\Zend\Validator\File\ImageSizeProvides a fluent interface

Sets the minimum image size

setImageMin(array $options) : \Zend\Validator\File\ImageSize

Parameters

$options

array

The minimum image dimensions

Returns

\Zend\Validator\File\ImageSizeProvides a fluent interface

Sets the minimum and maximum image width

setImageWidth(array $options) : \Zend\Validator\File\ImageSize

Parameters

$options

array

The image width dimensions

Returns

\Zend\Validator\File\ImageSizeProvides a fluent interface

Sets the maximum allowed height

setMaxHeight(integer $maxHeight) : \Zend\Validator\File\ImageSize

Parameters

$maxHeight

integer

Exceptions

\Zend\Validator\Exception\InvalidArgumentException When maxheight is less than minheight

Returns

\Zend\Validator\File\ImageSizeProvides a fluid interface

Sets the maximum allowed width

setMaxWidth(integer $maxWidth) : \Zend\Validator\File\ImageSize

Parameters

$maxWidth

integer

Exceptions

\Zend\Validator\Exception\InvalidArgumentException When maxwidth is less than minwidth

Returns

\Zend\Validator\File\ImageSizeProvides a fluid interface

Sets the validation failure message template for a particular key

setMessage(string $messageString, string $messageKey) : \Zend\Validator\AbstractValidator
Inherited

inherited_from \Zend\Validator\AbstractValidator::setMessage()

Parameters

$messageString

string

$messageKey

string

OPTIONAL

Exceptions

\Zend\Validator\Exception\InvalidArgumentException

Returns

\Zend\Validator\AbstractValidatorProvides a fluent interface

Sets the maximum allowed message length

setMessageLength(integer $length) 
Inherited

inherited_from \Zend\Validator\AbstractValidator::setMessageLength()

Parameters

$length

integer

Sets validation failure message templates given as an array, where the array keys are the message keys, and the array values are the message template strings.

setMessages(array $messages) : \Zend\Validator\AbstractValidator
Inherited

inherited_from \Zend\Validator\AbstractValidator::setMessages()

Parameters

$messages

array

Returns

Sets the minimum allowed height

setMinHeight(integer $minHeight) : \Zend\Validator\File\ImageSize

Parameters

$minHeight

integer

Exceptions

\Zend\Validator\Exception\InvalidArgumentException When minheight is greater than maxheight

Returns

\Zend\Validator\File\ImageSizeProvides a fluid interface

Sets the minimum allowed width

setMinWidth(integer $minWidth) : \Zend\Validator\File\ImageSize

Parameters

$minWidth

integer

Exceptions

\Zend\Validator\Exception\InvalidArgumentException When minwidth is greater than maxwidth

Returns

\Zend\Validator\File\ImageSizeProvides a fluid interface

Sets one or multiple options

setOptions(array | \Traversable $options) : \Zend\Validator\AbstractValidator
Inherited

inherited_from \Zend\Validator\AbstractValidator::setOptions()

Parameters

$options

array\Traversable

Options to set

Exceptions

\Zend\Validator\Exception\InvalidArgumentException If $options is not an array or Traversable

Returns

\Zend\Validator\AbstractValidatorProvides fluid interface

Set translation object

setTranslator(\Zend\I18n\Translator\Translator $translator, string $textDomain) : \Zend\Validator\AbstractValidator
Inherited

inherited_from \Zend\Validator\AbstractValidator::setTranslator()

Parameters

$textDomain

string

(optional)

Exceptions

\Zend\Validator\Exception\InvalidArgumentException

Returns

Indicate whether or not translation should be enabled

setTranslatorEnabled(bool $flag) : \Zend\Validator\AbstractValidator
Inherited

inherited_from \Zend\Validator\AbstractValidator::setTranslatorEnabled()

Parameters

$flag

bool

Returns

Set translation text domain

setTranslatorTextDomain(string $textDomain) : \Zend\Validator\AbstractValidator
Inherited

inherited_from \Zend\Validator\AbstractValidator::setTranslatorTextDomain()

Parameters

$textDomain

string

Returns

Set flag indicating whether or not value should be obfuscated in messages

setValueObscured(bool $flag) : \Zend\Validator\AbstractValidator
Inherited

inherited_from \Zend\Validator\AbstractValidator::setValueObscured()

Parameters

$flag

bool

Returns

Constructs and returns a validation failure message with the given message key and value.

createMessage(string $messageKey, string | array | object $value) : string
Inherited

Returns null if and only if $messageKey does not correspond to an existing template.

If a translator is available and a translation exists for $messageKey, the translation will be used.

inherited_from \Zend\Validator\AbstractValidator::createMessage()

Parameters

$messageKey

string

$value

stringarrayobject

Returns

string

error()

error(string $messageKey, string $value) : void
Inherited

inherited_from \Zend\Validator\AbstractValidator::error()

Parameters

$messageKey

string

$value

string

OPTIONAL

Returns the validation value

getValue() : mixed
Inherited

inherited_from \Zend\Validator\AbstractValidator::getValue()

Returns

mixedValue to be validated

Sets the value to be validated and clears the messages and errors arrays

setValue(mixed $value) : void
Inherited

inherited_from \Zend\Validator\AbstractValidator::setValue()

Parameters

$value

mixed

Throws an error of the given type

throwError(string $file, string $errorType) : false

Parameters

$file

string

$errorType

string

Returns

false

Translate a validation message

translateMessage(string $messageKey, string $message) : string
Inherited

inherited_from \Zend\Validator\AbstractValidator::translateMessage()

Parameters

$messageKey

string

$message

string

Returns

string

 Properties

 

$abstractOptions

$abstractOptions 
Inherited

inherited_from \Zend\Validator\AbstractValidator::$$abstractOptions
 

Default translation object for all validate objects

$defaultTranslator : \Zend\I18n\Translator\Translator
Inherited

inherited_from \Zend\Validator\AbstractValidator::$$defaultTranslator
 

Default text domain to be used with translator

$defaultTranslatorTextDomain : string
Inherited

inherited_from \Zend\Validator\AbstractValidator::$$defaultTranslatorTextDomain
 

Detected height

$height : integer

 

Limits the maximum returned length of a error message

$messageLength : Integer
Inherited

inherited_from \Zend\Validator\AbstractValidator::$$messageLength
 

<p>Error message template</p>

$messageTemplates : array

 

<p>Error message template variables</p>

$messageVariables : array

 

Options for this validator

$options : array

 

The value to be validated

$value : mixed
Inherited

inherited_from \Zend\Validator\AbstractValidator::$$value
 

Detected width

$width : integer

 Constants

 

HEIGHT_TOO_BIG

HEIGHT_TOO_BIG 

 

HEIGHT_TOO_SMALL

HEIGHT_TOO_SMALL 

 

NOT_DETECTED

NOT_DETECTED 

 

NOT_READABLE

NOT_READABLE 

 

WIDTH_TOO_BIG

WIDTH_TOO_BIG 

const string Error constants
 

WIDTH_TOO_SMALL

WIDTH_TOO_SMALL