Skip to content

Commit

Permalink
fix -> Validation/Rules.php
Browse files Browse the repository at this point in the history
  • Loading branch information
amirfaramarzi committed Jul 11, 2022
1 parent 95549b4 commit 2036586
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/Validation/Rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,25 @@ protected function required(array $parameters): void
$data = $this->getData($this->data , $parameters['rule']);
if (str_contains($parameters['rule'] , '*') && $data) {
foreach ($data as $index => $item){
if (!$item || !isset($index) || empty($item)){
if (is_string($item) && mb_strlen(trim($item), 'UTF-8') === 0) {
$this->saveError($parameters , $index);
}
if (is_array($item) && count($item) === 0) {
$this->saveError($parameters , $index);
}
if (is_null($item)) {
$this->saveError($parameters , $index);
}
}
return;
}
if (!$data || !isset($data) || empty($data)){
if (is_string($data) && mb_strlen(trim($data), 'UTF-8') === 0) {
$this->saveError($parameters);
}
if (is_array($data) && count($data) === 0) {
$this->saveError($parameters);
}
if (is_null($data)) {
$this->saveError($parameters);
}
}
Expand Down

0 comments on commit 2036586

Please sign in to comment.