Skip to content

Conversation

@ragulka
Copy link
Contributor

@ragulka ragulka commented Nov 24, 2025

✏️ Describe the bug
Validation rules referencing other field within a nested data inside an array or Illuminate\Support\Collection do not work. The validation rules only work when using the deprecated DataCollection.

The docs mention that for nesting a collection of data, DataCollection is deprecated and either a simple array and phpdoc, or Illuminate\Support\Collection should be used, instead.

In fact, the docs only show an example of using phpdoc annotation for a collection of data objects in the validation section.

However, it appears that some validation rules simply do not work when using these preferred method. I haven't tested everything, but it seems that rules referencing other fields on the nested Data object do not work.

I'm not sure why, but my hunch is that the validation path is not correctly set when the rules are generated.

↪️ To Reproduce
See the failing tests in the PR.

✅ Expected behavior

Rules referencing other fields on a nested data object contained within an array or Collection on the parent data object work as expected.

🖥️ Versions

Laravel: 12
Laravel Data: 4.18.0
PHP: 8.4

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.

1 participant