I created the Form Request Validation and I have problem to customize the custom validation message for multiple "unique" validator
I created the function like the documentation says, however it not showing my message instead the default one (email: ["The email has already been taken."])
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'email' => "required|string|email|unique:table1,email|unique:table2,email"
];
}
/**
* Get the error messages for the defined validation rules.
*
* @return array
*/
public function messages()
{
return [
"email.unique:table1,email" => "Error message for table 1",
"email.unique:table2,email" => "Completely different error message for table 2"
];
}
I can output the custom result if I use:
public function messages()
{
return [
"email.unique" => "Same message for table 1 and table 2 error messages"
];
}
however this isn't what i want, i want to custom the message separately, how I supposed to do?