I am using this code for validating a field.
$this->validate($request, [
'recovery_code' => 'required|exists:users,email_recovery_code',
'new_password'=>'required',
'confirm_password'=>'required|same:new_password',
]);
and when I enter wrong recovery code i get response
"The selected recovery code is invalid"
but in place of that I want my custom message. Does anyone know how to do it?
Its simple, Just do as like this:
$messages = [
'exists' => 'Your custom message',
];
$this->validate($request, [
'recovery_code' => 'required|exists:users,email_recovery_code',
'new_password'=>'required',
'confirm_password'=>'required|same:new_password',
],$messages);
You can set multiple checks on same field in laravel. Just pass them in an array with different key. e.g: exists, required, etc.
Hope it helps you.
Cheers :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With