Skip to content

Instantly share code, notes, and snippets.

Created May 15, 2012 11:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/2700895 to your computer and use it in GitHub Desktop.
Save anonymous/2700895 to your computer and use it in GitHub Desktop.
/**
* 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