mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-06 06:01:21 +00:00
Refactor currency validation
This commit is contained in:
@@ -67,6 +67,31 @@ trait GroupValidation
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an error to the "description" field when the user has submitted no descriptions and no
|
||||
* journal description.
|
||||
*
|
||||
* @param Validator $validator
|
||||
*/
|
||||
protected function validateDescriptions(Validator $validator): void
|
||||
{
|
||||
Log::debug('Now in GroupValidation::validateDescriptions()');
|
||||
$transactions = $this->getTransactionsArray($validator);
|
||||
$validDescriptions = 0;
|
||||
foreach ($transactions as $transaction) {
|
||||
if ('' !== (string)($transaction['description'] ?? null)) {
|
||||
$validDescriptions++;
|
||||
}
|
||||
}
|
||||
|
||||
// no valid descriptions?
|
||||
if (0 === $validDescriptions) {
|
||||
$validator->errors()->add(
|
||||
'transactions.0.description', (string)trans('validation.filled', ['attribute' => (string)trans('validation.attributes.description')])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Do the validation required by validateJournalIds.
|
||||
*
|
||||
@@ -86,4 +111,6 @@ trait GroupValidation
|
||||
$validator->errors()->add(sprintf('transactions.%d.source_name', $index), (string) trans('validation.need_id_in_edit'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user