Skip to content

[12.x] Fix wildcard validation rules skipping empty array keys - #62409

Merged
taylorotwell merged 1 commit into
laravel:12.xfrom
GrahamCampbell:12.x-empty-wildcard-keys
Nov 11, 2026
Merged

taylorotwell merged 1 commit into
laravel:12.xfrom
GrahamCampbell:12.x-empty-wildcard-keys

Conversation

@GrahamCampbell

Copy link
Copy Markdown
Collaborator

When validated input contains an array element whose key is an empty string, such as {"items": {"": {"name": "..."}}} in a JSON request, the rules attached to items.* are never applied to that element. ValidationRuleParser already matches empty segments with [^\.]*, but ValidationData::extractValuesForWildcards() and Validator::getExplicitKeys() still use [^\.]+, so the element is never gathered and wildcard parameters such as required_if:users.*.role,admin are not resolved for it. Rules like Rule::forEach() or array:name,qty on items.* are silently skipped for that element.

This backports f9c010a from 13.x, which makes both patterns accept empty segments so that they agree with the rule parser, together with its tests.

@taylorotwell
taylorotwell merged commit ab7761b into laravel:12.x Nov 11, 2026
72 checks passed
@GrahamCampbell
GrahamCampbell deleted the 12.x-empty-wildcard-keys branch November 12, 2026 00:31
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