1983. Class

1983.1. Zend\Validator\AbstractValidator

1983.1.1. Methods

1983.1.1.1. __construct

__construct()

Abstract constructor for all validators A validator should accept following parameters:

  • nothing f.e. 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:array|Traversable

1983.1.1.2. getOption

getOption()

Returns an option

Parameters:string – Option to be returned
Return type:mixed Returned option
Throws :ExceptionInvalidArgumentException

1983.1.1.3. getOptions

getOptions()

Returns all available options

Return type:array Array with all available options

1983.1.1.4. setOptions

setOptions()

Sets one or multiple options

Parameters:array|Traversable – Options to set
Throws ExceptionInvalidArgumentException:
 If $options is not an array or Traversable
Return type:AbstractValidator Provides fluid interface

1983.1.1.5. getMessages

getMessages()

Returns array of validation failure messages

Return type:array

1983.1.1.6. __invoke

__invoke()

Invoke as command

Parameters:mixed
Return type:bool

1983.1.1.7. getMessageVariables

getMessageVariables()

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

Return type:array

1983.1.1.8. getMessageTemplates

getMessageTemplates()

Returns the message templates from the validator

Return type:array

1983.1.1.9. setMessage

setMessage()

Sets the validation failure message template for a particular key

Parameters:
  • string
  • string – OPTIONAL
Return type:

AbstractValidator Provides a fluent interface

Throws :

ExceptionInvalidArgumentException

1983.1.1.10. setMessages

setMessages()

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.

Parameters:array
Return type:AbstractValidator

1983.1.1.11. __get

__get()

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

Parameters:string
Return type:mixed
Throws :ExceptionInvalidArgumentException

1983.1.1.12. createMessage

createMessage()

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

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:
  • string
  • string|array|object
Return type:

string

1983.1.1.13. error

error()

@param string $messageKey

Parameters:string – OPTIONAL
Return type:void

1983.1.1.14. getValue

getValue()

Returns the validation value

Return type:mixed Value to be validated

1983.1.1.15. setValue

setValue()

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

Parameters:mixed
Return type:void

1983.1.1.16. setValueObscured

setValueObscured()

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

Parameters:bool
Return type:AbstractValidator

1983.1.1.17. isValueObscured

isValueObscured()

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

Return type:bool

1983.1.1.18. setTranslator

setTranslator()

Set translation object

Parameters:
  • Translator|null
  • string – (optional)
Return type:

AbstractValidator

Throws :

ExceptionInvalidArgumentException

1983.1.1.19. getTranslator

getTranslator()

Return translation object

Return type:Translator|null

1983.1.1.20. hasTranslator

hasTranslator()

Does this validator have its own specific translator?

Return type:bool

1983.1.1.21. setTranslatorTextDomain

setTranslatorTextDomain()

Set translation text domain

Parameters:string
Return type:AbstractValidator

1983.1.1.22. getTranslatorTextDomain

getTranslatorTextDomain()

Return the translation text domain

Return type:string

1983.1.1.23. setDefaultTranslator

setDefaultTranslator()

Set default translation object for all validate objects

Parameters:
  • Translator|null
  • string – (optional)
Return type:

void

Throws :

ExceptionInvalidArgumentException

1983.1.1.24. getDefaultTranslator

getDefaultTranslator()

Get default translation object for all validate objects

Return type:Translator|null

1983.1.1.25. hasDefaultTranslator

hasDefaultTranslator()

Is there a default translation object set?

Return type:bool

1983.1.1.26. setDefaultTranslatorTextDomain

setDefaultTranslatorTextDomain()

Set default translation text domain for all validate objects

Parameters:string
Return type:void

1983.1.1.27. getDefaultTranslatorTextDomain

getDefaultTranslatorTextDomain()

Get default translation text domain for all validate objects

Return type:string

1983.1.1.28. setTranslatorEnabled

setTranslatorEnabled()

Indicate whether or not translation should be enabled

Parameters:bool
Return type:AbstractValidator

1983.1.1.29. isTranslatorEnabled

isTranslatorEnabled()

Is translation enabled?

Return type:bool

1983.1.1.30. getMessageLength

getMessageLength()

Returns the maximum allowed message length

Return type:integer

1983.1.1.31. setMessageLength

setMessageLength()

Sets the maximum allowed message length

Parameters:integer

1983.1.1.32. translateMessage

translateMessage()

Translate a validation message

Parameters:
  • string
  • string
Return type:

string