public function check($data) { $errors = array(); foreach ($this->validators as $v) { try { $v->check($data); } catch (ValidationError $e) { $errors[$v->codename] = $e->getErrors(); } } if (count($errors) > 0) { $e = new ValidationError("Hay errores en los datos"); $e->setErrors($errors); throw $e; } }
/** * Run the validation set. */ public function check(array $data) { $this->value = $this->arrGet($this->codename, $data, $this->defaultInput); $this->isNull = is_null($this->value); $this->isBlank = !$this->isNull && !is_array($this->value) && strlen($this->value) === 0; $this->isEmpty = $this->isNull || $this->isBlank; $this->cleanedValue = $this->clean(); $this->applyApply(); // Perform the validations on the input. $errors = $this->baseCheck(); foreach ($this->v as $k => $v) { $method = $k . "Check"; if ($msg = $this->{$method}($data)) { $errors[] = $msg; } } if (count($errors) > 0) { $e = new ValidationError("El valor es inválido"); $e->setErrors($errors); throw $e; } }