| 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::IP6Addr_Mask ; | ||
| 19 | |||
| 20 | use base qw(Embperl::Form::Validate::Default); | ||
| 21 | |||
| 22 | my %errutf8 = | ||
| 23 | ( | ||
| 24 | validate_ip6addr_mask => 'Feld %0: "%1" ist keine gültige IP-Adresse. Geben Sie die IPv6-Adresse in der Form fe80::ffdf:3bae:884e:ba9a ein', | ||
| 25 | ) ; | ||
| 26 | |||
| 27 | no utf8 ; | ||
| 28 | |||
| 29 | my %error_messages = | ||
| 30 | ( | ||
| 31 | de => | ||
| 32 | { | ||
| 33 | validate_ip6addr_mask => 'Feld %0: "%1" ist keine gültige IP-Adresse. Geben Sie die IPv6-Adresse in der Form fe80::ffdf:3bae:884e:ba9a ein', | ||
| 34 | }, | ||
| 35 | |||
| 36 | 'de.utf-8' => \%errutf8, | ||
| 37 | |||
| 38 | en => | ||
| 39 | { | ||
| 40 | validate_ip6addr_mask => 'Field %0: "%1" isn\\\'t a valid ip-address. Please enter the ipv6-address like fe80::ffdf:3bae:884e:ba9a', | ||
| 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 | if ($value !~ /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/) | ||
| 62 | { | ||
| 63 | return ['validate_ip6addr_mask', $value] ; | ||
| 64 | } | ||
| 65 | return undef; | ||
| 66 | } | ||
| 67 | |||
| 68 | # -------------------------------------------------------------- | ||
| 69 | |||
| 70 | sub getscript_validate | ||
| 71 | { | ||
| 72 | my ($self, $arg, $pref) = @_ ; | ||
| 73 | |||
| 74 | return ('obj.value.search(/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/) >= 0', ['validate_ip6addr_mask', "'+obj.value+'"]) ; | ||
| 75 | } | ||
| 76 | |||
| 77 | |||
| 78 | 1; |