Laravel自定义验证确认密码

时间:2017-07-05 14:40:09

标签: php laravel validation laravel-5

我必须对确认密码进行后端验证。我把我的验证器写成

$validator = Validator::make($request->all(), [
    'first_name' => 'required',
    'last_name' => 'required',
    'email' => 'email|required',
    'password' => 'required',
    'confirm_password' => 'required',
    'tnc' => 'required'
]);

现在确认密码必须与密码字段相同。我们可以用laravel验证器吗?

1 个答案:

答案 0 :(得分:3)

'password'  =>  'required|min:6|confirmed',
'confirm_password'  =>  'required|min:6|confirmed',

试试这个