Skip to content

Commit

Permalink
Fix: shouldConvertToBoolean when parameter uses dot notation (#53048)
Browse files Browse the repository at this point in the history
  • Loading branch information
bytestream authored Oct 8, 2024
1 parent bc02689 commit b6a5179
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Illuminate/Validation/Concerns/ValidatesAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -2259,7 +2259,7 @@ public function parseDependentRuleParameters($parameters)
*/
protected function shouldConvertToBoolean($parameter)
{
return in_array('boolean', Arr::get($this->rules, $parameter, []));
return in_array('boolean', $this->rules[$parameter] ?? []);
}

/**
Expand Down
8 changes: 8 additions & 0 deletions tests/Validation/ValidationValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1696,6 +1696,14 @@ public function testRequiredIf()
$this->assertTrue($v->fails());
$this->assertCount(1, $v->messages());
$this->assertSame('The baz field is required when foo is empty.', $v->messages()->first('baz'));

$trans = $this->getIlluminateArrayTranslator();
$v = new Validator(
$trans,
['foo' => 'bar', 'customfield' => ['1' => 'taylor']],
['customfield' => ['nullable', 'array'], 'foo' => 'required_if:customfield.1,taylor']
);
$this->assertTrue($v->passes());
}

public function testRequiredIfArrayToStringConversationErrorException()
Expand Down

0 comments on commit b6a5179

Please sign in to comment.