php - How to make Laravel 'confirmed' validator to add errors to the confirmation field? -


by default, laravel 'confirmed' validator adds error message original field , not field contains confirmed value.

'password' => 'required|confirmed|min:8', 

is there simple way extend validator or use trick force show error on confirmation field instead of original field?

if fail enter password twice, error seems more appropriate belong confirmation field , not original password field. or maybe that's our ux analyst getting nitpicky...

one way go use same rule instead of confirmed

// ...  $input = input::all();  $rules = [     'password' => 'required|min:8',     'password_confirmation' => 'required|min:8|same:password', ];  $messages = [     'password_confirmation.same' => 'password confirmation should match password', ]; $validator = validator::make($input, $rules, $messages);  if ($validator->fails()) {     return back()->withinput()->witherrors($validator->messages()); } // ... 

Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Blogger related post gadget image Resize s72-c [ Need Expert Help ] -