line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FormValidator::Lite::Constraint::File; |
2
|
3
|
|
|
3
|
|
1350
|
use strict; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
68
|
|
3
|
3
|
|
|
3
|
|
11
|
use warnings; |
|
3
|
|
|
|
|
2
|
|
|
3
|
|
|
|
|
65
|
|
4
|
3
|
|
|
3
|
|
11
|
use FormValidator::Lite::Constraint; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
15
|
|
5
|
3
|
|
|
3
|
|
9
|
use Carp (); |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
358
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
file_rule 'FILE_MIME' => sub { |
8
|
|
|
|
|
|
|
Carp::croak('missing args. usage: ["FILE_MIME", "text/plain"]') unless @_; |
9
|
|
|
|
|
|
|
my $expected = $_[0]; |
10
|
|
|
|
|
|
|
return $_->type =~ /^$expected$/; |
11
|
|
|
|
|
|
|
}; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
file_rule 'FILE_SIZE' => sub { |
14
|
|
|
|
|
|
|
Carp::croak('missing args. usage: ["FILE_SIZE", 1_000_000, 100]') unless @_; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $size = $_->size; |
17
|
|
|
|
|
|
|
my $max = shift; |
18
|
|
|
|
|
|
|
my $min = shift; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
return 0 if $max < $size; |
21
|
|
|
|
|
|
|
return 0 if defined($min) && $min > $size; |
22
|
|
|
|
|
|
|
return 1; |
23
|
|
|
|
|
|
|
}; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
1; |
26
|
|
|
|
|
|
|
__END__ |