kevin montuori | 9 Feb 23:56
Picon

[FormBuilder] validate + commas in FB source files


hi all -- first off, CGI::FB is a great module.  it's saved me
countless hours of tedious mind-numbing typing.  thanks a lot to
nate and anyone else responsible.

i have a question about using CGI::FormBuilder::Source::File with
regexps in the validate field: one of the things i really want to do
is make sure the length of the input is between a min and max value:

  validate: /^\w{3,32}$/

and it seems like this sort of thing would be not atypical.
unfortunately, the regex is split into two values when there's a comma
in the regex (via $source->write_module()):

  'validate' => [
                  '/^\\w{3',
                  '32}$/'

so : is there a canonical way of checking for min/max length that i'm
not aware of?  

would there be any interest in changing File.pm (~ line 155) from:

   # split commas
   @val = split /\s*,\s*/, $line;

to something like:

   # split commas
   my $split_regex = lc $term eq 'validate'
     ? qr/\s*(?<!\\),\s*/ : qr/\s*,\s*/;
   @val = split $split_regex, $line;

which would allow this statement in the source file:

   validate: /^\w{3\,32}$/

to produce the more useful:

  'validate' => '/^\\w{3\\,32}$/'

it's easy enough to maintain my own source adapter that had this
particular tweak (and having that hook is damn good thinking) but i
thought maybe this would be more broadly useful.

thanks for your time.

cheers.
k.

--

-- 
kevin montuori
montuori <at> gmail.com
_______________________________________________
FBusers mailing list
FBusers <at> formbuilder.org
http://www.formbuilder.org/mailman/listinfo/fbusers


Gmane