Replies: 2 comments
-
|
In our project, we needed to make validation messages more readable for nested DTO collections. This automatically expands all * wildcards in attribute definitions before building the validator — making the validation messages consistent with Laravel’s own wildcard behavior. |
Beta Was this translation helpful? Give feedback.
-
|
Sample of implemetation of our custom Resolver |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently, Spatie\LaravelData supports defining custom attribute names in validation messages using the attributes key via the DataValidationMessagesAndAttributesResolver.
However, wildcarded attributes such as users.*.email are not expanded automatically into explicit attribute names like users.0.email, users.1.email, etc.
This means when using nested data collections, custom labels are not applied to individual elements — resulting in default attribute paths (users.0.email) appearing in error messages.
I would suggest to automatically expand wildcard attribute definitions based on the incoming payload before validation runs.
Beta Was this translation helpful? Give feedback.
All reactions