/** * @param mixed $value * * @return bool */ public function validate($value) { if (!trim($value)) { $this->addError(L10n::msg('Value is empty.')); } return !$this->getErrorStack()->hasErrors(); }
/** * @param string $id * @throws \Loo\Exception\InvalidTypeException */ public function __construct($id) { parent::__construct($id); $this->setMethod(Request::POST); $this->add($this->getElementFactory()->getInputText('name', 'Name')->addAttributes(['placeholder' => L10n::msg('Name'), 'required', 'autofocus'])); $this->add($this->getElementFactory()->getInputPassword('password', 'Password')->addAttributes(['placeholder' => L10n::msg('Password'), 'required'])); $this->add($this->getElementFactory()->getSubmit('submit', L10n::msg('Login'))); }
/** * @param string $value * * @return bool */ public function validate($value) { if (strlen($value) < $this->min) { $this->addError(L10n::msg('Value is too short')); } elseif (strlen($value) > $this->max) { $this->addError(L10n::msg('Value is too long')); } return !$this->getErrorStack()->hasErrors(); }