[Bps-public-commit] r19107 - in RT-FormTools: .

sartak at bestpractical.com sartak at bestpractical.com
Thu Apr 9 04:39:49 EDT 2009


Author: sartak
Date: Thu Apr  9 04:39:49 2009
New Revision: 19107

Modified:
   RT-FormTools/   (props changed)
   RT-FormTools/html/FormTools/Form

Log:
 r81891 at onn:  sartak | 2009-04-09 04:39:40 -0400
 Allow coderef validators


Modified: RT-FormTools/html/FormTools/Form
==============================================================================
--- RT-FormTools/html/FormTools/Form	(original)
+++ RT-FormTools/html/FormTools/Form	Thu Apr  9 04:39:49 2009
@@ -19,14 +19,20 @@
     # registered validation
     if (my $validation = $m->notes('validation')) {
         while (my ($key, $validator) = each (%$validation)) {
-            if (!ref $validator) {
-                my $code = RT::Extension::FormTools->can($validator);
-                my ($ok, $res) = $code->($request_args{$key});
-                push @results, "$key: $res" unless $ok;
+            if (ref($validator) eq 'CODE') {
+                # no op
+            }
+            elsif (!ref($validator)) {
+                 my $method_name = $validator;
+                 $validator = RT::Extension::FormTools->can($method_name);
             }
             else {
-                warn "unknown validator for $key, ignoring."
+                warn "unknown validator for $key, ignoring.";
+                next;
             }
+
+            my ($ok, $res) = $code->($request_args{$key});
+            push @results, "$key: $res" unless $ok;
         }
     }
 



More information about the Bps-public-commit mailing list