49 lines
1.4 KiB
PHP
49 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Illuminate\Validation\Rules\Password;
|
|
|
|
class LoginRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return !Auth::check();
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'email' => ['required', 'email'],
|
|
'password' => ['required' => Password::min(8)
|
|
->mixedCase()
|
|
->numbers()
|
|
->symbols()]
|
|
];
|
|
}
|
|
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'email.required' => 'Email wajib diisi!',
|
|
'email.email' => 'Format email yang dimasukkan tidak valid!',
|
|
'password.required' => 'Password wajib diisi!',
|
|
'password.string' => 'Password harus berupa teks (string)!',
|
|
'password.min' => 'Password harus memiliki minimal 8 karakter!',
|
|
'password.mixedCase' => 'Password harus mengandung huruf besar dan huruf kecil!',
|
|
'password.numbers' => 'Password harus mengandung angka!',
|
|
'password.symbols' => 'Password harus mengandung simbol!',
|
|
];
|
|
}
|
|
}
|