Permalink
Browse files

added support for self rule (not validation) messages

  • Loading branch information...
typester
typester committed Apr 10, 2007
1 parent 347de4b commit a9687a68cf82ec7dc927b68e21272dc4951c66ee
Showing with 7 additions and 5 deletions.
  1. +5 −3 lib/Catalyst/Plugin/FormValidator/Simple/Auto.pm
  2. +2 −2 t/04_bundle_message.t
@@ -147,18 +147,20 @@ sub setup {
for my $param ( keys %$profile ) {
my $rules = $profile->{$param} || [];
+ my $i = 0;
for my $rule (@$rules) {
if ( ref $rule eq 'HASH' and defined $rule->{rule} ) {
my $rule_name = ref $rule->{rule} eq 'ARRAY' ? $rule->{rule}[0] : $rule->{rule};
$messages->{$action}{$param} ||= {};
$messages->{$action}{$param}{ $rule_name } = $rule->{message} if defined $rule->{message};
$rule = $rule->{rule};
}
- elsif (ref $rule eq 'HASH' and defined $rule->{_rule} ) {
+ elsif (ref $rule eq 'HASH' and defined $rule->{self_rule} ) {
$messages->{$action}{$param} ||= {};
- $messages->{$action}{$param}{ $rule->{_rule} } = $rule->{message} if defined $rule->{message};
- undef $rule;
+ $messages->{$action}{$param}{ $rule->{self_rule} } = $rule->{message} if defined $rule->{message};
+ delete $rules->[$i];
}
+ $i++;
}
}
}
View
@@ -23,7 +23,7 @@ use warnings;
},
action2_submit => { param1 => [ 'NOT_BLANK', 'ASCII' ], },
action3 => {
- param1 => [ { _rule => 'SELF', message => 'SELF!!', }, ],
+ param1 => [ { self_rule => 'SELF', message => 'SELF!!', }, ],
},
},
},
@@ -104,4 +104,4 @@ is( $res->content, 'no $c->form executed', 'is no $c->form executed');
# bundle message that not validation rule
-is( get('/action3'), 'SELF!!', 'self message ok');
+is( get('/action3'), 'SELF!!', 'self ruled message ok');

0 comments on commit a9687a6

Please sign in to comment.