Jul 23, 2021
0
Level 8
Stop validate on other attributes when one of the attribute's rule is break
I am trying to implement it using form request class but I've no idea how to do it. This is the way I implement in the controller method. I want to validate the old_password field later when the password field passed their rules.
public function update_password(Request $request)
{
$validator = Validator::make($request->all(), [
'password' => ['bail', 'required', 'confirmed', 'string', 'min:6']
]);
if($validator->fails()) {
return back()->withErrors($validator)->withInput();
}
Validator::make($request->all(), [
'old_password' => ['required', new MatchOldPassword],
])->validate();
}
Please or to participate in this conversation.