13.2. Standard Validation Classes

13.2. Standard Validation Classes

13.2.1. Confirm

The confirm validate checks whether the value provided is the same as the context value. This is particularly useful in validating password fields with Zend_Form.

Example 13.1. Using Zym_Validate_Confirm

The construct requires the field name of the context value if it is an array. The context value can be provided in the contructor if you are using the validator by itself or Zend_Filter_Input. With Zend_Form, the context is handled automatically.

<?php
$password = new Zend_Form_Element_Password('password');
$password->setLabel('Password')
        ->addValidator(new Zym_Validate_Confirm('password_confirm'));
 
$passwordConfirm = new Zend_Form_Element_Password('password_confirm');
$passwordConfirm->setLabel('Password Confirm');

Standalone usage is like so:

<?php
// Context value in constructor
$confirm = new Zym_Validate_Confirm('confirm', array('confirm' => 'aValue'));
$isValid = $confirm->isValid('bar');
 
// Context value in isValid
$confirm = new Zym_Validate_Confirm('confirm');
$isValid = $confirm->isValid('bar', array('confirm' => 'aValue'));

13.2.2. Float

A locale-aware float validator.

13.2.3. StringEquals

Validates whether all strings in an array are equal.