* @package tao */ class tao_helpers_form_validators_Password extends tao_helpers_form_Validator { // --- ASSOCIATIONS --- // --- ATTRIBUTES --- // --- OPERATIONS --- /** * Short description of method evaluate * * @access public * @author Joel Bout, * @param values * @return boolean */ public function evaluate($values) { $returnValue = (bool) false; if (is_array($values) && count($values) == 2) { list($first, $second) = $values; $returnValue = $first == $second; } elseif ($this->hasOption('password2_ref')) { $secondElement = $this->getOption('password2_ref'); if (is_null($secondElement) || ! $secondElement instanceof tao_helpers_form_FormElement) { throw new common_Exception("Please set the reference of the second password element"); } if ($values == $secondElement->getRawValue() && trim($values) != '') { $returnValue = true; } } else { throw new common_Exception("Please set the reference of the second password element or provide array of 2 elements"); } return (bool) $returnValue; } protected function getDefaultMessage() { return __('Passwords are not matching'); } }