/** * Check whether $value is a valid CSRF token * * @param string $value The value to check * @param mixed $context Context to use * * @return bool True, in case the CSRF token is valid * * @throws InvalidCSRFTokenException In case the CSRF token is not valid */ public function isValid($value, $context = null) { if (parent::isValid($value, $context) && $this->isValidCsrfToken($value)) { return true; } throw new InvalidCSRFTokenException(); }
/** * (non-PHPDoc) * @see \Zend_Form_Element::isValid() For the method documentation. */ public function isValid($value, $context = null) { $this->setValue($value); $value = $this->getValue(); if (!is_numeric($value)) { $this->addError(sprintf($this->translate('\'%s\' is not a valid number'), $value)); return false; } return parent::isValid($value, $context); }
/** * Is the date and time valid? * * @param string|DateTime $value * @param mixed $context * * @return bool */ public function isValid($value, $context = null) { if (!parent::isValid($value, $context)) { return false; } if (!$value instanceof DateTime) { $format = $this->getFormat(); $dateTime = DateTime::createFromFormat($format, $value); if ($dateTime === false) { $dateTime = DateTime::createFromFormat(substr($format, 0, strrpos($format, ':')), $value); } $this->setValue($dateTime); } return true; }