/** * Whether the input is valid or not. * * @param bool $revalid Re-valid or not. * @param mixed $value Value to test. * @return bool */ public function isValid($revalid = false, $value) { if (false === $revalid && null !== $this->_validity) { return $this->_validity; } $this->_validity = true; if ((null === $value || '' === $value || [] === $value) && true === $this->attributeExists('required')) { $this->_validity = false; return Form::postValidation($this->_validity, $value, $this); } if (empty($value)) { $this->_validity = true; return Form::postValidation($this->_validity, $value, $this); } if (is_array($value)) { if (false === $this->attributeExists('multiple')) { $this->_validity = false; return Form::postValidation($this->_validity, $value, $this); } } else { $value = [$value]; } foreach ($this->getOptions() as $option) { $option = $this->getConcreteElement($option); if (false === $option->attributeExists('value')) { continue; } $handle = $option->readAttribute('value'); if (false !== ($i = array_search($handle, $value))) { unset($value[$i]); } } $this->_validity = empty($value); return Form::postValidation($this->_validity, $value, $this); }
/** * Whether the input is valid or not. * * @param bool $revalid Re-valid or not. * @param mixed $value Value to test. * @return bool */ public function isValid($revalid = false, $value) { if (false === $revalid && null !== $this->_validity) { return $this->_validity; } $this->_validity = $value === $this->readAttribute('value'); return Form::postValidation($this->_validity, $value, $this); }
/** * Whether the input is valid or not. * * @param bool $revalid Re-valid or not. * @param mixed $value Value to test. * @return bool */ public function isValid($revalid = false, $value) { return Form::postValidation(true, $value, $this); }