42 lines
1.4 KiB
PHP
42 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use App\Http\Requests\Concerns\ValidatesUserOwnedResources;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class UpdateTransactionRequest extends FormRequest
|
|
{
|
|
use ValidatesUserOwnedResources;
|
|
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'category_id' => ['nullable', $this->userOwned('categories')],
|
|
'description' => ['sometimes', 'string'],
|
|
'description_iv' => ['nullable', 'string', 'size:16'],
|
|
'notes' => ['nullable', 'string'],
|
|
'notes_iv' => ['nullable', 'string', 'size:16'],
|
|
'creditor_name' => ['nullable', 'string', 'max:255'],
|
|
'debtor_name' => ['nullable', 'string', 'max:255'],
|
|
'label_ids' => ['nullable', 'array'],
|
|
'label_ids.*' => ['required', 'string', 'uuid', $this->userOwned('labels')],
|
|
];
|
|
}
|
|
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'category_id.exists' => 'The selected category does not exist.',
|
|
'description_iv.size' => 'The description IV must be exactly 16 characters.',
|
|
'notes_iv.size' => 'The notes IV must be exactly 16 characters.',
|
|
'label_ids.*.exists' => 'One or more selected labels do not exist or do not belong to you.',
|
|
];
|
|
}
|
|
}
|