mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-05 12:12:18 +00:00
Refactor group validation
This commit is contained in:
@@ -39,7 +39,7 @@ trait CurrencyValidation
|
||||
* @return array
|
||||
*/
|
||||
abstract protected function getTransactionsArray(Validator $validator): array;
|
||||
|
||||
|
||||
/**
|
||||
* If the transactions contain foreign amounts, there must also be foreign currency information.
|
||||
*
|
||||
|
@@ -113,4 +113,20 @@ trait GroupValidation
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Validator $validator
|
||||
*/
|
||||
protected function validateGroupDescription(Validator $validator): void
|
||||
{
|
||||
Log::debug('Now in validateGroupDescription()');
|
||||
$data = $validator->getData();
|
||||
$transactions = $this->getTransactionsArray($validator);
|
||||
|
||||
$groupTitle = $data['group_title'] ?? '';
|
||||
if ('' === $groupTitle && count($transactions) > 1) {
|
||||
$validator->errors()->add('group_title', (string) trans('validation.group_title_mandatory'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -160,21 +160,6 @@ trait TransactionValidation
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Validator $validator
|
||||
*/
|
||||
public function validateGroupDescription(Validator $validator): void
|
||||
{
|
||||
Log::debug('Now in validateGroupDescription()');
|
||||
$data = $validator->getData();
|
||||
$transactions = $this->getTransactionsArray($validator);
|
||||
|
||||
$groupTitle = $data['group_title'] ?? '';
|
||||
if ('' === $groupTitle && count($transactions) > 1) {
|
||||
$validator->errors()->add('group_title', (string)trans('validation.group_title_mandatory'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an error to the validator when there are no transactions in the array of data.
|
||||
*
|
||||
|
Reference in New Issue
Block a user