Widget/Constraint/Any.pm untested

filter: Statementstmt 0.0% 0 / 21 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 34 CC 4 SCAR 24.0
CC
4
Cov
0%
process
20.0
default_message
2.0
BEGIN
2.0
CRAP 11.0
1 package HTML::Widget::Constraint::Any;
2  
3 use warnings;
4 use strict;
5 use base 'HTML::Widget::Constraint';
6  
7 =head1 NAME
8  
9 HTML::Widget::Constraint::Any - Any Constraint
10  
11 =head1 SYNOPSIS
12  
13 my $c = $widget->constraint( 'Any', 'foo', 'bar' );
14  
15 =head1 DESCRIPTION
16  
17 One or more of the named fields must be present.
18  
19 =head1 METHODS
20  
21 =head2 process
22  
23 =cut
24  
25 sub process {
26 my ( $self, $w, $params ) = @_;
27  
28 my $results = [];
29 my $present = 0;
30 for my $name ( @{ $self->names } ) {
31 unless ( $params->{$name} ) {
32 push @$results, HTML::Widget::Error->new(
33 { name => $name, message => $self->mk_message } );
34 }
35 else { $present++ }
36 }
37 $present = $self->not ? !$present : $present;
38 return $present ? [] : $results;
39 }
40  
41 =head2 default_message
42  
43 =cut
44  
45 sub default_message {'Alternative Missing'}
46  
47 =head2 render_errors
48  
49 Arguments: @names
50  
51 A list of element names for which an error should be displayed.
52  
53 If this is not set, the default behaviour is for the error to be displayed
54 for all of the Constraint's named elements.
55  
56 =head1 AUTHOR
57  
58 Sebastian Riedel, C<sri@oook.de>
59  
60 =head1 LICENSE
61  
62 This library is free software, you can redistribute it and/or modify it under
63 the same terms as Perl itself.
64  
65 =cut
66  
67 1;