Widget/Constraint/AllOrNone.pm untested

filter: Statementstmt 0.0% 0 / 19 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 40 CC 4 SCAR 25.1
CC
4
Cov
0%
process
20.0
BEGIN
2.0
BEGIN
2.0
CRAP 12.3
1 package HTML::Widget::Constraint::AllOrNone;
2  
3 use warnings;
4 use strict;
5 use base 'HTML::Widget::Constraint';
6  
7 =head1 NAME
8  
9 HTML::Widget::Constraint::AllOrNone - AllOrNone Constraint
10  
11 =head1 SYNOPSIS
12  
13 my $c = $widget->constraint( 'AllOrNone', 'foo', 'bar' );
14  
15 =head1 DESCRIPTION
16  
17 AllOrNone means that if one is filled out, all of them have to be.
18  
19 =head1 METHODS
20  
21 =head2 process
22  
23 =cut
24  
25 sub process {
26 my ( $self, $w, $params ) = @_;
27 my $results = [];
28 my $one;
29 for my $name ( @{ $self->names } ) {
30 if ($self->not
31 ? ( defined $params->{$name} && length $params->{$name} )
32 : ( !defined $params->{$name} || !length $params->{$name} ) )
33 {
34 push @$results, HTML::Widget::Error->new(
35 { name => $name, message => $self->mk_message } );
36 }
37 else {
38 $one++;
39 }
40 }
41 return ( $one ? $results : [] );
42 }
43  
44 =head1 AUTHOR
45  
46 Marcus Ramberg, C<mramberg@cpan.org>
47  
48 =head1 LICENSE
49  
50 This library is free software, you can redistribute it and/or modify it under
51 the same terms as Perl itself.
52  
53 =cut
54  
55 1;