Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

phyothiha96's avatar

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();
}
0 likes
0 replies

Please or to participate in this conversation.