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