I have two forms, login and signup forms, and one User model, i have set-up my rules and messages in User class, which are static members, $rules and $messages, the problem i face now, is in sign up form everything validate the it should be, but in login form, after i put a correct email and password, it gives me "Password confirmation doesn't match" which it shouldn't because there is no password_confrimation field in the login form.
Rules and Messages in 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'
];
Login action
$validateUser = Validator::make($inputs, User::$rules, User::$messages);
$user = new User();
$user->email = $inputs['email'];
$user->password = $inputs['password'];
I did like this in my project
public static $rules = array(
'email' => 'required|email|unique:users,email',
'password' => 'required|min:6',
'repassword' => 'same:password',
'group' => 'exists:groups,id',
'last_name' => 'required',
'first_name' => 'required',
);
Give it a try .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.