Skip to content

Commit

Permalink
bug fix in validation
Browse files Browse the repository at this point in the history
  • Loading branch information
amirfaramarzi committed Aug 5, 2021
1 parent e3363c3 commit 3f9b929
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/Validation/Rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,28 @@ protected function regex(array $parameters): void

protected function max(array $parameters): void
{
if ($this->request->input($parameters['ruleName']) && $this->strlen($this->request->input($parameters['ruleName'])) > $parameters['value'])
if ($this->request->input($parameters['ruleName']) && is_string($this->request->input($parameters['ruleName'])) && $this->strlen($this->request->input($parameters['ruleName'])) > $parameters['value'])
array_push($this->messages , $parameters['message']);

if ($this->request->input($parameters['ruleName']) && is_int($this->request->input($parameters['ruleName'])) && $this->request->input($parameters['ruleName']) > $parameters['value'])
array_push($this->messages , $parameters['message']);
}

protected function min(array $parameters): void
{
if ($this->request->input($parameters['ruleName']) && $this->strlen($this->request->input($parameters['ruleName'])) < $parameters['value'])
if ($this->request->input($parameters['ruleName']) && is_string($this->request->input($parameters['ruleName'])) && $this->strlen($this->request->input($parameters['ruleName'])) < $parameters['value'])
array_push($this->messages , $parameters['message']);

if ($this->request->input($parameters['ruleName']) && is_int($this->request->input($parameters['ruleName'])) && $this->request->input($parameters['ruleName']) < $parameters['value'])
array_push($this->messages , $parameters['message']);
}

protected function size(array $parameters): void
{
if ($this->request->input($parameters['ruleName']) && $this->strlen($this->request->input($parameters['ruleName'])) != $parameters['value'])
if ($this->request->input($parameters['ruleName']) && is_string($this->request->input($parameters['ruleName'])) && $this->strlen($this->request->input($parameters['ruleName'])) != $parameters['value'])
array_push($this->messages , $parameters['message']);

if ($this->request->input($parameters['ruleName']) && is_int($this->request->input($parameters['ruleName'])) && $this->request->input($parameters['ruleName']) != $parameters['value'])
array_push($this->messages , $parameters['message']);
}

Expand Down

0 comments on commit 3f9b929

Please sign in to comment.