/** * Validate input data * * @param array $data * @return boolean */ public function validate(array &$data) { $this->validator->notEmpty(!$this->required); if ($this->multy) { $this->validator = MultyValidator::create($this->validator); } if (!$this->validator->validate($this->name, $this->value, $this->label, $data)) { foreach ($this->validator->getErrors()->all() as $message) { $this->addError($message); } return false; } return true; }
/** * Create validator * @param \BX\Validator\IValidator $validator * @return Multy */ public static function create(IValidator $validator) { $return = parent::create(); $return->setValidator($validator); return $return; }