Skip to content

Commit

Permalink
Fix StyleCI build (closed #30) (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidePastore authored Oct 15, 2017
1 parent 9788e6d commit 8e4b105
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions src/Validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,29 +121,29 @@ public function __invoke($request, $response, $next)
private function validate($params = [], $validators = [], $actualKeys = [])
{
//Validate every parameters in the validators array
foreach ($validators as $key => $validator) {
$actualKeys[] = $key;
$param = $this->getNestedParam($params, $actualKeys);
if (is_array($validator)) {
$this->validate($params, $validator, $actualKeys);
} else {
try {
$validator->assert($param);
} catch (NestedValidationException $exception) {
if ($this->translator) {
$exception->setParam('translator', $this->translator);
}
if ($this->options['useTemplate']) {
$this->errors[implode('.', $actualKeys)] = [$exception->getMainMessage()];
} else {
$this->errors[implode('.', $actualKeys)] = $exception->getMessages();
}
}
}

//Remove the key added in this foreach
array_pop($actualKeys);
}
foreach ($validators as $key => $validator) {
$actualKeys[] = $key;
$param = $this->getNestedParam($params, $actualKeys);
if (is_array($validator)) {
$this->validate($params, $validator, $actualKeys);
} else {
try {
$validator->assert($param);
} catch (NestedValidationException $exception) {
if ($this->translator) {
$exception->setParam('translator', $this->translator);
}
if ($this->options['useTemplate']) {
$this->errors[implode('.', $actualKeys)] = [$exception->getMainMessage()];
} else {
$this->errors[implode('.', $actualKeys)] = $exception->getMessages();
}
}
}

//Remove the key added in this foreach
array_pop($actualKeys);
}
}

/**
Expand Down

0 comments on commit 8e4b105

Please sign in to comment.