Open
Description
Laravel Version
11.44.2
PHP Version
8.3
Database Driver & Version
No response
Description
Hello everyone,
I've noticed an unexpected behavior when validating empty arrays with nested rules.
Here’s an example without any nested rules, which works as expected:
$validated = Validator::validate(['foo' => []], [
'foo' => 'present|array',
]);
// $validated contains the "foo" key: ["foo" => []]
However, when I add a nested rule:
$validated = Validator::validate(['foo' => []], [
'foo' => 'present|array',
'foo.bar' => 'integer'
]);
// $validated is empty: []
Expected:
the validated values should be the same and contain the "foo" key, since "foo.bar" is not required.
Steps To Reproduce
$validated = Validator::validate(['foo' => []], [
'foo' => 'present|array',
]);
// $validated contains the "foo" key: ["foo" => []]
$validated = Validator::validate(['foo' => []], [
'foo' => 'present|array',
'foo.bar' => 'integer'
]);
// $validated is empty: []