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