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

People
Owner: MARKSTOS [...] cpan.org
Requestors: rjuliano [...] 2co.com
Cc:
AdminCc:

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



Subject: missing_optional_valid implies missing_optional_invalid_valid
Date: Thu, 16 Aug 2007 11:44:39 -0400
To: <bug-Data-FormValidator [...] rt.cpan.org>
From: "Robert Juliano" <rjuliano [...] 2co.com>
Summary: invalid optional fields end up both valid and invalid when missing_optional_valid is set to true. Broken in: 4.51 Expect invalid fields not to be valid. Test and patch included. ---------------------------------------------------------------------------- --- ### TEST use strict; use Test::More tests => 2; use Data::FormValidator; my $data = { optional_invalid => 'invalid' }; my $profile = { optional => [qw/optional_invalid/], constraints => { optional_invalid => qr/^valid$/ }, missing_optional_valid => 1 }; my $results = Data::FormValidator->check($data, $profile); my $valid = $results->valid(); my $invalid = $results->invalid(); ok( exists $invalid->{'optional_invalid'}, 'optional_invalid is invalid'); ok( !exists $valid->{'optional_invalid'}, 'optional_invalid is not valid'); #--------------------------------------------------------------------------- ---- ### PATCH --- Data/FormValidator/Results.pm.orig 2007-08-15 16:06:50.000000000 -0400 +++ Data/FormValidator/Results.pm 2007-08-15 16:18:11.000000000 -0400 @@ -364,11 +364,6 @@ my $force_method_p = 1; $self->_check_constraints($private_constraint_methods,\%valid,$untaint_all,\ %untaint_hash, $force_method_p); - # all invalid fields are removed from valid hash - foreach my $field (keys %{ $self->{invalid} }) { - delete $valid{$field}; - } - # add back in missing optional fields from the data hash if we need to foreach my $field ( keys %data ) { if ($profile->{missing_optional_valid} and $optional{$field} and (not exists $valid{$field})) { @@ -376,6 +371,11 @@ } } + # all invalid fields are removed from valid hash + foreach my $field (keys %{ $self->{invalid} }) { + delete $valid{$field}; + } + my ($missing,$invalid); $self->{valid} ||= {};
Subject: Re: [rt.cpan.org #28860] missing_optional_valid implies missing_optional_invalid_valid
Date: Thu, 16 Aug 2007 12:15:30 -0400
To: bug-Data-FormValidator [...] rt.cpan.org
From: Mark Stosberg <mark [...] summersault.com>
On Thursday 16 August 2007 11:45, rjuliano@2co.com via RT wrote: Show quoted text
> Thu Aug 16 11:45:16 2007: Request 28860 was acted upon. > Transaction: Ticket created by rjuliano@2co.com > Queue: Data-FormValidator > Subject: missing_optional_valid implies missing_optional_invalid_valid > Broken in: (no value) > Severity: (no value) > Owner: Nobody > Requestors: rjuliano@2co.com > Status: new > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=28860 > > > > Summary: invalid optional fields end up both valid and invalid when > missing_optional_valid is set to true. > Broken in: 4.51 > > Expect invalid fields not to be valid. > Test and patch included.
Thanks for the patch and test. On first pass, they look good. I'll give them another round of review, and expect to apply and release them with credit to you based on that additional review. Mark
Patch applied and will appear in the next release, with credit to you. Thanks. Mark
4.53 has been sent to CPAN to address this.