Skip to content

Conversation

@fgaroby
Copy link
Contributor

@fgaroby fgaroby commented Nov 5, 2025

This PR allows to use the sub-array notation, in addition to the dot notation.
For example, instead of this:

class NestedArrayRequest extends FormRequest
{
    public function rules()
    {
        return [
            'nested.*.bar' => 'required',
            'nested.*.baz' => 'required'
        ];
    }
}

We can now do this:

class SubArrayRequest extends FormRequest
{
    public function rules()
    {
        return [
            'nested' => [
                '*' => [
                    'bar' => 'required',
                    'baz' => 'required',
                ],
            ],
        ];
    }
}

Usefull when the sub-array has many sub-fields.

Of course, the nested notation still works.

If this PR is OK, I also created a PR to improve the Laravel documentation.

@fgaroby fgaroby changed the title feat: allow sub-array notation in arrays validation [12.x] Allow sub-array notation in arrays validation Nov 5, 2025
@fgaroby fgaroby changed the title [12.x] Allow sub-array notation in arrays validation Draft: [12.x] Allow sub-array notation in arrays validation Nov 5, 2025
@fgaroby fgaroby changed the title Draft: [12.x] Allow sub-array notation in arrays validation [12.x] Allow sub-array notation in arrays validation Nov 5, 2025
@fgaroby fgaroby marked this pull request as draft November 5, 2025 10:25
@shaedrich
Copy link
Contributor

I already attempted something similar a while ago in #55491, so don't get your hopes up. That being said, it'd be nice to have this in Laravel, so 🤞🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants