File Coverage

lib/CGI/ValidOp/Check/alternative.pm
Criterion Covered Total %
statement 21 21 100.0
branch 4 4 100.0
condition n/a
subroutine 6 6 100.0
pod 0 1 0.0
total 31 32 96.8


line stmt bran cond sub pod time code
1             package CGI::ValidOp::Check::alternative;
2 7     7   43 use strict;
  7         14  
  7         308  
3 7     7   76 use warnings;
  7         14  
  7         379  
4              
5 7     7   39 use base qw/ CGI::ValidOp::Check /;
  7         16  
  7         2300  
6 7     7   47 use CGI;
  7         12  
  7         63  
7              
8             sub default {
9 53     53 0 116 my $self = shift;
10             sub {
11 53     53   119 my ( $value, $cond ) = @_;
12              
13              
14             # Pass if there is a value, and the conditional is empty
15             # Pass if the value is empty but the conditional is not
16             # Pass if both are set
17             # FIXME: Only need to check if the parameter is true or false
18             # this means this is safe in that we won;t be bringing in anything
19             # bad, however since this is being queried from CGI instead of validop
20             # it will return true even if '$cond' is not validated. This is not
21             # critical, but should be resolved.
22 53         336 my $CGI = CGI->new; #Randall, please don't kill me.
23 53 100       81305 return $self->pass if $CGI->param( $cond );
24              
25 16 100       284 if ( $value ) {
26 15         58 $value =~ m/^(.*)$/;
27 15         184 return $self->pass( $1 );
28             }
29              
30             #Fail saying the label is required because the condition has not been met.
31 1         9 return $self->fail( "\$label is required." );
32             }
33 53         472 }
34              
35             1;