mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Auto commit for release 'develop' on 2024-08-05
This commit is contained in:
@@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Rules\Account;
|
||||
|
||||
use Closure;
|
||||
use FireflyIII\Support\Http\Api\AccountFilter;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
|
||||
@@ -31,12 +30,9 @@ class IsValidAccountType implements ValidationRule
|
||||
{
|
||||
use AccountFilter;
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
#[\Override] public function validate(string $attribute, mixed $value, Closure $fail): void
|
||||
#[\Override]
|
||||
public function validate(string $attribute, mixed $value, \Closure $fail): void
|
||||
{
|
||||
|
||||
// only check the type.
|
||||
if (array_key_exists('type', $value)) {
|
||||
$value = $value['type'];
|
||||
@@ -44,13 +40,13 @@ class IsValidAccountType implements ValidationRule
|
||||
$value = [$value];
|
||||
}
|
||||
|
||||
|
||||
$filtered = [];
|
||||
$keys = array_keys($this->types);
|
||||
|
||||
/** @var mixed $entry */
|
||||
foreach ($value as $entry) {
|
||||
$entry = (string) $entry;
|
||||
if (!in_array($entry, $keys)) {
|
||||
if (!in_array($entry, $keys, true)) {
|
||||
$fail('something');
|
||||
}
|
||||
}
|
||||
|
@@ -35,17 +35,18 @@ class IsValidDateRange implements ValidationRule
|
||||
*/
|
||||
public function validate(string $attribute, mixed $value, \Closure $fail): void
|
||||
{
|
||||
$value = (string) $value;
|
||||
$value = (string) $value;
|
||||
if ('' === $value) {
|
||||
$fail('validation.date_or_time')->translate();
|
||||
|
||||
return;
|
||||
}
|
||||
$other = 'startPeriod';
|
||||
$other = 'startPeriod';
|
||||
if ('startPeriod' === $attribute) {
|
||||
$other = 'endPeriod';
|
||||
}
|
||||
$otherValue = request()->get($other);
|
||||
|
||||
// parse date, twice.
|
||||
try {
|
||||
$left = Carbon::parse($value);
|
||||
@@ -68,6 +69,7 @@ class IsValidDateRange implements ValidationRule
|
||||
if ($left->gt($right)) {
|
||||
$fail('validation.date_after')->translate();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
// end must be after start
|
||||
@@ -76,4 +78,3 @@ class IsValidDateRange implements ValidationRule
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user