7
* This source file is subject to the new BSD license that is bundled
8
* with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://framework.zend.com/license/new-bsd
11
* If you did not receive a copy of the license and are unable to
12
* obtain it through the world-wide-web, please send an email
13
* to license@zend.com so we can send you a copy immediately.
16
* @package Zend_Validate
17
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
18
* @license http://framework.zend.com/license/new-bsd New BSD License
19
* @version $Id: Identical.php 8118 2008-02-18 16:10:32Z matthew $
22
/** Zend_Validate_Abstract */
23
require_once 'Zend/Validate/Abstract.php';
27
* @package Zend_Validate
28
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
29
* @license http://framework.zend.com/license/new-bsd New BSD License
31
class Zend_Validate_Identical extends Zend_Validate_Abstract
37
const NOT_SAME = 'notSame';
38
const MISSING_TOKEN = 'missingToken';
45
protected $_messageTemplates = array(
46
self::NOT_SAME => 'Tokens do not match',
47
self::MISSING_TOKEN => 'No token was provided to match against',
51
* Original token against which to validate
57
* Sets validator options
59
* @param string $token
62
public function __construct($token = null)
64
if (null !== $token) {
65
$this->setToken($token);
70
* Set token against which to compare
72
* @param string $token
73
* @return Zend_Validate_Identical
75
public function setToken($token)
77
$this->_token = (string) $token;
86
public function getToken()
92
* Defined by Zend_Validate_Interface
94
* Returns true if and only if a token has been set and the provided value
97
* @param string $value
100
public function isValid($value)
102
$this->_setValue($value);
103
$token = $this->getToken();
106
$this->_error(self::MISSING_TOKEN);
110
if ($value !== $token) {
111
$this->_error(self::NOT_SAME);