Skip to content

Commit a8ee7c4

Browse files
committed
修复过滤多余字段bug
1 parent 421345e commit a8ee7c4

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/Aspect/ValidationAspect.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,16 @@ private function validationData($validation, $verData, $class, $proceedingJoinPo
112112
};
113113

114114
if ($validation->filter) {
115-
foreach ($rules as $key => $item) {
116-
if (isset($verData[$key]) && $verData[$key] === null) {
117-
unset($verData[$key]);
115+
$fields = [];
116+
foreach ($rules as $field => $rule) {
117+
if (is_numeric($field)) {
118+
$field = $rule;
118119
}
120+
$fields[] = $field;
119121
}
122+
$verData = array_filter($verData, function ($value, $key) use ($fields) {
123+
return in_array($key, $fields);
124+
}, ARRAY_FILTER_USE_BOTH);
120125

121126
switch ($isRequest) {
122127
case true:

0 commit comments

Comments
 (0)