Class ValidatorChain

Summary

Fully Qualified Name: Zend\Validator\ValidatorChain
Implements: Countable, ValidatorInterface

Description

Methods

Name Description Defined By
__clone() Deep clone handling ValidatorChain
__construct() Initialize validator chain ValidatorChain
__invoke() Invoke chain as command ValidatorChain
__sleep() Prepare validator chain for serialization ValidatorChain
addByName() Proxy to attachByName() to keep BC ValidatorChain
addValidator() Proxy to attach() to keep BC ValidatorChain
attach() Attach a validator to the end of the chain ValidatorChain
attachByName() Use the plugin manager to add a validator by name ValidatorChain
count() Return the count of attached validators ValidatorChain
getMessages() Returns array of validation failure messages ValidatorChain
getPluginManager() Get plugin manager instance ValidatorChain
getValidators() Get all the validators ValidatorChain
isValid() Returns true if and only if $value passes all validations in the chain ValidatorChain
merge() Merge the validator chain with the one given in parameter ValidatorChain
plugin() Retrieve a validator by name ValidatorChain
prependByName() Use the plugin manager to prepend a validator by name ValidatorChain
prependValidator() Adds a validator to the beginning of the chain ValidatorChain
setPluginManager() Set plugin manager instance ValidatorChain

Method Details

__clone()

Deep clone handling

Returns:

__construct()

Initialize validator chain

Returns:

__invoke()

Invoke chain as command

Parameter Name Type Description
$value mixed

Returns: bool

__sleep()

Prepare validator chain for serialization

Plugin manager (property 'plugins') cannot be serialized. On wakeup the property remains unset and next invocation to getPluginManager() sets the default plugin manager instance (ValidatorPluginManager).

Returns: array

addByName()

Proxy to attachByName() to keep BC

Parameter Name Type Description
$name string
$options array
$breakChainOnFailure bool

Returns: \ValidatorChain

addValidator()

Proxy to attach() to keep BC

Parameter Name Type Description
$validator \ValidatorInterface
$breakChainOnFailure bool
$priority int

Returns: \ValidatorChain Provides a fluent interface

attach()

Attach a validator to the end of the chain

If $breakChainOnFailure is true, then if the validator fails, the next validator in the chain, if one exists, will not be executed.

Parameter Name Type Description
$validator \ValidatorInterface
$breakChainOnFailure bool
$priority int Priority

Returns: self

attachByName()

Use the plugin manager to add a validator by name

Parameter Name Type Description
$name string
$options array
$breakChainOnFailure bool
$priority int

Returns: \ValidatorChain

count()

Return the count of attached validators

Returns: int

getMessages()

Returns array of validation failure messages

Returns: array

getPluginManager()

Get plugin manager instance

Returns: \ValidatorPluginManager

getValidators()

Get all the validators

Returns: array

isValid()

Returns true if and only if $value passes all validations in the chain

Validators are run in the order in which they were added to the chain (FIFO).

Parameter Name Type Description
$value mixed
$context mixed Extra

Returns: bool

merge()

Merge the validator chain with the one given in parameter

Parameter Name Type Description
$validatorChain \ValidatorChain

Returns: \ValidatorChain

plugin()

Retrieve a validator by name

Parameter Name Type Description
$name string Name
$options null|array Options

Returns: \ValidatorInterface

prependByName()

Use the plugin manager to prepend a validator by name

Parameter Name Type Description
$name string
$options array
$breakChainOnFailure bool

Returns: \ValidatorChain

prependValidator()

Adds a validator to the beginning of the chain

If $breakChainOnFailure is true, then if the validator fails, the next validator in the chain, if one exists, will not be executed.

Parameter Name Type Description
$validator \ValidatorInterface
$breakChainOnFailure bool

Returns: \ValidatorChain Provides a fluent interface

setPluginManager()

Set plugin manager instance

Parameter Name Type Description
$plugins \ValidatorPluginManager Plugin

Returns: \ValidatorChain

Top