validate email and password in laravel code example
Example 1: email validation in laravel
'email' => 'required|email|unique:users,email',
Example 2: username or email validation in laravel
$input = $request->only('account');
$rules = [
'account' => 'required'
];
if (filter_var($input['account'], FILTER_VALIDATE_EMAIL)) {
$rules['account'] .= '|exists:users,email';
} else {
$rules['account'] .= '|exists:users,username';
}
$messages = [
'account.required' => 'Enter username or email to login.',
];
$validator = Validator::make($input, $rules, $messages);