line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FormValidator::Simple::Result; |
2
|
24
|
|
|
24
|
|
61112
|
use strict; |
|
24
|
|
|
|
|
57
|
|
|
24
|
|
|
|
|
1007
|
|
3
|
24
|
|
|
24
|
|
127
|
use base qw/Class::Accessor::Fast/; |
|
24
|
|
|
|
|
229
|
|
|
24
|
|
|
|
|
16441
|
|
4
|
24
|
|
|
24
|
|
17422
|
use FormValidator::Simple::Constants; |
|
24
|
|
|
|
|
57
|
|
|
24
|
|
|
|
|
1699
|
|
5
|
24
|
|
|
24
|
|
13504
|
use FormValidator::Simple::Exception; |
|
24
|
|
|
|
|
60
|
|
|
24
|
|
|
|
|
300
|
|
6
|
24
|
|
|
24
|
|
24788
|
use Tie::IxHash; |
|
24
|
|
|
|
|
146919
|
|
|
24
|
|
|
|
|
1193
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw/name constraints data is_blank/); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
106
|
|
|
106
|
1
|
2039
|
my $class = shift; |
12
|
106
|
|
|
|
|
320
|
my $self = bless { }, $class; |
13
|
106
|
|
|
|
|
312
|
$self->_init(@_); |
14
|
106
|
|
|
|
|
944
|
return $self; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub _init { |
18
|
106
|
|
|
106
|
|
254
|
my ($self, $name) = @_; |
19
|
106
|
|
|
|
|
190
|
my %constraints = (); |
20
|
106
|
|
|
|
|
393
|
tie (%constraints, 'Tie::IxHash'); |
21
|
106
|
|
|
|
|
1490
|
$self->name($name); |
22
|
106
|
|
|
|
|
985
|
$self->constraints(\%constraints); |
23
|
106
|
|
|
|
|
811
|
$self->data(q{}); |
24
|
106
|
|
|
|
|
666
|
$self->is_blank( FALSE ); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub set { |
28
|
116
|
|
|
116
|
1
|
2826
|
my ($self, $constraint, $result) = @_; |
29
|
116
|
|
|
|
|
323
|
$self->constraints->{$constraint} = $result; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub is_valid { |
33
|
23
|
|
|
23
|
0
|
222
|
my $self = shift; |
34
|
23
|
100
|
|
|
|
63
|
return FALSE if $self->is_blank; |
35
|
19
|
|
|
|
|
109
|
foreach my $result ( values %{ $self->constraints } ) { |
|
19
|
|
|
|
|
56
|
|
36
|
10
|
100
|
|
|
|
206
|
return FALSE unless $result; |
37
|
|
|
|
|
|
|
} |
38
|
16
|
|
|
|
|
249
|
return TRUE; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub is_invalid { |
42
|
144
|
|
|
144
|
0
|
1931
|
my $self = shift; |
43
|
144
|
100
|
|
|
|
385
|
return FALSE if $self->is_blank; |
44
|
136
|
|
|
|
|
797
|
foreach my $result ( values %{ $self->constraints } ) { |
|
136
|
|
|
|
|
393
|
|
45
|
152
|
100
|
|
|
|
2886
|
return TRUE unless $result; |
46
|
|
|
|
|
|
|
} |
47
|
56
|
|
|
|
|
682
|
return FALSE; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub is_valid_for { |
51
|
3
|
|
|
3
|
0
|
6
|
my ($self, $constraint) = @_; |
52
|
3
|
50
|
|
|
|
9
|
return TRUE unless exists $self->constraints->{$constraint}; |
53
|
3
|
100
|
|
|
|
41
|
return $self->constraints->{$constraint} ? TRUE : FALSE; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub is_invalid_for { |
57
|
7
|
|
|
7
|
0
|
62
|
my ($self, $constraint) = @_; |
58
|
7
|
50
|
|
|
|
24
|
return FALSE unless exists $self->constraints->{$constraint}; |
59
|
7
|
100
|
|
|
|
90
|
return $self->constraints->{$constraint} ? FALSE : TRUE; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
__END__ |