From f1dac23003c2ad8895136188ea503a63ac6a9710 Mon Sep 17 00:00:00 2001 From: ping-yee <611077101@mail.nknu.edu.tw> Date: Mon, 23 Oct 2023 11:43:30 +0800 Subject: [PATCH] chore: Write out where the problem occur and the preliminary solution. --- system/Validation/Validation.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/system/Validation/Validation.php b/system/Validation/Validation.php index ad95cde7bc6b..fdde5f8b71ee 100644 --- a/system/Validation/Validation.php +++ b/system/Validation/Validation.php @@ -168,6 +168,17 @@ public function run(?array $data = null, ?string $group = null, ?string $dbGroup } if (strpos($field, '*') !== false) { + + // The solution I think is check whether the rule is required and the field is match with the whole array amount. + // If it isn't, We need to fill it up. + // But seems there is the better way? + if (in_array('required', $rules, true) === true) { + dd($data, $field); + } + + // The problem occurs here. + // It'll filter out the array that follow the rule. + // And the after code will all use the filtered array. $values = array_filter(array_flatten_with_dots($data), static fn ($key) => preg_match( '/^' . str_replace(['\.\*', '\*\.'], ['\..+', '.+\.'], preg_quote($field, '/'))