From fbc3a76f088e8aa019434562a267266a1a67b64c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20B=C3=BCren?= Date: Thu, 14 Nov 2019 15:09:01 +0100 Subject: [PATCH] =?utf8?q?SetNumberRange:=20Validit=C3=A4tspr=C3=BCfung=20?= =?utf8?q?auf=20Benutzereingabe=20(data)=20im=20Job?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/BackgroundJob/SetNumberRange.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/SL/BackgroundJob/SetNumberRange.pm b/SL/BackgroundJob/SetNumberRange.pm index e317730f3..a7976f472 100644 --- a/SL/BackgroundJob/SetNumberRange.pm +++ b/SL/BackgroundJob/SetNumberRange.pm @@ -17,9 +17,15 @@ sub run { my ($self, $db_obj) = @_; my $data = $db_obj->data_as_hash; + if ($data->{digits_year} && !($data->{digits_year} == 2 || $data->{digits_year} == 4)) { + die "No valid input for digits_year should be 2 or 4."; + } + if ($data->{multiplier} && !($data->{multiplier} % 10 == 0)) { + die "No valid input for multiplier should be 10, 100, .., 1000000"; + } my $next_year = DateTime->today_local->truncate(to => 'year')->add(years => 1)->year(); $next_year = ($data->{digits_year} == 2) ? substr($next_year, 2, 2) : $next_year; - my $multiplier = $data->{multiplier} || 1; + my $multiplier = $data->{multiplier} || 100; my $defaults = SL::DB::Default->get; -- 2.20.1