line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: MaxSum Directive for Validation Class Field Definitions |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Validation::Class::Directive::MaxSum; |
4
|
|
|
|
|
|
|
|
5
|
109
|
|
|
109
|
|
42396
|
use strict; |
|
109
|
|
|
|
|
229
|
|
|
109
|
|
|
|
|
2663
|
|
6
|
109
|
|
|
109
|
|
480
|
use warnings; |
|
109
|
|
|
|
|
214
|
|
|
109
|
|
|
|
|
2382
|
|
7
|
|
|
|
|
|
|
|
8
|
109
|
|
|
109
|
|
470
|
use base 'Validation::Class::Directive'; |
|
109
|
|
|
|
|
204
|
|
|
109
|
|
|
|
|
8921
|
|
9
|
|
|
|
|
|
|
|
10
|
109
|
|
|
109
|
|
683
|
use Validation::Class::Util; |
|
109
|
|
|
|
|
250
|
|
|
109
|
|
|
|
|
691
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '7.900058'; # VERSION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has 'mixin' => 1; |
16
|
|
|
|
|
|
|
has 'field' => 1; |
17
|
|
|
|
|
|
|
has 'multi' => 0; |
18
|
|
|
|
|
|
|
has 'message' => '%s must be less than %s'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub validate { |
21
|
|
|
|
|
|
|
|
22
|
4
|
|
|
4
|
0
|
15
|
my $self = shift; |
23
|
|
|
|
|
|
|
|
24
|
4
|
|
|
|
|
11
|
my ($proto, $field, $param) = @_; |
25
|
|
|
|
|
|
|
|
26
|
4
|
50
|
33
|
|
|
38
|
if (defined $field->{max_sum} && defined $param) { |
27
|
|
|
|
|
|
|
|
28
|
4
|
|
|
|
|
16
|
my $max_sum = $field->{max_sum}; |
29
|
|
|
|
|
|
|
|
30
|
4
|
50
|
33
|
|
|
28
|
if ( $field->{required} || $param ) { |
31
|
|
|
|
|
|
|
|
32
|
4
|
100
|
|
|
|
20
|
if (int($param) > int($max_sum)) { |
33
|
|
|
|
|
|
|
|
34
|
1
|
|
|
|
|
21
|
$self->error(@_, $max_sum); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
4
|
|
|
|
|
11
|
return $self; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__END__ |