Skip to content

Commit

Permalink
fix: if_exist does not work with array data
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Jun 12, 2024
1 parent 33477f8 commit 1ca24da
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions system/Validation/FormatRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ class FormatRules
*/
public function alpha($str = null): bool
{
if (is_array($str)) {
return false;
}

if (! is_string($str)) {
$str = (string) $str;
}
Expand Down
4 changes: 3 additions & 1 deletion system/Validation/Validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,10 @@ private function processIfExist(string $field, array $rules, array $data)
break;
}
}
} else {
} elseif (str_contains($field, '.')) {
$dataIsExisting = array_key_exists($ifExistField, $flattenedData);
} else {
$dataIsExisting = array_key_exists($ifExistField, $data);
}

if (! $dataIsExisting) {
Expand Down

0 comments on commit 1ca24da

Please sign in to comment.