电子邮件验证在Laravel表单验证中不起作用

时间:2016-08-15 09:31:20

标签: php validation email laravel-5.2

我几乎尝试了所有可能性,但电子邮件验证无法在表单验证中使用,并且需要对MySQL所需的唯一电子邮件进行例外处理。

public function rules()
{
    return  [
        'email'=>"required|email|unique:users,email",
        'password' => "required|min:6",
        'first_name' => "required",
        'last_name'=>"required",
        'country'=>"required",
        'city'=>"required",
        'is_willing_to_relocate'=>"required",
        'min_gross_salary'=>"required|integer|min:0",
        'max_gross_salary'=>"required|integer|min:0",
        'skills'=>'required|json|objCount',
        'languages'=>'required|json|objCount',
        'professions'=>'required|json|objCount',
        'cities'=>'required_if:is_willing_to_relocate,yes|json|objCount'
    ];
}

1 个答案:

答案 0 :(得分:0)

我认为你应该这样验证:

public function postSignUp(Request $request)
{
    $this->validate($request,[
        'email' => 'required|email|unique:users' ,
    ]);
}