FormValidator::LazyWay

Index: lib/FormValidator/LazyWay.pm
===================================================================
--- lib/FormValidator/LazyWay.pm        (revision 14373)
+++ lib/FormValidator/LazyWay.pm        (working copy)
@@ -72,7 +72,16 @@
     $storage->{has_error}   = ( $storage->{has_missing} || $storage->{has_invalid} ) ? 1 : 0 ;
     $storage->{success}   = ( $storage->{has_missing} || $storage->{has_invalid} ) ? 0 : 1 ;

-    return FormValidator::LazyWay::Result->new($storage);
+    {
+        no strict 'refs';
+        my $resclass = 'FormValidator::LazyWay::Result';
+        *{"${resclass}::valid"} = sub {
+            return $_[0]->{valid} if @_ == 1;
+            return $_[0]->{valid}->{ $_[1] } if @_ == 2;
+        };
+    }
+
+    FormValidator::LazyWay::Result->new($storage);
 }

 sub _set_error_message_for_display {
created by woremacx [vaginarepos.org]

コメント

コメントはありません

コメントを投稿

コメントを投稿するにはログインが必要です