I meant to send this comment earlier in the day, I hope it is still useful:
FRAGMENT - not complete: my ($results, $err_page) = $self->check_rm('qs_display', { required => [qw/upfirstname uplastname upemail upusername +uppassword confirm_password/], optional => [qw/upzip upcountry/], filters => ['trim'], constraints => { uppassword => { #Make sure passwords are the same name => 'user_passwords', constraint => \&check_password, params => [qw(uppassword confirm_password)], }, upusername => { #Is username unique? name => 'user_username', constraint => \&check_username, params => [qw(upusername)], }, upemail => 'email', upzip => 'zip_or_postcode', }, msgs => { any_errors => 'err__', prefix => 'err_', constraints => { 'user_passwords' => "Your passwords don't match", 'user_username' => "Username not unique", }, }, } ); return $err_page if $err_page; # Results are valid my $dfv_results = $results->valid(); print STDERR Dumper( $dfv_results ); $self->header_type('redirect'); $self->header_props( -url => 'http://posiedon.mine.nu'); return; } sub check_password { my ($p1, $p2) = @_; if ($p1 eq $p2) { return 1; } else { return 0; } }
I think it is pretty straightforward. I get the two passowrd values from my form, the trivial sub (which could be much simplified!) merely returns true or false. I am using D::FV 3.14 with CGI::Application

The code is not original, Cees Hek gave me the outline in an answer to a question on the CGI::App mail list.

jdtoronto


In reply to Re: Data::FormValidator constraints against local sub routine by jdtoronto
in thread Data::FormValidator constraints against local sub routine by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.