diff --git a/app/Api/V1/Requests/Data/DateRequest.php b/app/Api/V1/Requests/Data/DateRequest.php index 0a5aab91f9..a739f31f63 100644 --- a/app/Api/V1/Requests/Data/DateRequest.php +++ b/app/Api/V1/Requests/Data/DateRequest.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Requests\Data; +use FireflyIII\Exceptions\FireflyException; use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ConvertsDataTypes; use Illuminate\Foundation\Http\FormRequest; @@ -43,9 +44,15 @@ class DateRequest extends FormRequest */ public function getAll(): array { + $start = $this->getCarbonDate('start'); + $end = $this->getCarbonDate('end'); + if($start->diffInYears($end) > 5) { + throw new FireflyException('Date range out of range.'); + } + return [ - 'start' => $this->getCarbonDate('start'), - 'end' => $this->getCarbonDate('end'), + 'start' => $start, + 'end' => $end, ]; }