Skip to content

Commit 3a1c4ef

Browse files
authored
Don't return nested data from validator when failing an exclude rule (#33435)
1 parent 7109e0a commit 3a1c4ef

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/Illuminate/Validation/Validator.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,8 @@ protected function shouldBeExcluded($attribute)
369369
*/
370370
protected function removeAttribute($attribute)
371371
{
372-
unset($this->data[$attribute], $this->rules[$attribute]);
372+
Arr::forget($this->data, $attribute);
373+
Arr::forget($this->rules, $attribute);
373374
}
374375

375376
/**

tests/Validation/ValidationValidatorTest.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5153,13 +5153,10 @@ public function providesPassingExcludeIfData()
51535153
'vehicles' => [
51545154
[
51555155
'type' => 'car', 'wheels' => [
5156-
// The shape field for these blue wheels were correctly excluded (if they weren't, they would
5157-
// fail the validation). They still appear in the validated data. This behaviour is unrelated
5158-
// to the "exclude" type rules.
51595156
['color' => 'red', 'shape' => 'square'],
5160-
['color' => 'blue', 'shape' => 'hexagon'],
5157+
['color' => 'blue'],
51615158
['color' => 'red', 'shape' => 'round', 'junk' => 'no rule, still present'],
5162-
['color' => 'blue', 'shape' => 'triangle'],
5159+
['color' => 'blue'],
51635160
],
51645161
],
51655162
['type' => 'boat'],

0 commit comments

Comments
 (0)