Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once 'Zend/Validate/Abstract.php';
- class Application_Validate_FieldMatch extends Zend_Validate_Abstract {
- const NOT_MATCH = 'notMatch';
- protected $_messageTemplates = array(
- self::NOT_MATCH => 'Fields does not match'
- );
- protected $_target;
- public function __construct($target) {
- $this->_target = $target;
- }
- public function isValid($value, $context = null) {
- $value = (string) $value;
- $this->_setValue($value);
- if (is_array($context)) {
- if (isset($context[$this->_target]) && ($value == $context[$this->_target])) {
- return true;
- }
- } elseif (is_string($context) && ($value == $context)) {
- return true;
- }
- $this->_error(self::NOT_MATCH);
- return false;
- }
- }
Add Comment
Please, Sign In to add comment