line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: Hostname Directive for Validation Class Field Definitions |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Validation::Class::Directive::Hostname; |
4
|
|
|
|
|
|
|
|
5
|
109
|
|
|
109
|
|
53458
|
use strict; |
|
109
|
|
|
|
|
266
|
|
|
109
|
|
|
|
|
3152
|
|
6
|
109
|
|
|
109
|
|
584
|
use warnings; |
|
109
|
|
|
|
|
261
|
|
|
109
|
|
|
|
|
2818
|
|
7
|
|
|
|
|
|
|
|
8
|
109
|
|
|
109
|
|
599
|
use base 'Validation::Class::Directive'; |
|
109
|
|
|
|
|
235
|
|
|
109
|
|
|
|
|
11207
|
|
9
|
|
|
|
|
|
|
|
10
|
109
|
|
|
109
|
|
889
|
use Validation::Class::Util; |
|
109
|
|
|
|
|
289
|
|
|
109
|
|
|
|
|
775
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '7.900059'; # VERSION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has 'mixin' => 1; |
16
|
|
|
|
|
|
|
has 'field' => 1; |
17
|
|
|
|
|
|
|
has 'multi' => 0; |
18
|
|
|
|
|
|
|
has 'message' => '%s requires a valid hostname'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub validate { |
21
|
|
|
|
|
|
|
|
22
|
12
|
|
|
12
|
0
|
26
|
my ($self, $proto, $field, $param) = @_; |
23
|
|
|
|
|
|
|
|
24
|
12
|
50
|
33
|
|
|
63
|
if (defined $field->{hostname} && defined $param) { |
25
|
|
|
|
|
|
|
|
26
|
12
|
50
|
33
|
|
|
50
|
if ($field->{required} || $param) { |
27
|
|
|
|
|
|
|
|
28
|
12
|
|
|
|
|
70
|
my $hnre = qr/^(?:[-_a-z0-9][-_a-z0-9]*\.)*(?:[a-z0-9][-a-z0-9]{0,62})\.(?:(?:[a-z]{2}\.)?[a-z]{2,4}|museum|travel)$/; |
29
|
|
|
|
|
|
|
|
30
|
12
|
100
|
|
|
|
142
|
$self->error($proto, $field) unless $param =~ $hnre; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
12
|
|
|
|
|
40
|
return $self; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
__END__ |