From 5dedcc305e5c93aec4066c3ccf13ad17b5e5fb84 Mon Sep 17 00:00:00 2001 From: Bastian Allgeier Date: Sat, 7 Dec 2024 15:57:12 +0100 Subject: [PATCH] Reuse the validation error messages --- config/sections/files.php | 8 ++++++-- config/sections/pages.php | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/config/sections/files.php b/config/sections/files.php index 8971fdf327..31fb2a5766 100644 --- a/config/sections/files.php +++ b/config/sections/files.php @@ -236,11 +236,15 @@ } $ids = $this->requestBody('ids'); + $min = $section->min(); // check if the section has enough files after the deletion - if ($section->total() - count($ids) < $section->min()) { + if ($section->total() - count($ids) < $min) { throw new Exception( - message: 'The section needs to have at least ' . $section->min() . ' files', + message: I18n::template('error.section.files.min.' . I18n::form($min), [ + 'min' => $min, + 'section' => $section->headline() + ]) ); } diff --git a/config/sections/pages.php b/config/sections/pages.php index 40cea4d9ad..8288f8b242 100644 --- a/config/sections/pages.php +++ b/config/sections/pages.php @@ -335,11 +335,15 @@ } $ids = $this->requestBody('ids'); + $min = $section->min(); // check if the section has enough pages after the deletion - if ($section->total() - count($ids) < $section->min()) { + if ($section->total() - count($ids) < $min) { throw new Exception( - message: 'The section needs to have at least ' . $section->min() . ' pages', + message: I18n::template('error.section.pages.min.' . I18n::form($min), [ + 'min' => $min, + 'section' => $section->headline() + ]) ); }