mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-05 12:12:18 +00:00
Code and tests for #1450
This commit is contained in:
@@ -31,6 +31,7 @@ use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Models\PiggyBank;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use FireflyIII\Services\Password\Verifier;
|
||||
@@ -40,7 +41,6 @@ use Google2FA;
|
||||
use Illuminate\Contracts\Encryption\DecryptException;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Validation\Validator;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class FireflyValidator.
|
||||
@@ -249,9 +249,10 @@ class FireflyValidator extends Validator
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function validateRuleActionValue(string $attribute, string $value): bool
|
||||
public function validateRuleActionValue(string $attribute, string $value = null): bool
|
||||
{
|
||||
// first, get the index from this string:
|
||||
$value = $value ?? '';
|
||||
$parts = explode('.', $attribute);
|
||||
$index = (int)($parts[1] ?? '0');
|
||||
|
||||
@@ -287,6 +288,18 @@ class FireflyValidator extends Validator
|
||||
return null !== $bill;
|
||||
}
|
||||
|
||||
// if it's convert_transfer, it must be a valid asset account name.
|
||||
if ('convert_transfer' === $actionType) {
|
||||
/** @var AccountRepositoryInterface $repository */
|
||||
$repository = app(AccountRepositoryInterface::class);
|
||||
$account = $repository->findByName($value,
|
||||
[AccountType::DEFAULT, AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE,
|
||||
AccountType::CREDITCARD]
|
||||
);
|
||||
|
||||
return null !== $account;
|
||||
}
|
||||
|
||||
// return true for the rest.
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user