mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Update various things. I know, great description.
This commit is contained in:
@@ -40,6 +40,8 @@ class IsAssetAccountId implements ValidationRule
|
||||
* @param Closure $fail
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function validate(string $attribute, mixed $value, Closure $fail): void
|
||||
{
|
||||
|
||||
@@ -38,6 +38,8 @@ class IsBoolean implements ValidationRule
|
||||
* @param Closure $fail
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function validate(string $attribute, mixed $value, Closure $fail): void
|
||||
{
|
||||
|
||||
@@ -41,6 +41,8 @@ class IsDateOrTime implements ValidationRule
|
||||
* @param Closure $fail
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function validate(string $attribute, mixed $value, Closure $fail): void
|
||||
{
|
||||
|
||||
@@ -40,6 +40,8 @@ class IsTransferAccount implements ValidationRule
|
||||
* @param Closure $fail
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function validate(string $attribute, mixed $value, Closure $fail): void
|
||||
{
|
||||
@@ -59,7 +61,7 @@ class IsTransferAccount implements ValidationRule
|
||||
$validAccount = $validator->validateSource(['id' => (int)$value,]);
|
||||
app('log')->debug(sprintf('Search by id (%d), result is %s.', (int)$value, var_export($validAccount, true)));
|
||||
|
||||
if(false === $validAccount) {
|
||||
if (false === $validAccount) {
|
||||
$fail('validation.not_transfer_account')->translate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,6 +82,8 @@ class IsValidAttachmentModel implements ValidationRule
|
||||
* @param Closure $fail
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function validate(string $attribute, mixed $value, Closure $fail): void
|
||||
{
|
||||
@@ -89,26 +91,19 @@ class IsValidAttachmentModel implements ValidationRule
|
||||
$fail('validation.model_id_invalid')->translate();
|
||||
return;
|
||||
}
|
||||
$methods = [
|
||||
Account::class => 'validateAccount',
|
||||
Bill::class => 'validateBill',
|
||||
Budget::class => 'validateBudget',
|
||||
Category::class => 'validateCategory',
|
||||
PiggyBank::class => 'validatePiggyBank',
|
||||
Tag::class => 'validateTag',
|
||||
Transaction::class => 'validateTransaction',
|
||||
TransactionJournal::class => 'validateJournal',
|
||||
];
|
||||
if (!array_key_exists($this->model, $methods)) {
|
||||
app('log')->error(sprintf('Cannot validate model "%s" in %s.', substr($this->model, 0, 20), __METHOD__));
|
||||
$result = match ($this->model) {
|
||||
Account::class => $this->validateAccount((int)$value),
|
||||
Bill::class => $this->validateBill((int)$value),
|
||||
Budget::class => $this->validateBudget((int)$value),
|
||||
Category::class => $this->validateCategory((int)$value),
|
||||
PiggyBank::class => $this->validatePiggyBank((int)$value),
|
||||
Tag::class => $this->validateTag((int)$value),
|
||||
Transaction::class => $this->validateTransaction((int)$value),
|
||||
TransactionJournal::class => $this->validateJournal((int)$value),
|
||||
default => false,
|
||||
};
|
||||
|
||||
$fail('validation.model_id_invalid')->translate();
|
||||
return;
|
||||
}
|
||||
$method = $methods[$this->model];
|
||||
|
||||
$result = $this->$method((int)$value); // @phpstan-ignore-line
|
||||
if(false === $result) {
|
||||
if (false === $result) {
|
||||
$fail('validation.model_id_invalid')->translate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,6 +60,8 @@ class IsValidBulkClause implements ValidationRule
|
||||
* @param Closure $fail
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function validate(string $attribute, mixed $value, Closure $fail): void
|
||||
{
|
||||
|
||||
@@ -48,6 +48,8 @@ class LessThanPiggyTarget implements ValidationRule
|
||||
* @param Closure $fail
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function validate(string $attribute, mixed $value, Closure $fail): void
|
||||
{
|
||||
|
||||
@@ -79,6 +79,8 @@ class UniqueAccountNumber implements ValidationRule
|
||||
* @param Closure $fail
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function validate(string $attribute, mixed $value, Closure $fail): void
|
||||
{
|
||||
|
||||
@@ -95,6 +95,8 @@ class UniqueIban implements ValidationRule
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*
|
||||
*/
|
||||
public function passes($attribute, $value): bool
|
||||
{
|
||||
|
||||
@@ -41,6 +41,8 @@ class ValidJournals implements ValidationRule
|
||||
* @param Closure $fail
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function validate(string $attribute, mixed $value, Closure $fail): void
|
||||
{
|
||||
|
||||
@@ -39,6 +39,8 @@ class ValidRecurrenceRepetitionType implements ValidationRule
|
||||
* @param string $attribute
|
||||
* @param mixed $value
|
||||
* @param Closure $fail
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function validate(string $attribute, mixed $value, Closure $fail): void
|
||||
{
|
||||
|
||||
@@ -41,6 +41,8 @@ class ValidRecurrenceRepetitionValue implements ValidationRule
|
||||
* @param Closure $fail
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function validate(string $attribute, mixed $value, Closure $fail): void
|
||||
{
|
||||
@@ -62,12 +64,12 @@ class ValidRecurrenceRepetitionValue implements ValidationRule
|
||||
|
||||
// Value is like: weekly,7
|
||||
if (str_starts_with($value, 'weekly') && $this->validateWeekly($value)) {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
// Value is like: yearly,2018-01-01
|
||||
if (str_starts_with($value, 'yearly') && $this->validateYearly($value)) {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
$fail('validation.valid_recurrence_rep_type')->translate();
|
||||
|
||||
Reference in New Issue
Block a user