title: Zend Framework Validator Chain messages
body: <p>Struggling to understand why my validator chain is showing the incorrect message for the value I type in.</p>
  
  <p>Currently my model's code is making the incorrect message appear when I type in non-identical passwords instead of just the expected 3rd message ('<em>Please retype password between 8-25 alphanumeric characters and matching the first password</em>' when expecting '<em>Retyped password must match first.</em>') when i type in mismatched passwords of 8 -25 characters long. </p>
  
  <p>$password2 is the one giving issues</p>
  
  <p>Also unsure if the indentical validator is working due to this problem.</p>
  
  <p>Zend Framework version 1.11</p>
  
  <p>Specific code chunk related to above</p>
  
  <pre><code>$password2 = new Zend_Form_Element_Password('password2');
  $password2-&gt;setAttrib('size', 25);
  $password2-&gt;setRequired(true);
  $validatorChain2 = new Zend_Validate();
  $validatorChain2-&gt;addValidator(new Zend_Validate_StringLength(array('min' =&gt; 8,'max' =&gt; 25)), true);
  $validatorChain2-&gt;addValidator(new Zend_Validate_Alnum(false), true);
  $validatorChain2-&gt;addValidator(new Zend_Validate_Identical('password1'), true);
  $password2-&gt;addValidator($validatorChain2);
  $password2-&gt;addErrorMessage('Please retype password between 8-25 alphanumeric characters and matching the first password');
  $password2-&gt;addErrorMessage('Passwords can only be alphanumeric characters.');
          $password2-&gt;addErrorMessage('Retyped password must match first.');
  </code></pre>
  
  <p>Full model code listing</p>
  
  <pre><code>class Application_Model_RegisterNewAccount extends Zend_Form
  {
  
      public function __construct($options = null)
      {
          // TODO: The errors are been grouped together at the top of the page now but the original error messages below each field need to be removed
          parent::__construct($options);
  
          $this-&gt;setName('newaccountregistration');
          $this-&gt;setMethod('post');
          $this-&gt;setAction($options['action']);   // Variable action passed via parameter array for argument 'action'
  
          $email = new Zend_Form_Element_Text('email');   // Create form text field
          $email-&gt;setAttrib('size', 75);  // Set for, element max size/length
          $email-&gt;setRequired(true);  // Make this field a required item
  
          $validator_email = new Zend_Validate_EmailAddress();
          $email-&gt;addValidator($validator_email);   // Set validator type and minimum and maximum size required
          $email-&gt;addErrorMessage('Please provide a valid email address');
  
          $firstname = new Zend_Form_Element_Text('firstname');
          $firstname-&gt;setAttrib('size', 35);
          $firstname-&gt;setRequired(true);
  
          $validator_firstname = new Zend_Validate_StringLength(array(1,35));
          $firstname-&gt;addValidator($validator_firstname);
          $firstname-&gt;addErrorMessage('Please provide your first name between 1-35 characters');
  
          $surname = new Zend_Form_Element_Text('surname');
          $surname-&gt;setAttrib('size', 35);
          $surname-&gt;setRequired(true);
  
          $validator_surname = new Zend_Validate_StringLength(array(1,35));
          $surname-&gt;addValidator($validator_surname);
          $surname-&gt;addErrorMessage('Please provide your first name between 1-35 characters');
  
          $password1 = new Zend_Form_Element_Password('password1');
          $password1-&gt;setAttrib('size', 25);
          $password1-&gt;setRequired(true);
          $validatorChain1 = new Zend_Validate();
          $validatorChain1-&gt;addValidator(new Zend_Validate_StringLength(array('min' =&gt; 8,'max' =&gt; 25)), true);
          $validatorChain1-&gt;addValidator(new Zend_Validate_Alnum(false), true);
          $password1-&gt;addValidator($validatorChain1);
          $password1-&gt;addErrorMessage('Please provide a password between 8-25 alphanumeric characters');
          $password1-&gt;addErrorMessage('Passwords can only be alphanumeric characters.');
  
          $password2 = new Zend_Form_Element_Password('password2');
  
          $password2-&gt;setAttrib('size', 25);
          $password2-&gt;setRequired(true);
          $validatorChain2 = new Zend_Validate();
          $validatorChain2-&gt;addValidator(new Zend_Validate_StringLength(array('min' =&gt; 8,'max' =&gt; 25)), true);
          $validatorChain2-&gt;addValidator(new Zend_Validate_Alnum(false), true);
          $validatorChain2-&gt;addValidator(new Zend_Validate_Identical('password1'), true);
          $password2-&gt;addValidator($validatorChain2);
          $password2-&gt;addErrorMessage('Please retype password between 8-25 alphanumeric characters and matching the first password');
          $password2-&gt;addErrorMessage('Passwords can only be alphanumeric characters.');
          $password2-&gt;addErrorMessage('Retyped password must match first.');
  
          $submit = new Zend_Form_Element_Submit('submit');   // Added submit button
          $submit-&gt;setLabel('Register');
          $submit-&gt;removeDecorator('DtDdWrapper'); // Remove the default DD div wrapper
  
          $this-&gt;setDecorators( array( array('ViewScript',
              array('viewScript' =&gt; '_register.phtml'))));    // The form html page
  
          $this-&gt;addElements(array($email, $firstname, $surname, $password1, $password2, $submit));   // Add all the form elements
      }
  
  }
  </code></pre>