Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • I have a class that combines Data::FormValidator and some other things so I can write:
    my $addr = Foo::Address->new($cgi);
    if ($addr->is_valid) {
      # XXX
    } else {
      print "The following fields are missing or invalid: ", join("\n", $addr->errors);
    }
    It has a few neat features including supporting a prefix so if you have two addresses in the same field you can use:
    <input type="text" name="addr1.name">
    <input type="text" name="addr2.name">
    and:
    my $addr1 = Foo::Address->new($cgi, 'addr1');
    my $addr2 = Foo::Address->new($cgi, 'addr2');
    It's made things way easier.
    • Very cool idea! Could it work in conjuntion with something like CGI::Untaint or Class::DBI::FromCGI? Any chance this could be released to CPAN? How do you handle testing with your object level validation - dummy CGI object?

      I have something similar to you except I combine the validation at a higher level when deciding if a form should be processed or simply displayed. So I can't do the individual object level validation like you're doing. Any errors from D::FV are eventually stuffed into the template param

      --
      "Perl users are the Greatful Dead fans of computer science." --slashdot comment
      • I've been thinking about the client-side JS validation recently. What my plan is:
        1. Write something like D::FV but with a more flexible store for the rules
        2. Have a JS version of this
        3. Use one of the SpiderMonkey based CPAN modules to test Perl vs JS
        4. Release to CPAN
        5. ...
        6. Profit!

        • My thinking was to have the validation module be able to write a JS function (ie. check_form() ), that would do at least the easier checks. This of course requires some other template support to automatically set the onSubmit attribute of the appropriate element. The checks would just cover the simple cases: required field & dependencies. If this field is not present, then fail. If field a is "foo", then fields x & y are also required. I want to do it all in a single module, which can then be tran
          --
          "Perl users are the Greatful Dead fans of computer science." --slashdot comment