Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

some small fixes #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/validate.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use Audit;

trait Validate
{
static $extendedValidators = [
Expand Down Expand Up @@ -40,7 +42,7 @@ public abstract function getRules();
public function check($input)
{
$this->errors = [];
$f3 = Base::instance();
$f3 = \Base::instance();
$configValidators = $f3->exists("VALIDATE.validators") ? $f3->get('VALIDATE.validators') : [];
$configErrorMessages = $f3->exists("VALIDATE.errors") ? $f3->get('VALIDATE.errors') : [];
$rules = $this->getRules();
Expand All @@ -53,7 +55,7 @@ public function check($input)
$ruleConfigs = $f3->split($currentRule, false);
$mainRule = $ruleConfigs[0];
$callable = $validators[$mainRule];
if (!$callable) throw new Exception("Validation for $mainRule is missing");
if (!$callable) throw new \Exception("Validation for $mainRule is missing");
array_shift($ruleConfigs);
if ($f3->call($callable, [$value, $ruleConfigs, $input])) continue;
$error = $errorMessages[$mainRule] ? $errorMessages[$mainRule] : Validate::$defaultErrorMessage;
Expand Down