Skip to content

Commit 76118c6

Browse files
committed
fix: if_exist does not work with array data
1 parent b23318c commit 76118c6

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

system/Validation/FormatRules.php

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ class FormatRules
2929
*/
3030
public function alpha($str = null): bool
3131
{
32+
if (is_array($str)) {
33+
return false;
34+
}
35+
3236
if (! is_string($str)) {
3337
$str = (string) $str;
3438
}

system/Validation/Validation.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,11 @@ private function processIfExist(string $field, array $rules, array $data)
400400
}
401401
}
402402
} else {
403-
$dataIsExisting = array_key_exists($ifExistField, $flattenedData);
403+
if (str_contains($field, '.')) {
404+
$dataIsExisting = array_key_exists($ifExistField, $flattenedData);
405+
} else {
406+
$dataIsExisting = array_key_exists($ifExistField, $data);
407+
}
404408
}
405409

406410
if (! $dataIsExisting) {

0 commit comments

Comments
 (0)