rendered paste body<?php
class EDM_Validate_mustMatch extends Zend_Validate_Abstract
{
const NOT_MATCH = 'notMatch';
protected $_field;
protected $_messageTemplates = array(
self::NOT_MATCH => 'Values do not match'
);
public function __construct($field = null)
{
if (null === $field) {
require_once 'Zend/Validate/Exception.php';
throw new Zend_Validate_Exception("Nothing specified for mustMatch Validator");
}
$this->_field = $field;
}
public function isValid($value, $context = null)
{
$value = (string) $value;
$this->_setValue($value);
if (is_array($context)) {
if (isset($context[$this->_field])
&& ($value == $context[$this->_field]))
{
return true;
}
} elseif (is_string($context) && ($value == $context)) {
return true;
}
$this->_error(self::NOT_MATCH);
return false;
}
}