Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validator wildcard custom attributes break with NestedRules #51784

Closed
owenandrews opened this issue Jun 13, 2024 · 1 comment
Closed

Validator wildcard custom attributes break with NestedRules #51784

owenandrews opened this issue Jun 13, 2024 · 1 comment

Comments

@owenandrews
Copy link
Contributor

owenandrews commented Jun 13, 2024

Laravel Version

11.0

PHP Version

8.3

Database Driver & Version

No response

Description

The Validator class allows for custom attribute strings to be passed in to replace the original attribute name. However, this functionality appears to be broken when using Rule::forEach or anything that relies on NestedRules.

Steps To Reproduce

Create a validator containing a Rule::forEach and custom attributes.

$validator = Validator::make(["items" => [["id" => "Laravel"]]], [
    'items.*' => Rule::forEach(function () {
        return [
            'id' => 'int',
        ];
    }),
],[], [
    'item.*.id' => 'ID',
]);

Expected messages array:

["items.0.id" => ["The ID field must be an integer."]]

Actual messages array:

["items.0.id" => ["The items.0.id field must be an integer."]]
Copy link

Thank you for reporting this issue!

As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub.

If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team.

Thank you!

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

No branches or pull requests

3 participants