Skip Menu |

This queue is for tickets about the Data-FormValidator CPAN distribution.

Maintainer(s)' notes

This is the bug queue for Data::FormValidator.

Report information
The Basics
Id: 14952
Status: resolved
Priority: 0/
Queue: Data-FormValidator

People
Owner: MARKSTOS [...] cpan.org
Requestors: mag-perl [...] occamstoothbrush.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 4.02
Fixed in: (no value)



Subject: value of any_errors gets added to msgs even when there are no errors
In my Data::FormValidator validation profile, I've added a custom 'any_errors' message msgs => { 'any_errors' => 'some_errors' }, The docs suggest that the 'some_errors' key will be present in the result's msgs only if there were errors returned. However, it seems to me that it is always added, even if the input data passed the validation profile. I've attached a test script with failing tests for this case. Environment: Data::FormValidator 4.02 on perl 5.8.5 (Centos 4.1) Michael
#!/usr/bin/perl use strict; use Test::More 'no_plan'; use Data::FormValidator; my $dfv_standard_any_errors = Data::FormValidator->new({}); my $dfv_custom_any_errors = Data::FormValidator->new({},{msgs => { any_errors => 'some_errors' }}); my %profile = ( required => 'foo', ); my %good_input = ( 'foo' => 1, ); my %bad_input = ( 'bar' => 1, ); my ($results, $msgs); # standard 'any_errors', good input $results = $dfv_standard_any_errors->check(\%good_input, \%profile); $msgs = $results->msgs; ok($results, "[standard any_errors] good input passed"); ok(!keys %$msgs, "[standard any_errors] no error messages"); # standard 'any_errors', bad input $results = $dfv_standard_any_errors->check(\%bad_input, \%profile); $msgs = $results->msgs; ok(!$results, "[standard any_errors] bad input caught"); ok(keys %$msgs, "[standard any_errors] error messages reported"); # custom 'any_errors', good input $results = $dfv_custom_any_errors->check(\%good_input, \%profile); $msgs = $results->msgs; ok($results, "[standard any_errors] good input passed"); ok(!keys %$msgs, "[standard any_errors] no error messages"); ok(!$msgs->{'some_errors'}, "[standard any_errors] 'some_errors' not reported"); # custom 'any_errors', bad input $results = $dfv_custom_any_errors->check(\%bad_input, \%profile); $msgs = $results->msgs; ok(!$results, "[standard any_errors] bad input caught"); ok(keys %$msgs, "[standard any_errors] error messages reported"); ok($msgs->{'some_errors'}, "[standard any_errors] 'some_errors' reported");
Sorry - some misleading test names in the test script. I've attached a copy with better names. Michael
#!/usr/bin/perl use strict; use Test::More 'no_plan'; use Data::FormValidator; my $dfv_standard_any_errors = Data::FormValidator->new({}); my $dfv_custom_any_errors = Data::FormValidator->new({},{msgs => { any_errors => 'some_errors' }}); my %profile = ( required => 'foo', ); my %good_input = ( 'foo' => 1, ); my %bad_input = ( 'bar' => 1, ); my ($results, $msgs); # standard 'any_errors', good input $results = $dfv_standard_any_errors->check(\%good_input, \%profile); $msgs = $results->msgs; ok($results, "[standard any_errors] good input passed"); ok(!keys %$msgs, "[standard any_errors] no error messages"); # standard 'any_errors', bad input $results = $dfv_standard_any_errors->check(\%bad_input, \%profile); $msgs = $results->msgs; ok(!$results, "[standard any_errors] bad input caught"); ok(keys %$msgs, "[standard any_errors] error messages reported"); # custom 'any_errors', good input $results = $dfv_custom_any_errors->check(\%good_input, \%profile); $msgs = $results->msgs; ok($results, "[custom any_errors] good input passed"); ok(!keys %$msgs, "[custom any_errors] no error messages"); ok(!$msgs->{'some_errors'}, "[custom any_errors] 'some_errors' not reported"); # custom 'any_errors', bad input $results = $dfv_custom_any_errors->check(\%bad_input, \%profile); $msgs = $results->msgs; ok(!$results, "[custom any_errors] bad input caught"); ok(keys %$msgs, "[custom any_errors] error messages reported"); ok($msgs->{'some_errors'}, "[custom any_errors] 'some_errors' reported");
Date: Thu, 6 Oct 2005 09:14:36 -0500
From: Mark Stosberg <mark [...] summersault.com>
To: via RT <bug-Data-FormValidator [...] rt.cpan.org>
Subject: Re: [cpan #14952] value of any_errors gets added to msgs even when there are no errors
RT-Send-Cc:
On Wed, Oct 05, 2005 at 11:38:04PM -0400, via RT wrote: Show quoted text
> > This message about Data-FormValidator was sent to you by MGRAHAM <MGRAHAM@cpan.org> via rt.cpan.org > > Full context and any attached attachments can be found at: > <URL: https://rt.cpan.org/Ticket/Display.html?id=14952 > > > Sorry - some misleading test names in the test script. > > I've attached a copy with better names.
Thanks for the contribution Michael. I expect to get to it somewhat soon. Mark