| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package HTML::Widget::Constraint::Range; |
|
2
|
|
|
|
|
|
|
|
|
3
|
88
|
|
|
88
|
|
73011
|
use warnings; |
|
|
88
|
|
|
|
|
212
|
|
|
|
88
|
|
|
|
|
2705
|
|
|
4
|
88
|
|
|
88
|
|
491
|
use strict; |
|
|
88
|
|
|
|
|
183
|
|
|
|
88
|
|
|
|
|
3075
|
|
|
5
|
88
|
|
|
88
|
|
486
|
use base 'HTML::Widget::Constraint'; |
|
|
88
|
|
|
|
|
193
|
|
|
|
88
|
|
|
|
|
7478
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
88
|
|
|
88
|
|
775
|
use Scalar::Util qw(looks_like_number); |
|
|
88
|
|
|
|
|
256
|
|
|
|
88
|
|
|
|
|
22936
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw/minimum maximum/); |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
*min = \&minimum; |
|
12
|
|
|
|
|
|
|
*max = \&maximum; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
HTML::Widget::Constraint::Range - Range Constraint |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $c = $widget->constraint( 'Range', 'foo' ); |
|
21
|
|
|
|
|
|
|
$c->min(23); |
|
22
|
|
|
|
|
|
|
$c->max(30); |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Range Constraint. |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 METHODS |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head2 maximum |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Arguments: $max_value |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head2 minimum |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Arguments: $min_value |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 validate |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub validate { |
|
43
|
15
|
|
|
15
|
1
|
30
|
my ( $self, $value ) = @_; |
|
44
|
|
|
|
|
|
|
|
|
45
|
15
|
100
|
66
|
|
|
120
|
return 1 if !defined $value || $value eq ''; |
|
46
|
|
|
|
|
|
|
|
|
47
|
14
|
|
|
|
|
55
|
my $minimum = $self->minimum; |
|
48
|
14
|
|
|
|
|
119
|
my $maximum = $self->maximum; |
|
49
|
14
|
|
|
|
|
74
|
my $failed = 0; |
|
50
|
|
|
|
|
|
|
|
|
51
|
14
|
100
|
|
|
|
76
|
$failed++ if !looks_like_number($value); |
|
52
|
|
|
|
|
|
|
|
|
53
|
14
|
100
|
66
|
|
|
104
|
if ( !$failed && defined $minimum ) { |
|
54
|
13
|
100
|
|
|
|
54
|
$failed++ unless ( $value >= $minimum ); |
|
55
|
|
|
|
|
|
|
} |
|
56
|
14
|
100
|
66
|
|
|
117
|
if ( !$failed && defined $maximum ) { |
|
57
|
12
|
100
|
|
|
|
42
|
$failed++ unless ( $value <= $maximum ); |
|
58
|
|
|
|
|
|
|
} |
|
59
|
14
|
|
|
|
|
49
|
return !$failed; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 AUTHOR |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Sebastian Riedel, C |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 LICENSE |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
This library is free software, you can redistribute it and/or modify it under |
|
69
|
|
|
|
|
|
|
the same terms as Perl itself. |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |