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

[9.x] Allow validator messages to use nested arrays #43981

Merged
merged 4 commits into from
Sep 5, 2022
Merged

[9.x] Allow validator messages to use nested arrays #43981

merged 4 commits into from
Sep 5, 2022

Conversation

ollieread
Copy link
Contributor

@ollieread ollieread commented Sep 2, 2022

This PR allows for validator messages to be nested without the dot notation.

Here's an example of the current way of providing custom messages.

[
   'attribute.rule1' => 'message1',
   'attribute.rule2' => 'message2',
   'attribute.rule3' => 'message3',
   'attribute.rule4' => 'message4',
   'attribute.rule5' => 'message5',
]

This PR makes it possible to nest the rule => message elements.

[
   'attribute' => [
       'rule1' => 'message1',
       'rule2' => 'message2',
       'rule3' => 'message3',
       'rule4' => 'message4',
       'rule5' => 'message5',
    ]
]

The idea is that it makes it easier to read and identify.

@nunomaduro nunomaduro changed the title Allow validator messages to use nested arrays [9.x] Allow validator messages to use nested arrays Sep 2, 2022
@taylorotwell taylorotwell merged commit 78289b4 into laravel:9.x Sep 5, 2022
@siarheipashkevich
Copy link
Contributor

@ollieread will it work for FormRequest attributes?

@ollieread
Copy link
Contributor Author

ollieread commented Sep 5, 2022

@ollieread will it work for FormRequest attributes?

@siarheipashkevich that's specifically why I created it, working for all validators was a side effect.

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.

3 participants