-
-
Save anonymous/97f7d055a6c450079069 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/Mojolicious/Validator/Validation.pm b/lib/Mojolicious/Validator/Validation.pm | |
index ac1c410..5d28115 100644 | |
--- a/lib/Mojolicious/Validator/Validation.pm | |
+++ b/lib/Mojolicious/Validator/Validation.pm | |
@@ -1,7 +1,8 @@ | |
package Mojolicious::Validator::Validation; | |
use Mojo::Base -base; | |
-use Carp (); | |
+use Carp (); | |
+use Mojo::JSON::Pointer; | |
use Scalar::Util (); | |
has [qw(csrf_token topic validator)]; | |
@@ -23,9 +24,12 @@ sub check { | |
return $self unless $self->is_valid; | |
- my $cb = $self->validator->checks->{$check}; | |
- my $name = $self->topic; | |
- my $input = $self->input->{$name}; | |
+ my $cb = $self->validator->checks->{$check}; | |
+ my $name = $self->topic; | |
+ my $input | |
+ = $name =~ m!^/! | |
+ ? Mojo::JSON::Pointer->new($self->input)->get($name) | |
+ : $self->input->{$name}; | |
for my $value (ref $input eq 'ARRAY' ? @$input : $input) { | |
next unless my $result = $self->$cb($name, $value, @_); | |
return $self->error($name => [$check, $result, @_]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment