mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-09 22:26:04 +00:00
🤖 Auto commit for release 'develop' on 2025-09-07
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
* IsValidSortInstruction.php
|
||||
* Copyright (c) 2025 james@firefly-iii.org
|
||||
@@ -35,21 +37,24 @@ class IsValidSortInstruction implements ValidationRule
|
||||
|
||||
public function validate(string $attribute, mixed $value, Closure $fail): void
|
||||
{
|
||||
$shortClass = str_replace('FireflyIII\\Models\\', '', $this->class);
|
||||
$shortClass = str_replace('FireflyIII\Models\\', '', $this->class);
|
||||
if (!is_string($value)) {
|
||||
$fail('validation.invalid_sort_instruction')->translate(['object' => $shortClass]);
|
||||
|
||||
return;
|
||||
}
|
||||
$validParameters = config(sprintf('firefly.allowed_sort_parameters.%s', $shortClass));
|
||||
if (!is_array($validParameters)) {
|
||||
$fail('validation.no_sort_instructions')->translate(['object' => $shortClass]);
|
||||
|
||||
return;
|
||||
}
|
||||
$parts = explode(',', $value);
|
||||
$parts = explode(',', $value);
|
||||
foreach ($parts as $i => $part) {
|
||||
$part = trim($part);
|
||||
if (strlen($part) < 2) {
|
||||
$fail('validation.invalid_sort_instruction_index')->translate(['index' => $i, 'object' => $shortClass]);
|
||||
|
||||
return;
|
||||
}
|
||||
if ('-' === $part[0]) {
|
||||
@@ -57,6 +62,7 @@ class IsValidSortInstruction implements ValidationRule
|
||||
}
|
||||
if (!in_array($part, $validParameters, true)) {
|
||||
$fail('validation.invalid_sort_instruction_index')->translate(['index' => $i, 'object' => $shortClass]);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user