line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::FormFu::Constraint::Range; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
1348
|
use strict; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
262
|
|
4
|
|
|
|
|
|
|
our $VERSION = '2.05'; # VERSION |
5
|
|
|
|
|
|
|
|
6
|
6
|
|
|
6
|
|
20
|
use Moose; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
32
|
|
7
|
6
|
|
|
6
|
|
24948
|
use MooseX::Attribute::FormFuChained; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
120
|
|
8
|
6
|
|
|
6
|
|
23
|
use MooseX::Aliases; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
35
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
extends 'HTML::FormFu::Constraint'; |
11
|
|
|
|
|
|
|
|
12
|
6
|
|
|
6
|
|
14188
|
use Scalar::Util qw( looks_like_number ); |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
1326
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has minimum => ( |
15
|
|
|
|
|
|
|
is => 'rw', |
16
|
|
|
|
|
|
|
alias => 'min', |
17
|
|
|
|
|
|
|
traits => ['FormFuChained'], |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has maximum => ( |
21
|
|
|
|
|
|
|
is => 'rw', |
22
|
|
|
|
|
|
|
alias => 'max', |
23
|
|
|
|
|
|
|
traits => ['FormFuChained'], |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub constrain_value { |
27
|
21
|
|
|
21
|
0
|
24
|
my ( $self, $value ) = @_; |
28
|
|
|
|
|
|
|
|
29
|
21
|
100
|
66
|
|
|
80
|
return 1 if !defined $value || $value eq ''; |
30
|
|
|
|
|
|
|
|
31
|
15
|
100
|
|
|
|
60
|
return if !looks_like_number($value); |
32
|
|
|
|
|
|
|
|
33
|
14
|
100
|
|
|
|
340
|
if ( defined( my $min = $self->minimum ) ) { |
34
|
10
|
100
|
|
|
|
26
|
return 0 if $value < $min; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
11
|
100
|
|
|
|
279
|
if ( defined( my $max = $self->maximum ) ) { |
38
|
7
|
100
|
|
|
|
16
|
return 0 if $value > $max; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
9
|
|
|
|
|
18
|
return 1; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub _localize_args { |
45
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
return $self->min, $self->max; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
__END__ |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 NAME |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
HTML::FormFu::Constraint::Range - Numerical Range Constraint |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 VERSION |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
version 2.05 |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 SYNOPSIS |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
type: Range |
67
|
|
|
|
|
|
|
min: 18 |
68
|
|
|
|
|
|
|
max: 35 |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 DESCRIPTION |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Numerical range constraint. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
This constraint doesn't honour the C<not()> value. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 METHODS |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 minimum |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head2 min |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
If defined, the input value must be equal to or greater than this. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
L</min> is an alias for L</minimum>. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 maximum |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head2 max |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
If defined, the input value must be equal to or less than this. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
L</max> is an alias for L</maximum>. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 SEE ALSO |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Is a sub-class of, and inherits methods from L<HTML::FormFu::Constraint> |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
L<HTML::FormFu> |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 AUTHOR |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Carl Franks C<cfranks@cpan.org> |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 LICENSE |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
This library is free software, you can redistribute it and/or modify it under |
107
|
|
|
|
|
|
|
the same terms as Perl itself. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=cut |