| 1 | package HTML::Widget::Constraint::SingleValue; | ||
| 2 | |||
| 3 | use warnings; | ||
| 4 | use strict; | ||
| 5 | use base 'HTML::Widget::Constraint'; | ||
| 6 | |||
| 7 | =head1 NAME | ||
| 8 | |||
| 9 | HTML::Widget::Constraint::SingleValue - SingleValue Constraint | ||
| 10 | |||
| 11 | =head1 SYNOPSIS | ||
| 12 | |||
| 13 | my $c = $widget->constraint( 'SingleValue', 'foo' ); | ||
| 14 | |||
| 15 | =head1 DESCRIPTION | ||
| 16 | |||
| 17 | Ensures that multiple values were not submitted for the named element. | ||
| 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 ($name) = @{ $self->names }; | ||
| 29 | |||
| 30 | if ( ref $params->{$name} ) { | ||
| 31 | push @$results, HTML::Widget::Error->new( | ||
| 32 | { name => $name, message => $self->mk_message } ); | ||
| 33 | } | ||
| 34 | |||
| 35 | return $results; | ||
| 36 | } | ||
| 37 | |||
| 38 | =head1 AUTHOR | ||
| 39 | |||
| 40 | Carl Franks, C<cfranks@cpan.org> | ||
| 41 | |||
| 42 | =head1 LICENSE | ||
| 43 | |||
| 44 | This library is free software, you can redistribute it and/or modify it under | ||
| 45 | the same terms as Perl itself. | ||
| 46 | |||
| 47 | =cut | ||
| 48 | |||
| 49 | 1; |