lib/HTML/FormFu/Constraint/File.pm

filter: Statementstmt 100% 16 / 16 Branchbran 100% 2 / 2 Conditioncond 66.6% 4 / 6 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 1 totaltotal 84.8% 28 / 33 SCAR 13.9
CC
4
Cov
92%
constrain_value
4.1
BEGIN
1.0
BEGIN
1.0
CRAP 4.0
« lib/HTML/FormFu/Filter/CompoundSprintf.pm ↑ Summary lib/HTML/FormFu/Filter/CompoundJoin.pm »
1 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 package HTML::FormFu::Constraint::File;
4 2 $HTML::FormFu::Constraint::File::VERSION = '2.06';
5 # ABSTRACT: File Upload Constraint
6  
7 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 extends 'HTML::FormFu::Constraint';
9  
10 2 ▶use Scalar::Util qw( blessed );
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 sub constrain_value {
13 4 ▶ my ( $self, $value ) = @_;
Subroutine constrain_value: called CC=4 SCAR=14.1
Pod undocumented
14  
15 4 ▶ return 1 if !defined $value || $value eq '';
Branch: 1 branch
BranchTrueFalseTotal
if not defined $value or $value eq "" 1 3 4
Condition66%2/3
not defined $value or $value eq ""
l!l&&r!l&&!r
103
MC/DC50%1/2
not defined $value or $value eq ""
not defined $value $value eq ""
Truth table66%2/3
not(A) or B
A= not defined $valueB= $value eq ""
ABresult
1X1
011
000
16  
17 3 ▶ return blessed($value) && $value->isa('HTML::FormFu::Upload');
Condition66%2/3
builtin::blessed($value) && $value->isa('HTML::FormFu::Upload')
!ll&&!rl&&r
102
MC/DC50%1/2
builtin::blessed($value) && $value->isa('HTML::FormFu::Upload')
builtin::blessed($value) $value->isa('HTML::FormFu::Upload')
Truth table66%2/3
A && B
A= builtin::blessed($value)B= $value->isa('HTML::FormFu::Upload')
ABresult
0X0
100
111
18 }
19  
20 2 __PACKAGE__->meta->make_immutable;
21  
22 2 1;
23  
24 __END__
25  
26 =pod
27  
28 =encoding UTF-8
29  
30 =head1 NAME
31  
32 HTML::FormFu::Constraint::File - File Upload Constraint
33  
34 =head1 VERSION
35  
36 version 2.06
37  
38 =head1 DESCRIPTION
39  
40 Ensure the submitted value is a file upload.
41  
42 This Constraint is not needed if you use any of the C<File::*> Constraints,
43 as they all make the same check as this Constraint does.
44  
45 =head1 LIMITATIONS
46  
47 This can only verify that your CGI backend (CGI, Catalyst, CGI::Simple)
48 thinks it was a file upload. If the user submits a filename which doesn't
49 exist on their system, you will probably get a valid L<HTML::FormFu::Upload>
50 object, with a valid filehandle, but no Content-Length. This Constraint
51 would still see this as a valid uploaded file - if you want to ensure that
52 you get a file with content, instead use
53 L<HTML::FormFu::Constraint::File::Size> with
54 L<min|HTML::FormFu::Constraint::File::Size/min> set to C<1>.
55  
56 =head1 SEE ALSO
57  
58 Is a sub-class of, and inherits methods from L<HTML::FormFu::Constraint>
59  
60 L<HTML::FormFu>
61  
62 =head1 AUTHOR
63  
64 Carl Franks, C<cfranks@cpan.org>
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 =head1 AUTHOR
72  
73 Carl Franks <cpan@fireartist.com>
74  
75 =head1 COPYRIGHT AND LICENSE
76  
77 This software is copyright (c) 2018 by Carl Franks.
78  
79 This is free software; you can redistribute it and/or modify it under
80 the same terms as the Perl 5 programming language system itself.
81  
82 =cut
« lib/HTML/FormFu/Filter/CompoundSprintf.pm ↑ Summary lib/HTML/FormFu/Filter/CompoundJoin.pm »