When customising Laravel 5.7 validation attributes, is it possible to include wildcards in the attribute names? I can't determine the correct way to indicate a wildcard here.
I have a contacts page which lists the details of a particular contact including all of their phone numbers and emails. From this page you can edit each of these, and add new ones. As such I've used a foreach statement to display each of these and included their id numbers in the form field names, ie:
- phone_areacode_{{ $number->id }}
- phone_number_{{ $number->id }}
- phone_extension_{{ $number->id }}
This makes their names unique and means I can display the error messages relevant only to the specific number or email being edited when validation fails. However, the error messages that display include the number so I get things like "The phone areacode 10 format is invalid." or "The phone number 27 may not be greater than 20 characters."
Is there a way to use wildcards in the attribute names when defining them in the validation language file? Basically I'd like to be able to do this:
'attributes' => [
'phone_areacode_*.*' => 'phone areacode',
],
If not, how can I define the attribute names in the @update method of my controller?