Created
May 15, 2012 11:10
-
-
Save anonymous/2700895 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Validate the word | |
* | |
* @see Zend_Validate_Interface::isValid() | |
* @param mixed $value | |
* @return boolean | |
*/ | |
public function isValid($value, $context = null) | |
{ | |
if (!is_array($value) && !is_array($context)) { | |
$this->_error(self::MISSING_VALUE); | |
return false; | |
} | |
if (!is_array($value) && is_array($context)) { | |
$value = $context; | |
} | |
$name = $this->getName(); | |
if (isset($value[$name])) { | |
$value = $value[$name]; | |
} | |
if (!isset($value['input'])) { | |
$this->_error(self::MISSING_VALUE); | |
return false; | |
} | |
$input = strtolower($value['input']); | |
$this->_setValue($input); | |
if (!isset($value['id'])) { | |
$this->_error(self::MISSING_ID); | |
return false; | |
} | |
$this->_id = $value['id']; | |
if ($input !== $this->getWord()) { | |
$this->_error(self::BAD_CAPTCHA); | |
return false; | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment