Anneq has asked for the wisdom of the Perl Monks concerning the following question:

I'm using Data::FormValidator, which has saved me many lines of code and has greatly simplified my validation logic. Excellent module.

However, due my lack of Perl experience, I'm having trouble creating a D::FV profile to apply multiple constraints to a single query parameter. I've searched the POD, perlmonks and googled but didn't find anything that helped me see how to do it. Here is a snippet of what I've got so far:

my $ca_obj = shift; # CGI::Application object my $q = $ca_obj->query(); my $dfv_profile = { required => [qw (userid)], constraints => { userid => { name => 'userid_exists', constraint => sub { return !MyDBITools->user_exists($ca_obj); }, }, userid => { name => 'userid_untaint', constraint => qr/^[-\@\w.]+$/, }, }, msgs => { format => '%s', constraints => { 'userid_exists' => "User ID already exists.", 'userid_untaint'=> "User ID contains bad stuff", }, }, }; my $results = Data::FormValidator->check($q, $dfv_profile);

Using the code above, as I fully expected it to, the userid_untaint constraint is overriding the userid_exists constraint, because the second instance of the userid hash key is trashing the first. This is clear from my results. I get the "User ID contains bad stuff" error and the already existing user gets registered. If I remove the userid_untaint constraint, I get the expected error message "User ID already exists."

Does anyone know the proper syntax to write multiple constraints for a single variable?