Permalink
Browse files

use base FormValidator::Lite and add method.

  • Loading branch information...
1 parent f021719 commit 27f8c914b229480e8e4d17db3e8f5c36be17eea8 @nekokak committed Nov 2, 2009
Showing with 23 additions and 2 deletions.
  1. +23 −2 lib/Kamui/Plugin/FormValidatorLite.pm
@@ -13,7 +13,6 @@ sub register_method {
package Kamui::Plugin::FormValidatorLite::Backend;
use Kamui;
-use FormValidator::Lite;
use String::CamelCase qw/camelize/;
sub new {
@@ -36,7 +35,7 @@ sub valid {
};
my $validator = $valid_class->new(
- engine => FormValidator::Lite->new($self->c->req),
+ engine => Kamui::Plugin::FormValidatorLite::Backend::Base->new($self->c->req),
context => $self->c,
);
@@ -45,5 +44,27 @@ sub valid {
return $validator;
}
+package Kamui::Plugin::FormValidatorLite::Backend::Base;
+use Kamui;
+use base 'FormValidator::Lite';
+
+sub get_error_message_from_param {
+ my ($self, $target_param) = @_;
+
+ my %dup_check;
+ my @messages;
+ for my $err (@{$self->{_error_ary}}) {
+ my $param = $err->[0];
+ my $func = $err->[1];
+
+ next if $target_param ne $param;
+ next if exists $dup_check{"$param.$func"};
+ push @messages, $self->get_error_message( $param, $func );
+ $dup_check{"$param.$func"}++;
+ }
+
+ return @messages;
+}
+
1;

0 comments on commit 27f8c91

Please sign in to comment.