当我使用我的php UserController添加此代码时出错,如果删除它,那么它有效!
public function signUp(Request $request){
$this->validate($request,[
'name' => 'required|string|max:255',
'email' => 'required|string|email|max:255',
'password' => 'required|string|min:6',
//'password_confirmation' => 'required|string|min:6|same:password',
]);
}
答案 0 :(得分:1)
将您的确认密码字段重命名为password_confirmation
,docs建议
验证中的字段必须具有foo_confirmation的匹配字段。例如,如果验证字段为password,输入中必须存在匹配的password_confirmation字段。
并按照以下方式进行验证:
$this->validate($request,[
'name' => 'required|string|max:255',
'email' => 'required|string|email|max:255',
'password' => 'required|string|min:6|confirmed',
'password_confirmation' => 'required|string|min:6'
]);
答案 1 :(得分:0)
答案 2 :(得分:0)
试试此代码
$this->validate($request,[
'name' => 'required|string|max:255',
'email' => 'required|string|email|max:255',
'password' => 'required|string|min:6|same:password_confirmation'
]);