Guest User

Untitled

a guest
Apr 20th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. <?php
  2.  
  3. require_once 'Zend/Validate/Abstract.php';
  4.  
  5. class Application_Validate_FieldMatch extends Zend_Validate_Abstract {
  6.  
  7. const NOT_MATCH = 'notMatch';
  8.  
  9. protected $_messageTemplates = array(
  10. self::NOT_MATCH => 'Fields does not match'
  11. );
  12.  
  13. protected $_target;
  14.  
  15. public function __construct($target) {
  16. $this->_target = $target;
  17. }
  18.  
  19. public function isValid($value, $context = null) {
  20. $value = (string) $value;
  21. $this->_setValue($value);
  22.  
  23. if (is_array($context)) {
  24. if (isset($context[$this->_target]) && ($value == $context[$this->_target])) {
  25. return true;
  26. }
  27. } elseif (is_string($context) && ($value == $context)) {
  28. return true;
  29. }
  30.  
  31. $this->_error(self::NOT_MATCH);
  32. return false;
  33. }
  34. }
Add Comment
Please, Sign In to add comment