array validation messages with key

Posted 7 months ago by basvandertogt

Is there a way to make the array validation messages more clear to the user?


Validator::make($rows->toArray(), [
            '*.initials' => 'required|max:10',
            '*.first_name' => 'max:50',
            '*.prefixes' => 'max:10',
            '*.last_name' => 'required|max:50',
            '*.email' => 'required|email|unique:users,email'

Returns messages like: The has already been taken.

I can add to the attributes array in validation.php but that only returns the field name. I prefer to return the key as well to clarify on which row the error is.

This error message is what i like to see: The E-mailadress on row 1 has already been taken.

Regards, Bas

Please sign in or create an account to participate in this conversation.