First commit
This commit is contained in:
42
app/Http/Requests/Admin/UpdateChunkRequest.php
Normal file
42
app/Http/Requests/Admin/UpdateChunkRequest.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Admin;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateChunkRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
// Hanya admin yang boleh edit chunk
|
||||
return auth()->check() && auth()->user()->role === 'admin';
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'final_text' => ['required', 'string', 'min:20', 'max:10000'],
|
||||
'notes' => ['nullable', 'string', 'max:500'],
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'final_text.required' => 'final_text tidak boleh kosong.',
|
||||
'final_text.min' => 'final_text terlalu pendek. Minimum 20 aksara diperlukan untuk embedding bermakna.',
|
||||
'final_text.max' => 'final_text terlalu panjang. Maksimum 10,000 aksara.',
|
||||
'notes.max' => 'Nota tidak boleh melebihi 500 aksara.',
|
||||
];
|
||||
}
|
||||
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
// Trim whitespace pada final_text sebelum validasi
|
||||
if ($this->has('final_text')) {
|
||||
$this->merge([
|
||||
'final_text' => trim($this->input('final_text')),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user