Laravel Password & Password_Confirmation Validation

前端 未结 7 1571
甜味超标
甜味超标 2020-12-23 17:16

I\'ve been using this in order to edit the User Account Info:

$this->validate($request, [
    \'password\' => \'min:6\',
    \'password_confirmation\'          


        
7条回答
  •  攒了一身酷
    2020-12-23 18:11

    It should be enough to do:

    $this->validate($request, [
        'password' => 'sometimes,min:6,confirmed,required_with:password_confirmed',
    ]);
    

    Make password optional, but if present requires a password_confirmation that matches, also make password required only if password_confirmed is present

提交回复
热议问题