Skip to content

Commit

Permalink
input and output might not be the same (closes #825)
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Aug 7, 2015
1 parent 6a51c3e commit 523ed7a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/Mojolicious/Validator/Validation.pm
Expand Up @@ -23,10 +23,10 @@ sub check {

return $self unless $self->is_valid;

my $cb = $self->validator->checks->{$check};
my $name = $self->topic;
my $input = $self->input->{$name};
for my $value (ref $input eq 'ARRAY' ? @$input : $input) {
my $cb = $self->validator->checks->{$check};
my $name = $self->topic;
my $values = $self->output->{$name};
for my $value (ref $values eq 'ARRAY' ? @$values : $values) {
next unless my $result = $self->$cb($name, $value, @_);
return $self->error($name => [$check, $result, @_]);
}
Expand Down
1 change: 1 addition & 0 deletions t/mojolicious/validation_lite_app.t
Expand Up @@ -160,6 +160,7 @@ ok !$validation->has_data, 'no data';
$validation->input({foo => ['', 'bar', ''], bar => ['', 'baz', '']});
ok $validation->has_data, 'has data';
ok $validation->optional('bar')->is_valid, 'valid';
ok $validation->in('baz')->is_valid, 'still valid';
is_deeply $validation->output, {bar => 'baz'}, 'right result';
ok !$validation->has_error, 'no error';
ok !$validation->required('foo')->is_valid, 'not valid';
Expand Down

0 comments on commit 523ed7a

Please sign in to comment.