Skip to content

Commit

Permalink
Update Validator.php
Browse files Browse the repository at this point in the history
  • Loading branch information
imanghafoori1 authored Oct 6, 2020
1 parent e45fc87 commit 78d172c
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/Reactions/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ public function __construct(array $validationData)
public function otherwise()
{
$rules = $this->validationData;
$modifier = $this->modifier ?: function ($args) {
return $args;
};

$result = $this->validationPassesCallback($modifier, $rules);
$result = $this->validationPassesCallback($this->getModifier(), $rules);

resolve('heyman.chain')->set('condition', $result);

Expand Down Expand Up @@ -80,11 +76,7 @@ public function __destruct()
}

$data = $this->validationData;
$modifier = $this->modifier ?: function ($args) {
return $args;
};

$condition = $this->validatorCallback($modifier, $data);
$condition = $this->validatorCallback($this->getModifier(), $data);
$chain->set('condition', $condition);

resolve('heyman.chains')->commitChain();
Expand All @@ -97,4 +89,11 @@ private function wrapForIgnore($validator)
{
return resolve(HeyManSwitcher::class)->wrapForIgnorance($validator, 'validation');
}

private function getModifier()
{
return $this->modifier ?: function () {
return request()->all();
};
}
}

0 comments on commit 78d172c

Please sign in to comment.