Add nullable types in validation.

This commit is contained in:
James Cole
2023-07-11 08:19:47 +02:00
parent 43ad63fac6
commit 10646099a0

View File

@@ -324,7 +324,7 @@ class UpdateRequest extends FormRequest
return [
// basic fields for group:
'group_title' => 'between:1,1000',
'group_title' => 'between:1,1000|nullable',
'apply_rules' => [new IsBoolean()],
// transaction rules (in array for splits):
@@ -360,7 +360,7 @@ class UpdateRequest extends FormRequest
// budget, category, bill and piggy
'transactions.*.budget_id' => ['mustExist:budgets,id', new BelongsUser()],
'transactions.*.budget_name' => ['between:1,255', 'nullable', new BelongsUser()],
'transactions.*.category_id' => ['mustExist:categories,id', new BelongsUser()],
'transactions.*.category_id' => ['mustExist:categories,id', new BelongsUser(), 'nullable'],
'transactions.*.category_name' => 'between:1,255|nullable',
'transactions.*.bill_id' => ['numeric', 'nullable', 'mustExist:bills,id', new BelongsUser()],
'transactions.*.bill_name' => ['between:1,255', 'nullable', new BelongsUser()],