| HTML-Widget documentation | Contained in the HTML-Widget distribution. |
HTML::Widget::Constraint::AllOrNone - AllOrNone Constraint
my $c = $widget->constraint( 'AllOrNone', 'foo', 'bar' );
AllOrNone means that if one is filled out, all of them have to be.
Marcus Ramberg, mramberg@cpan.org
This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself.
| HTML-Widget documentation | Contained in the HTML-Widget distribution. |
package HTML::Widget::Constraint::AllOrNone; use warnings; use strict; use base 'HTML::Widget::Constraint';
sub process { my ( $self, $w, $params ) = @_; my $results = []; my $one; for my $name ( @{ $self->names } ) { if ($self->not ? ( defined $params->{$name} && length $params->{$name} ) : ( !defined $params->{$name} || !length $params->{$name} ) ) { push @$results, HTML::Widget::Error->new( { name => $name, message => $self->mk_message } ); } else { $one++; } } return ( $one ? $results : [] ); }
1;