Validator for the maximum size of a file up to a max of 2GB

category Zend
package Zend_Validate
copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
license New BSD License
inherited_from \Zend_Validate_Abstract

 Methods

Sets validator options

__construct(integer|array $options) 

If $options is a integer, it will be used as maximum filesize As Array is accepts the following keys: 'min': Minimum filesize 'max': Maximum filesize 'bytestring': Use bytestring or real size for messages

Parameters

$options

integerarray

Options for the adapter

Exceptions

\Zend_Validate_Exception

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

Parameters

$property

string

Exceptions

\Zend_Validate_Exception

Returns

mixed

Get default translation object for all validate objects

getDefaultTranslator() : \Zend_Translate_Adapter | null
InheritedStatic

Returns

\Zend_Translate_Adapternull

Returns array of validation failure message codes

getErrors() : array
Inherited
deprecated Since 1.5.0

Returns

array

Returns the maximum filesize

getMax(boolean $raw = false) : integer | string

Parameters

$raw

boolean

Whether or not to force return of the raw value (defaults off)

Returns

integerstring

Returns the maximum allowed message length

getMessageLength() : integer
InheritedStatic

Returns

integer

Returns the message templates from the validator

getMessageTemplates() : array
Inherited

Returns

array

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

getMessageVariables() : array
Inherited

Returns

array

Returns array of validation failure messages

getMessages() : array
Inherited

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

inherited_from \Zend_Validate_Interface::getMessages()

Returns

array

Returns the minimum filesize

getMin(boolean $raw = false) : integer | string

Parameters

$raw

boolean

Whether or not to force return of the raw value (defaults off)

Returns

integerstring

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

getObscureValue() : boolean
Inherited

Returns

boolean

Return translation object

getTranslator() : \Zend_Translate_Adapter | null
Inherited

Returns

\Zend_Translate_Adapternull

Is there a default translation object set?

hasDefaultTranslator() : boolean
InheritedStatic

Returns

boolean

Does this validator have its own specific translator?

hasTranslator() : boolean
Inherited

Returns

boolean

Defined by Zend_Validate_Interface

isValid(string $value, array $file = null) : boolean

Returns true if and only if the filesize of $value is at least min and not bigger than max (when max is not null).

Parameters

$value

string

Real file to check for size

$file

array

File data from Zend_File_Transfer

Returns

boolean

Set default translation object for all validate objects

setDefaultTranslator(\Zend_Translate|\Zend_Translate_Adapter|null $translator = null
InheritedStatic

Parameters

$translator

\Zend_Translate\Zend_Translate_Adapternull

Exceptions

\Zend_Validate_Exception

Indicate whether or not translation should be disabled

setDisableTranslator(boolean $flag) : \Zend_Validate_Abstract
Inherited

Parameters

$flag

boolean

Returns

\Zend_Validate_Abstract

Sets the maximum filesize

setMax(integer $max) : \Zend_Validate_StringLength

Parameters

$max

integer

The maximum filesize

Exceptions

\Zend_Validate_Exception When max is smaller than min

Returns

\Zend_Validate_StringLengthProvides a fluent interface

Sets the validation failure message template for a particular key

setMessage(string $messageString, string $messageKey = null) : \Zend_Validate_Abstract
Inherited

Parameters

$messageString

string

$messageKey

string

OPTIONAL

Exceptions

\Zend_Validate_Exception

Returns

\Zend_Validate_AbstractProvides a fluent interface

Sets the maximum allowed message length

setMessageLength(integer $length = -1
InheritedStatic

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_Validate_Abstract
Inherited

Parameters

$messages

array

Returns

\Zend_Validate_Abstract

Sets the minimum filesize

setMin(integer $min) : \Zend_Validate_File_Size

Parameters

$min

integer

The minimum filesize

Exceptions

\Zend_Validate_Exception When min is greater than max

Returns

\Zend_Validate_File_SizeProvides a fluent interface

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

setObscureValue(boolean $flag) : \Zend_Validate_Abstract
Inherited

Parameters

$flag

boolean

Returns

\Zend_Validate_Abstract

Set translation object

setTranslator(\Zend_Translate|\Zend_Translate_Adapter|null $translator = null) : \Zend_Validate_Abstract
Inherited

Parameters

$translator

\Zend_Translate\Zend_Translate_Adapternull

Exceptions

\Zend_Validate_Exception

Returns

\Zend_Validate_Abstract

Returns the minimum filesize

setUseByteString(boolean $byteString = true) : integer

Parameters

$byteString

boolean

Use bytestring ?

Returns

integer

Is translation disabled?

translatorIsDisabled() : boolean
Inherited

Returns

boolean

Will bytestring be used?

useByteString() : boolean

Returns

boolean

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

_createMessage(string $messageKey, string $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.

Parameters

$messageKey

string

$value

string

Returns

string

_error()

_error(string $messageKey, string $value = null) : void
Inherited

Parameters

$messageKey

string

$value

string

OPTIONAL

Returns the unformatted size

_fromByteString(string $size) : integer

Parameters

$size

string

Returns

integer

Retrieve current detected file size

_getSize() : integer

Returns

integer

Joins elements of a multidimensional array

_implodeRecursive(array $pieces) : string
Inherited

Parameters

$pieces

array

Returns

string

Set current size

_setSize(integer $size) : \Zend_Validate_File_Size

Parameters

$size

integer

Returns

\Zend_Validate_File_Size

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

_setValue(mixed $value) : void
Inherited

Parameters

$value

mixed

Throws an error of the given type

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

Parameters

$file

string

$errorType

string

Returns

false

Returns the formatted size

_toByteString(integer $size) : string

Parameters

$size

integer

Returns

string

 Properties

 

Default translation object for all validate objects

$_defaultTranslator : \Zend_Translate

Default

Static
 

Array of validation failure message codes

$_errors : array

Default

array()
deprecated Since 1.5.0
 

Maximum filesize

$_max : integer | null

Default

If null, there is no maximum filesize

 

Limits the maximum returned length of a error message

$_messageLength : Integer

Default

-1
Static
 

Validation failure message template definitions

$_messageTemplates : array

Default

array(self::TOO_BIG => "Maximum allowed size for file '%value%' is '%max%' but '%size%' detected", self::TOO_SMALL => "Minimum expected size for file '%value%' is '%min%' but '%size%' detected", self::NOT_FOUND => "File '%value%' is not readable or does not exist")
inherited_from \Zend_Validate_Abstract::_messageTemplates
 

Validation failure message template definitions

$_messageTemplates : array

Default

array()
 

Additional variables available for validation failure messages

$_messageVariables : array

Default

array('min' => '_min', 'max' => '_max', 'size' => '_size')
inherited_from \Zend_Validate_Abstract::_messageVariables
 

Additional variables available for validation failure messages

$_messageVariables : array

Default

array()
 

Array of validation failure messages

$_messages : array

Default

array()
 

Minimum filesize

$_min : integer

Default

 

Flag indidcating whether or not value should be obfuscated in error messages

$_obscureValue : boolean

Default

false
 

Detected size

$_size : integer

Default

 

Translation object

$_translator : \Zend_Translate

Default

 

Is translation disabled?

$_translatorDisabled : Boolean

Default

false
 

Use bytestring ?

$_useByteString : boolean

Default

true
 

The value to be validated

$_value : mixed

Default

 Constants

 

NOT_FOUND

NOT_FOUND = 'fileSizeNotFound' 
 

TOO_BIG

TOO_BIG = 'fileSizeTooBig' 
 

TOO_SMALL

TOO_SMALL = 'fileSizeTooSmall'