feat(webstatement): tambah validasi password wajib untuk request_type tertentu
Perubahan yang dilakukan: - Menambahkan validasi pada PrintStatementRequest agar password wajib diisi jika field request_type tidak kosong. - Menggunakan closure function kustom untuk validasi kondisional password. - Menambahkan pesan error khusus yang informatif dan user-friendly untuk validasi password. - Memperbarui validasi request_type agar mendukung tipe multi_account. - Mengimplementasikan validasi fleksibel tanpa mengganggu kompatibilitas sistem yang sudah ada. - Menambahkan lapisan keamanan tambahan untuk request yang memerlukan proteksi PDF. Tujuan perubahan: - Memastikan keamanan data dengan mewajibkan password pada jenis request tertentu. - Memberikan umpan balik yang jelas kepada pengguna saat input tidak valid. - Menjaga fleksibilitas sistem untuk mendukung berbagai tipe request di masa depan.
This commit is contained in:
@@ -40,8 +40,19 @@ class PrintStatementRequest extends FormRequest
|
|||||||
'is_period_range' => ['sometimes', 'boolean'],
|
'is_period_range' => ['sometimes', 'boolean'],
|
||||||
'email' => ['nullable', 'email'],
|
'email' => ['nullable', 'email'],
|
||||||
'email_sent_at' => ['nullable', 'timestamp'],
|
'email_sent_at' => ['nullable', 'timestamp'],
|
||||||
'request_type' => ['sometimes', 'string', 'in:single_account,branch,all_branches'],
|
'request_type' => ['sometimes', 'string', 'in:single_account,branch,all_branches,multi_account'],
|
||||||
'batch_id' => ['nullable', 'string'],
|
'batch_id' => ['nullable', 'string'],
|
||||||
|
// Password wajib diisi jika request_type diisi
|
||||||
|
'password' => [
|
||||||
|
function ($attribute, $value, $fail) {
|
||||||
|
$requestType = $this->input('request_type');
|
||||||
|
|
||||||
|
// Jika request_type diisi, maka password wajib diisi
|
||||||
|
if (!empty($requestType) && empty($value)) {
|
||||||
|
$fail('Password is required when request type is specified.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
'period_from' => [
|
'period_from' => [
|
||||||
'required',
|
'required',
|
||||||
'string',
|
'string',
|
||||||
@@ -108,7 +119,8 @@ class PrintStatementRequest extends FormRequest
|
|||||||
'period_to.required' => 'End period is required for period range',
|
'period_to.required' => 'End period is required for period range',
|
||||||
'period_to.regex' => 'End period must be in YYYYMM format',
|
'period_to.regex' => 'End period must be in YYYYMM format',
|
||||||
'period_to.gte' => 'End period must be after or equal to start period',
|
'period_to.gte' => 'End period must be after or equal to start period',
|
||||||
'request_type.in' => 'Request type must be single_account, branch, or all_branches',
|
'request_type.in' => 'Request type must be single_account, branch, all_branches, or multi_account',
|
||||||
|
'password.required' => 'Password is required when request type is specified',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user