| 1 | |||
| 2 | ################################################################################### | ||
| 3 | # | ||
| 4 | # Embperl - Copyright (c) 1997-2008 Gerald Richter / ecos gmbh www.ecos.de | ||
| 5 | # Embperl - Copyright (c) 2008-2015 Gerald Richter | ||
| 6 | # Embperl - Copyright (c) 2015-2023 actevy.io | ||
| 7 | # | ||
| 8 | # You may distribute under the terms of either the GNU General Public | ||
| 9 | # License or the Artistic License, as specified in the Perl README file. | ||
| 10 | # | ||
| 11 | # THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR | ||
| 12 | # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED | ||
| 13 | # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
| 14 | # | ||
| 15 | ################################################################################### | ||
| 16 | |||
| 17 | |||
| 18 | package Embperl::Form::Validate::TimeHHMMSS ; | ||
| 19 | |||
| 20 | use base qw(Embperl::Form::Validate::Default); | ||
| 21 | |||
| 22 | my %errutf8 = | ||
| 23 | ( | ||
| 24 | validate_time_long => 'Feld %0: "%1" ist kein gültiges Zeitformat. Geben Sie die Zeit in der Form hh:mm:ss ein', | ||
| 25 | ) ; | ||
| 26 | |||
| 27 | no utf8 ; | ||
| 28 | |||
| 29 | my %error_messages = | ||
| 30 | ( | ||
| 31 | de => | ||
| 32 | { | ||
| 33 | validate_time_long => 'Feld %0: "%1" ist kein gültiges Zeitformat. Geben Sie die Zeit in der Form hh:mm:ss ein', | ||
| 34 | }, | ||
| 35 | |||
| 36 | 'de.utf-8' => \%errutf8, | ||
| 37 | |||
| 38 | en => | ||
| 39 | { | ||
| 40 | validate_time_long => 'Field %0: "%1" isn\\\'t a valid time. Please enter the time as hh:mm:ss', | ||
| 41 | } | ||
| 42 | ); | ||
| 43 | |||
| 44 | # -------------------------------------------------------------- | ||
| 45 | |||
| 46 | sub getmsg | ||
| 47 | { | ||
| 48 | my ($self, $id, $language, $default_language) = @_ ; | ||
| 49 | |||
| 50 | return $error_messages{$language}{$id} || | ||
| 51 | $error_messages{$default_language}{$id} || | ||
| 52 | $self -> SUPER::getmsg ($id, $language, $default_language) ; | ||
| 53 | } | ||
| 54 | |||
| 55 | |||
| 56 | # -------------------------------------------------------------- | ||
| 57 | |||
| 58 | sub validate | ||
| 59 | { | ||
| 60 | my ($self, $key, $value, $fdat, $pref) = @_ ; | ||
| 61 | |||
| 62 | if($value =~ /^(\d\d):(\d\d):(\d\d)$/) | ||
| 63 | { | ||
| 64 | if ($1 < 0 || $1 > 23 || | ||
| 65 | $2 < 0 || $2 > 59 || | ||
| 66 | $3 < 0 || $3 > 59) | ||
| 67 | { | ||
| 68 | return ['validate_time_long', $value] ; | ||
| 69 | } | ||
| 70 | return undef ; | ||
| 71 | } | ||
| 72 | return ['validate_time_long', $value] ; | ||
| 73 | } | ||
| 74 | |||
| 75 | # -------------------------------------------------------------- | ||
| 76 | |||
| 77 | sub getscript_validate | ||
| 78 | { | ||
| 79 | my ($self, $arg, $pref) = @_ ; | ||
| 80 | |||
| 81 | return ('obj.value.search(/^\d\d:\d\d:\d\d$/) >= 0', ['validate_time_long', "'+obj.value+'"]) ; | ||
| 82 | } | ||
| 83 | |||
| 84 | |||
| 85 | 1; |