category Zend
package Zend_Validator

 Methods

Abstract constructor for all validators A validator should accept following parameters: - nothing f.e.

__construct(array | \Traversable $options) 

Validator() - one or multiple scalar values f.e. Validator($first, $second, $third) - an array f.e. Validator(array($first => 'first', $second => 'second', $third => 'third')) - an instance of Traversable f.e. Validator($config_instance)

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

Parameters

$property

string

Exceptions

\Zend\Validator\Exception\InvalidArgumentException

Returns

mixed

Invoke as command

__invoke(mixed $value) : bool

Parameters

$value

mixed

Returns

bool

Get default translation object for all validate objects

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

Get default translation text domain for all validate objects

getDefaultTranslatorTextDomain() : string

Returns

string

Returns the maximum allowed message length

getMessageLength() : integer

Returns

integer

Returns the message templates from the validator

getMessageTemplates() : array

Returns

array

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

getMessageVariables() : array

Returns

array

Returns array of validation failure messages

getMessages() : array

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.

Returns

array

Returns an option

getOption(string $option) : mixed

Parameters

$option

string

Option to be returned

Exceptions

\Zend\Validator\Exception\InvalidArgumentException

Returns

mixedReturned option

Returns all available options

getOptions() : array

Returns

arrayArray with all available options

Return translation object

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

Return the translation text domain

getTranslatorTextDomain() : string

Returns

string

Is there a default translation object set?

hasDefaultTranslator() : bool

Returns

bool

Does this validator have its own specific translator?

hasTranslator() : bool

Returns

bool

Is translation enabled?

isTranslatorEnabled() : bool

Returns

bool

Returns true if and only if $value meets the validation requirements

isValid(mixed $value) : bool
Inherited

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

inherited_from \Zend\Validator\ValidatorInterface::isValid()

Parameters

$value

mixed

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

Returns

bool

Set default translation object for all validate objects

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

Parameters

$textDomain

string

(optional)

Exceptions

\Zend\Validator\Exception\InvalidArgumentException

Set default translation text domain for all validate objects

setDefaultTranslatorTextDomain(string $textDomain) : void

Parameters

$textDomain

string

Sets the validation failure message template for a particular key

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

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) 

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

Parameters

$messages

array

Returns

Sets one or multiple options

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

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

Parameters

$textDomain

string

(optional)

Exceptions

\Zend\Validator\Exception\InvalidArgumentException

Returns

Indicate whether or not translation should be enabled

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

Parameters

$flag

bool

Returns

Set translation text domain

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

Parameters

$textDomain

string

Returns

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

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

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

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

stringarrayobject

Returns

string

error()

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

Parameters

$messageKey

string

$value

string

OPTIONAL

Returns the validation value

getValue() : mixed

Returns

mixedValue to be validated

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

setValue(mixed $value) : void

Parameters

$value

mixed

Translate a validation message

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

Parameters

$messageKey

string

$message

string

Returns

string

 Properties

 

$abstractOptions

$abstractOptions 

 

Default translation object for all validate objects

$defaultTranslator : \Zend\I18n\Translator\Translator

 

Default text domain to be used with translator

$defaultTranslatorTextDomain : string

 

Limits the maximum returned length of a error message

$messageLength : Integer

 

The value to be validated

$value : mixed