Skip to content

Firefly III: a personal finances manager

Don't validate on empty string.

James Coleed2e0e86dcb2
diff --git a/app/Rules/IsValidSortInstruction.php b/app/Rules/IsValidSortInstruction.php
index 4d9e7b0cf7..6194c6668b 100644
--- a/app/Rules/IsValidSortInstruction.php
+++ b/app/Rules/IsValidSortInstruction.php
@@ -32,19 +32,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;
}
+ if ('' === $value) {
+ // don't validate.
+
+ 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) {