0
我有兩種形式,登錄和註冊表單,以及一個User模型,我在User類中設置了我的規則和消息,它們是靜態成員,$ rules和$ messages,現在我面臨的問題是符號在登錄表單中,在我輸入正確的電子郵件和密碼後,它會給我「密碼確認不匹配」,它不應該是因爲登錄表單中沒有password_confrimation字段。Laravel驗證登錄表單驗證在密碼配置中失敗?
規則和消息的usermodel
public static $rules = [
'email' => 'required|email',
'password' => 'sometimes|required|confirmed',
'password_confirmation' => 'sometimes|required'
];
public static $messages = [
'email.required' => 'The email is required',
'email.email' => 'the email attribute is not in a email format',
'password.required' => 'the password is required'
];
登錄行動
$validateUser = Validator::make($inputs, User::$rules, User::$messages);
$user = new User();
$user->email = $inputs['email'];
$user->password = $inputs['password'];
也許最好是爲登錄和註冊定義單獨的驗證規則?我在我的用戶模型中保留註冊規則,並在我的SessionsController中保留登錄規則。 – 2014-09-24 11:08:51