Skip to content
This repository was archived by the owner on May 24, 2018. It is now read-only.

Keep updates with method changes #548

Merged
merged 1 commit into from
Dec 12, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions docs/languages/en/modules/zend.validator.validator-chains.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ between 6 and 12 alphanumeric characters:

// Create a validator chain and add validators to it
$validatorChain = new Zend\Validator\ValidatorChain();
$validatorChain->addValidator(
$validatorChain->attach(
new Zend\Validator\StringLength(array('min' => 6,
'max' => 12)))
->addValidator(new Zend\Validator\Alnum());
->attach(new Zend\Validator\Alnum());

// Validate the username
if ($validatorChain->isValid($username)) {
Expand All @@ -34,7 +34,7 @@ performed regardless of whether the first validation, for length between 6 and 1
that if both validations fail, ``getMessages()`` will return failure messages from both validators.

In some cases it makes sense to have a validator break the chain if its validation process fails.
``Zend\Validator\ValidatorChain`` supports such use cases with the second parameter to the ``addValidator()``
``Zend\Validator\ValidatorChain`` supports such use cases with the second parameter to the ``attach()``
method. By setting ``$breakChainOnFailure`` to ``TRUE``, the added validator will break the chain execution upon
failure, which avoids running any other validations that are determined to be unnecessary or inappropriate for the
situation. If the above example were written as follows, then the alphanumeric validation would not occur if the
Expand All @@ -43,11 +43,11 @@ string length validation fails:
.. code-block:: php
:linenos:

$validatorChain->addValidator(
$validatorChain->attach(
new Zend\Validator\StringLength(array('min' => 6,
'max' => 12)),
true)
->addValidator(new Zend\Validator\Alnum());
->attach(new Zend\Validator\Alnum());

Any object that implements ``Zend\Validator\ValidatorInterface`` may be used in a validator chain.

Expand Down