lib/HTML/FormFu/Constraint/Length.pm

filter: Statementstmt 92.5% 25 / 27 Branchbran 90.0% 9 / 10 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 1 totaltotal 81.6% 40 / 49 SCAR 19.6
CC
7
Cov
88%
constrain_value
7.2
_localize_args
2.0
BEGIN
1.0
CRAP 7.1
« lib/HTML/FormFu/Role/ContainsElementsSharedWithField.pm ↑ Summary lib/HTML/FormFu/Inflator.pm »
1 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 package HTML::FormFu::Constraint::Length;
4 6 $HTML::FormFu::Constraint::Length::VERSION = '2.06';
5 # ABSTRACT: Min/Max Length String Constraint
6  
7 6 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 6 ▶use MooseX::Attribute::Chained;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 6 ▶use MooseX::Aliases;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 6 extends 'HTML::FormFu::Constraint';
12  
13 6 has minimum => (
14 is => 'rw',
15 alias => 'min',
16 traits => ['Chained'],
17 );
18  
19 6 has maximum => (
20 is => 'rw',
21 alias => 'max',
22 traits => ['Chained'],
23 );
24  
25 sub constrain_value {
26 13 ▶ my ( $self, $value ) = @_;
Subroutine constrain_value: called CC=7 SCAR=19.7
Pod undocumented
27  
28 13 ▶ return 1 if !defined $value || $value eq '';
Branch: 1 branch
BranchTrueFalseTotal
if not defined $value or $value eq "" 0 13 13
Condition33%1/3
not defined $value or $value eq ""
l!l&&r!l&&!r
0013
MC/DC0%0/2
not defined $value or $value eq ""
not defined $value $value eq ""
Truth table33%1/3
not(A) or B
A= not defined $valueB= $value eq ""
ABresult
1X1
011
000
29  
30 13 ▶ if ( defined( my $min = $self->minimum ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $min = $self->minimum)) 9 4 13
31 9 ▶ return 0 if length $value < $min;
Branch: 1 branch
BranchTrueFalseTotal
if length $value < $min 3 6 9
32 }
33  
34 10 ▶ if ( defined( my $max = $self->maximum ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $max = $self->maximum)) 7 3 10
35 7 ▶ return 0 if length $value > $max;
Branch: 1 branch
BranchTrueFalseTotal
if length $value > $max 2 5 7
36 }
37  
38 8 return 1;
39 }
40  
41 sub _localize_args {
42 0 ▶ my ($self) = @_;
Subroutine _localize_args: not called CC=1 SCAR=6.9
43  
44 0 return $self->min, $self->max;
45 }
46  
47 6 __PACKAGE__->meta->make_immutable;
48  
49 6 1;
50  
51 __END__
52  
53 =pod
54  
55 =encoding UTF-8
56  
57 =head1 NAME
58  
59 HTML::FormFu::Constraint::Length - Min/Max Length String Constraint
60  
61 =head1 VERSION
62  
63 version 2.06
64  
65 =head1 DESCRIPTION
66  
67 Checks the input value meets both a minimum and maximum length.
68  
69 This constraint doesn't honour the C<not()> value.
70  
71 =head1 METHODS
72  
73 =head2 minimum
74  
75 =head2 min
76  
77 The minimum input string length.
78  
79 L</min> is an alias for L</minimum>.
80  
81 =head2 maximum
82  
83 =head2 max
84  
85 The maximum input string length.
86  
87 L</max> is an alias for L</maximum>.
88  
89 =head1 SEE ALSO
90  
91 Is a sub-class of, and inherits methods from L<HTML::FormFu::Constraint>
92  
93 L<HTML::FormFu>
94  
95 =head1 AUTHOR
96  
97 Carl Franks C<cfranks@cpan.org>
98  
99 =head1 LICENSE
100  
101 This library is free software, you can redistribute it and/or modify it under
102 the same terms as Perl itself.
103  
104 =head1 AUTHOR
105  
106 Carl Franks <cpan@fireartist.com>
107  
108 =head1 COPYRIGHT AND LICENSE
109  
110 This software is copyright (c) 2018 by Carl Franks.
111  
112 This is free software; you can redistribute it and/or modify it under
113 the same terms as the Perl 5 programming language system itself.
114  
115 =cut
« lib/HTML/FormFu/Role/ContainsElementsSharedWithField.pm ↑ Summary lib/HTML/FormFu/Inflator.pm »