Validation transalations for array in request #50794
Replies: 1 comment
-
Hi! This is my idea. In your validation language file (resources/lang/en/validation.php for English), add a wildcard message for array validation: 'custom' => [ In your validation logic, you can pass the custom attribute names using the attributes() method: Validator::validate($requestData, [ Make sure to define the attribute name in your validation language file as well: Also, it will be best if you do this in laravel http request. |
Beta Was this translation helpful? Give feedback.
-
Hello,
I'm currently facing challenges with translating Laravel array validation messages.
In my validation logic, I have an array key named 'room_name' that may contain multiple data elements:
Each element in the 'room_name' array corresponds to a room name input field in the HTML form:
I've already added a translation for 'room_name' in the validation language file:
However, this translation only works for the first array element. Is there a way to translate all 'room_name' elements (e.g., room_name.1, room_name.2, ..., room_name.100) with the same translation?
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions