mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Tiny fixes in API
This commit is contained in:
parent
472c1a0c37
commit
8c9bb3addb
@ -94,7 +94,7 @@ abstract class Controller extends BaseController
|
||||
$obj = Carbon::parse($date);
|
||||
} catch (InvalidDateException | InvalidFormatException $e) {
|
||||
// don't care
|
||||
Log::error(sprintf('Invalid date exception in API controller: %s', $e->getMessage()));
|
||||
Log::warn(sprintf('Ignored invalid date "%s" in API controller parameter check: %s', (string) $date, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
$bag->set($field, $obj);
|
||||
|
@ -143,10 +143,12 @@ class StoreRequest extends FormRequest
|
||||
'active' => [new IsBoolean],
|
||||
'repeat_until' => 'nullable|date',
|
||||
'nr_of_repetitions' => 'nullable|numeric|between:1,31',
|
||||
|
||||
'repetitions.*.type' => 'required|in:daily,weekly,ndom,monthly,yearly',
|
||||
'repetitions.*.moment' => 'between:0,10',
|
||||
'repetitions.*.skip' => 'nullable|numeric|between:0,31',
|
||||
'repetitions.*.weekend' => 'numeric|min:1|max:4',
|
||||
|
||||
'transactions.*.description' => 'required|between:1,255',
|
||||
'transactions.*.amount' => 'required|numeric|gt:0',
|
||||
'transactions.*.foreign_amount' => 'nullable|numeric|gt:0',
|
||||
|
@ -155,33 +155,34 @@ class UpdateRequest extends FormRequest
|
||||
'first_date' => 'date',
|
||||
'apply_rules' => [new IsBoolean],
|
||||
'active' => [new IsBoolean],
|
||||
'repeat_until' => 'date',
|
||||
'nr_of_repetitions' => 'numeric|between:1,31',
|
||||
'repeat_until' => 'nullable|date',
|
||||
'nr_of_repetitions' => 'nullable|numeric|between:1,31',
|
||||
|
||||
'repetitions.*.type' => 'in:daily,weekly,ndom,monthly,yearly',
|
||||
'repetitions.*.moment' => 'between:0,10',
|
||||
'repetitions.*.skip' => 'numeric|between:0,31',
|
||||
'repetitions.*.weekend' => 'numeric|min:1|max:4',
|
||||
'repetitions.*.skip' => 'nullable|numeric|between:0,31',
|
||||
'repetitions.*.weekend' => 'nullable|numeric|min:1|max:4',
|
||||
|
||||
'transactions.*.description' => 'between:1,255',
|
||||
'transactions.*.amount' => 'numeric|gt:0',
|
||||
'transactions.*.foreign_amount' => 'numeric|gt:0',
|
||||
'transactions.*.currency_id' => 'numeric|exists:transaction_currencies,id',
|
||||
'transactions.*.currency_code' => 'min:3|max:3|exists:transaction_currencies,code',
|
||||
'transactions.*.foreign_currency_id' => 'numeric|exists:transaction_currencies,id',
|
||||
'transactions.*.foreign_currency_code' => 'min:3|max:3|exists:transaction_currencies,code',
|
||||
'transactions.*.foreign_amount' => 'nullable|numeric|gt:0',
|
||||
'transactions.*.currency_id' => 'nullable|numeric|exists:transaction_currencies,id',
|
||||
'transactions.*.currency_code' => 'nullable|min:3|max:3|exists:transaction_currencies,code',
|
||||
'transactions.*.foreign_currency_id' => 'nullable|numeric|exists:transaction_currencies,id',
|
||||
'transactions.*.foreign_currency_code' => 'nullable|min:3|max:3|exists:transaction_currencies,code',
|
||||
'transactions.*.source_id' => ['numeric', 'nullable', new BelongsUser],
|
||||
'transactions.*.source_name' => 'between:1,255|nullable',
|
||||
'transactions.*.destination_id' => ['numeric', 'nullable', new BelongsUser],
|
||||
'transactions.*.destination_name' => 'between:1,255|nullable',
|
||||
|
||||
// new and updated fields:
|
||||
'transactions.*.budget_id' => ['mustExist:budgets,id', new BelongsUser],
|
||||
'transactions.*.budget_id' => ['nullable','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' => ['nullable','mustExist:categories,id', new BelongsUser],
|
||||
'transactions.*.category_name' => 'between:1,255|nullable',
|
||||
'transactions.*.piggy_bank_id' => ['numeric', 'mustExist:piggy_banks,id', new BelongsUser],
|
||||
'transactions.*.piggy_bank_id' => ['nullable','numeric', 'mustExist:piggy_banks,id', new BelongsUser],
|
||||
'transactions.*.piggy_bank_name' => ['between:1,255', 'nullable', new BelongsUser],
|
||||
'transactions.*.tags' => 'between:1,64000',
|
||||
'transactions.*.tags' => 'nullable|between:1,64000',
|
||||
|
||||
];
|
||||
}
|
||||
|
@ -303,7 +303,7 @@ class RecurrenceUpdateService
|
||||
$this->setCategory($match, (int)$current['category_id']);
|
||||
}
|
||||
|
||||
if (array_key_exists('tags', $current)) {
|
||||
if (array_key_exists('tags', $current) && is_array($current['tags'])) {
|
||||
$this->updateTags($match, $current['tags']);
|
||||
}
|
||||
if (array_key_exists('piggy_bank_id', $current)) {
|
||||
|
@ -93,7 +93,7 @@ trait RecurrenceValidation
|
||||
// validate source account.
|
||||
$sourceId = array_key_exists('source_id', $transaction) ? (int)$transaction['source_id'] : null;
|
||||
$sourceName = $transaction['source_name'] ?? null;
|
||||
$validSource = $accountValidator->validateSource($sourceId, $sourceName, null);
|
||||
$validSource = $accountValidator->validateSource(['id' => $sourceId, 'name' => $sourceName]);
|
||||
|
||||
// do something with result:
|
||||
if (false === $validSource) {
|
||||
|
Loading…
Reference in New Issue
Block a user