Skip to content

Commit

Permalink
V0.12
Browse files Browse the repository at this point in the history
  • Loading branch information
Viktor Turskyi committed Jun 24, 2012
1 parent e49cead commit 2fc4e83
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 4 additions & 1 deletion Changes
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ Revision history for Mojolicious::Plugin::ValidateTiny

0.11
Improved POD
Added fix for potential problem which will appear if $c->param($field) will return empty list
Added fix for potential problem which will appear if $c->param($field) will return empty list

0.12
Added support for parameters with multiple values
7 changes: 5 additions & 2 deletions lib/Mojolicious/Plugin/ValidateTiny.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use warnings;
use Carp qw/croak/;
use Validate::Tiny;

our $VERSION = '0.11';
our $VERSION = '0.12';

sub register {
my ( $self, $app, $conf ) = @_;
Expand All @@ -33,7 +33,10 @@ sub register {
$rules->{fields} ||= [];

# Validate GET+POST parameters by default
$params ||= { map { $_ => ( $c->param($_) // undef ) } $c->param };
$params ||= { map {
my @values = $c->param($_);
$_ => ( @values > 1 ? \@values : ( $values[0] // undef ) );
} $c->param };

# Autofill fields
if ( $conf->{autofields} ) {
Expand Down

0 comments on commit 2fc4e83

Please sign in to comment.