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: 5951
Status: resolved
Priority: 0/
Queue: Data-FormValidator

People
Owner: Nobody in particular
Requestors: jason [...] multiply.org
Cc:
AdminCc:

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



Subject: Error when using "email" for a constraint.
Hi. If i run the script below (or a wrapper i have built for D::FV), and i use "email" for a constraint, an invalid field changes the value of that field to an array reference instead of the invalid value. If an email address passes, it is left alone. My system is fedora core 1 with perl 5.8.3 and Data::FormValidator 3.54. Below is my example script and the sample output. use Data::FormValidator; %VAR1 = ( 'create' => 'Create New Category', 'name' => ' asdf ', 'sort_position' => '1', 'description' => ' asdf ', 'email_addy' => 'jasonmultiply.org' ); my $profile = { optional => [qw( description )], required => [qw( name email_addy )], constraints => { email_addy => 'email' } }; my $results = Data::FormValidator->check(\%VAR1, $profile); use Data::Dumper; print Dumper( $results ); ---------------- OUTPUT: ---------------- $VAR1 = bless( { 'profile' => { 'defaults' => {}, 'dependencies' => {}, 'optional' => [ 'description' ], 'dependency_groups' => {}, 'constraint_regexp_map' => {}, 'constraints' => { 'email_addy' => 'email' }, 'required' => [ 'name', 'email_addy' ], 'require_some' => {}, 'field_filter_regexp_map' => {}, 'field_filters' => {} }, 'validate_invalid' => [ 'email_addy' ], '__INPUT_DATA' => { 'create' => 'Create New Category', 'sort_position' => '1', 'email_addy' => 'jasonmultiply.org', 'name' => ' asdf ', 'description' => ' asdf ' }, 'missing' => {}, '__CURRENT_CONSTRAINT_FIELD' => 'email_addy', '__CURRENT_CONSTRAINT_VALUE' => 'jasonmultiply.org', 'valid' => { 'name' => ' asdf ', 'description' => ' asdf ' }, '__CURRENT_CONSTRAINT_NAME' => 'email', 'unknown' => { 'create' => 1, 'sort_position' => 1 }, 'invalid' => { 'email_addy' => [ 'email' ] } }, 'Data::FormValidator::Results' );
Date: Tue, 6 Apr 2004 13:05:20 -0500
From: Mark Stosberg <mark [...] summersault.com>
To: Guest via RT <bug-Data-FormValidator [...] rt.cpan.org>
CC: "Data::FormValidator list" <cascade-dataform [...] lists.sourceforge.net>
Subject: Re: [cpan #5951] Error when using "email" for a constraint.
RT-Send-Cc:
My comments below. On Tue, Apr 06, 2004 at 01:58:10PM -0400, Guest via RT wrote: Show quoted text
> > This message about Data-FormValidator was sent to you by guest <> via rt.cpan.org > > Full context and any attached attachments can be found at: > <URL: https://rt.cpan.org/Ticket/Display.html?id=5951 > > > Hi. > > If i run the script below (or a wrapper i have built for D::FV), and i use "email" for a constraint, an invalid field changes the value of that field to an array reference instead of the invalid value. If an email address passes, it is left alone. > > My system is fedora core 1 with perl 5.8.3 and Data::FormValidator 3.54. > > Below is my example script and the sample output. > > use Data::FormValidator; > > %VAR1 = ( > 'create' => 'Create New Category', > 'name' => ' asdf ', > 'sort_position' => '1', > 'description' => ' asdf ', > 'email_addy' => 'jasonmultiply.org' > ); > > my $profile = { > optional => [qw( description )], > > required => [qw( name > email_addy )], > > constraints => { > email_addy => 'email' > } > }; > > my $results = Data::FormValidator->check(\%VAR1, $profile); > use Data::Dumper; > > print Dumper( $results ); > ---------------- > OUTPUT: > ---------------- > $VAR1 = bless( { > 'profile' => { > 'defaults' => {}, > 'dependencies' => {}, > 'optional' => [ > 'description' > ], > 'dependency_groups' => {}, > 'constraint_regexp_map' => {}, > 'constraints' => { > 'email_addy' => 'email' > }, > 'required' => [ > 'name', > 'email_addy' > ], > 'require_some' => {}, > 'field_filter_regexp_map' => {}, > 'field_filters' => {} > }, > 'validate_invalid' => [ > 'email_addy' > ], > '__INPUT_DATA' => { > 'create' => 'Create New Category', > 'sort_position' => '1', > 'email_addy' => 'jasonmultiply.org', > 'name' => ' asdf ', > 'description' => ' asdf ' > }, > 'missing' => {}, > '__CURRENT_CONSTRAINT_FIELD' => 'email_addy', > '__CURRENT_CONSTRAINT_VALUE' => 'jasonmultiply.org', > 'valid' => { > 'name' => ' asdf ', > 'description' => ' asdf ' > }, > '__CURRENT_CONSTRAINT_NAME' => 'email', > 'unknown' => { > 'create' => 1, > 'sort_position' => 1 > }, > 'invalid' => { > 'email_addy' => [ > 'email' > ] > } > }, 'Data::FormValidator::Results' );
Thanks for the bug report. From reviewing your submission, this does appear to be a bug. Returning an arrayref is the correct response if multiple constraints are applied. However, that does not appear to be what's happening in your case. If this could be turned into a Test::More test case that fails, that would be great. Otherwise, I'll get to myself. Mark -- . . . . . . . . . . . . . . . . . . . . . . . . . . . Mark Stosberg Principal Developer mark@summersault.com Summersault, LLC 765-939-9301 ext 202 database driven websites . . . . . http://www.summersault.com/ . . . . . . . .
Date: Tue, 6 Apr 2004 20:39:22 -0500
From: Mark Stosberg <mark [...] summersault.com>
To: Guest via RT <bug-Data-FormValidator [...] rt.cpan.org>, "Data::FormValidator list" <cascade-dataform [...] lists.sourceforge.net>
Subject: Re: [dfv] Re: [cpan #5951] Error when using "email" for a constraint.
RT-Send-Cc:
On Tue, Apr 06, 2004 at 01:05:20PM -0500, Mark Stosberg wrote: Show quoted text
> My comments below. > > On Tue, Apr 06, 2004 at 01:58:10PM -0400, Guest via RT wrote:
> > > > This message about Data-FormValidator was sent to you by guest <> via rt.cpan.org > > > > Full context and any attached attachments can be found at: > > <URL: https://rt.cpan.org/Ticket/Display.html?id=5951 > > > > > Hi. > > > > If i run the script below (or a wrapper i have built for D::FV), and > > i use "email" for a constraint, an invalid field changes the value > > of that field to an array reference instead of the invalid value. > > If an email address passes, it is left alone.
I had a chance to look at this again tonight. The result is that I'd still like to see the Test::More style test. :) From looking at the docs, it appears that it is /supposed to return an arrayref of failed constraints: invalid( [field] ) This method returns in an array context the list of fields which con- tains invalid value. In a scalar context, it returns an hash reference which contains the invalid fields as keys, and references to arrays of failed constraints as values. If called with an argument, it returns the reference to an array of failed constraints for this field. ################## So it's not clear to me what the incorrect behavior you are experiencing is. Mark -- http://mark.stosberg.com/