Skip to content

Fix validation of keyed collections with dotted array keys - #1199

Closed
lazerg wants to merge 1 commit into
spatie:mainfrom
lazerg:fix/issue-1198-dotted-collection-keys
Closed

lazerg wants to merge 1 commit into
spatie:mainfrom
lazerg:fix/issue-1198-dotted-collection-keys

Conversation

@lazerg

@lazerg lazerg commented Jul 6, 2026

Copy link
Copy Markdown

Fixes #1198

When a keyed collection (array<string, ChildData>) has array keys containing literal dots, validation reports the fields as missing. The static rules path added in #1043 builds the rule key from the raw array key, so key.with.dots gets treated as nested path segments (items.key.with.dots.string) instead of one key.

This escapes the dots in the collection key so the rule key becomes items.key\.with\.dots.string, matching how the dynamic Rule::forEach path already handles it.

@ropi-bc

ropi-bc commented Jul 6, 2026

Copy link
Copy Markdown

Thanks for jumping on it

@lazerg

lazerg commented Aug 22, 2026

Copy link
Copy Markdown
Author

Hi @rubenvanassche, just a gentle follow-up. It has been two weeks since my last ping. Could you take a look when you have a moment? Thanks!

@lazerg lazerg closed this by deleting the head repository Aug 26, 2026
@cativo23

cativo23 commented Sep 9, 2026

Copy link
Copy Markdown

Found the same fix working #1198 and saw this after. Going to open a PR with the same one-line change plus a regression test, linked from here. All credit for the diagnosis is yours — if you'd rather reopen this one instead, happy to hand over the test.

@lazerg

lazerg commented Sep 9, 2026

Copy link
Copy Markdown
Author

Go ahead with #1206. No need to reopen mine, since yours already carries the regression test.

The diagnosis holds. #1043 builds the rule key from the raw array key, so a literal dot becomes a path separator. The Rule::forEach path escapes it already, which is why an empty rules() hides the bug. Escaping inside resolveStaticCollectionRules is the right spot, because ValidationPath is also used for MapName and rule keys that contain dots on purpose.

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.

Dots inside array keys break validation of keyed collections

3 participants