46 lines
1.5 KiB
PHP
46 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Student;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rules\Password;
|
|
|
|
class PasswordUpdateRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'current_password' => ['required', 'current_password'],
|
|
'password' => ['required', Password::defaults(), 'confirmed'],
|
|
'password_confirmation' => ['required'],
|
|
];
|
|
}
|
|
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'current_password.required' => 'Password saat ini harus diisi',
|
|
'current_password.current_password' => 'Password saat ini tidak sesuai',
|
|
'password.required' => 'Password baru harus diisi',
|
|
'password.confirmed' => 'Konfirmasi password baru tidak sesuai',
|
|
'password.min' => 'Password minimal 8 karakter',
|
|
'password.max' => 'Password maksimal 255 karakter',
|
|
'password.regex' => 'Password harus mengandung huruf besar, huruf kecil, angka, dan karakter khusus',
|
|
'password_confirmation.required' => 'Konfirmasi password baru harus diisi',
|
|
];
|
|
}
|
|
}
|