Data-FormValidator-Tutorial

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

                      return 0;
                    }
                  },
      ...

    You could also bump that subroutine outside the data structure somewhere
    and refer to it by name:

      ...
                'email' => \&my_domain_email(),
      ...
      sub my_domain_email {
        ...
      }

    Lastly, either you or the PHB (pointed-haired boss) will note that
    password1 and password2 should be confirmed to be the same thing, to
    make sure the user didn't typo the password wrong. I think you can
    handle that yourself, given the ammo I've given above, but it does use a
    twist, so let me introduce it. First off, it would be a "constraint" and
    it would point to a subroutine, but there are multiple parameters
    involved: "password1" and "password2". Whenever that happens, you define
    the constraint like so:

      ...
            'constraints' => {
                'email'     => 'email',
                'password1' => {
                    'constraint' => "check_passwords",
                    'params'     => [ qw( password1 password2 ) ],
                  },
              },
      ...

    So what this is saying is to check "password1", but instead of pointing
    to a regexp pattern, a built-in constraint or a subroutine, it's
    actually pointing to a more complex hashref. Within that hashref is
    "constraint", which could be confusing, but it simply is the name of a
    subroutine that will be called. Also within the hashref is "params",
    which is a list of the parameters to pass in as arguments to the
    subroutine. So then somewhere in your code, you'll have the
    "check_passwords" method:

      sub check_passwords {
        my ( $pw1, $pw2 ) = @_;
        if ( $pw1 eq $pw2 ) {
          return 1;
        } else {
          return 0;
        }
      }

TODO
    This is just an early release of this tutorial - we're using the release
    early & often mentality, so there's still a few things left to do. We
    want to address of of the more complicated aspects of dfv, like Filters,
    etc.

SEE ALSO
    Data::FormValidator and the dfv mailing list:
    <http://lists.sourceforge.net/lists/listinfo/cascade-dataform>

    Also, Jason Purdy presented dfv at ApacheCon 2005
    (<http://www.apachecon.com>). You can download the slides here:

    <http://www.purdy.info/useperl/th06_slides.pdf>

AUTHORS
    Originally written by T. M. Brannon, <tbone@cpan.org>

    William McKee, <william@knowmad.com> and Jason Purdy, <jason@purdy.info>

LICENSE
    Copyright (C) 2004-2005 Jason Purdy, <jason@purdy.info> and William
    McKee, <william@knowmad.com>

    This library is free software. You can modify and or distribute it under
    the same terms as Perl itself.



( run in 1.126 second using v1.01-cache-2.11-cpan-524268b4103 )