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

People
Owner: Nobody in particular
Requestors: mark [...] summersault.com
Cc:
AdminCc:

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



Date: Tue, 2 Dec 2003 09:38:37 -0500
From: Mark Stosberg <mark [...] summersault.com>
To: Adam Thick <adam.thick [...] strategicdata.com.au>
CC: cascade-dataform [...] lists.sourceforge.net
Subject: Re: [dfv] zero and constraints
On Tue, Dec 02, 2003 at 10:38:37AM +1100, Adam Thick wrote: Show quoted text
> Hi I've been happily using Data::FormValidator in conjuction with > CGI::App. I've encountered a problem when I submit a value from a form, > using a constraint like > > 'BLAH' => { > name => 'number', > constraint => qr/^\d+$/, > }, > > if the value is 0, it passes the constraint but is then rejected > somewhere in FormValidator and brings me back to my form screen with my > error message 'this is not a valid number' > > 00 works and is passed through fine... > > letters and other characters are rejected which you would expect so I > can only assume that 0 causes Data::FormValidator to fail on some test > internally?
Thanks for the report. I've submitted this to the bug tracking system and will look into it. If someone else wants to look into it more and/or write a formal test case for it, that would be helpful. :) Since we are already requiring Regexp::Common, perhaps I should just make "number" an alias to Regexp::Common RE, which I can only imagine will be more thorough and better tested. In the meantime, you might want to just use one of the Regexp::Common functions directly. Maybe you want: RE_num_int See Regexp::Common::number for more options. Mark -- . . . . . . . . . . . . . . . . . . . . . . . . . . . Mark Stosberg Principal Developer mark@summersault.com Summersault, LLC 765-939-9301 ext 202 database driven websites . . . . . http://www.summersault.com/ . . . . . . . .
[mark@summersault.com - Tue Dec 2 09:38:44 2003]: Show quoted text
> On Tue, Dec 02, 2003 at 10:38:37AM +1100, Adam Thick wrote:
> > Hi I've been happily using Data::FormValidator in conjuction with > > CGI::App. I've encountered a problem when I submit a value from a
> form,
> > using a constraint like > > > > 'BLAH' => { > > name => 'number', > > constraint => qr/^\d+$/, > > }, > > > > if the value is 0, it passes the constraint but is then rejected > > somewhere in FormValidator and brings me back to my form screen with
> my
> > error message 'this is not a valid number' > > > > 00 works and is passed through fine... > > > > letters and other characters are rejected which you would expect so
> I
> > can only assume that 0 causes Data::FormValidator to fail on some
> test
> > internally?
I've resolved this ticket as not being a bug. The below test case appears to confirm that. I'm adding this test to future versions of the distribution so this won't break in the future either. If there still appears to be a bug, please update the test case so that it is triggered. Mark #!/usr/bin/perl use Test::More qw/no_plan/; use strict; use Data::FormValidator; my $input_profile = { required => [ qw( number_field ) ], constraints => { number_field => { name => 'number', constraint => qr/^\d+$/, } } }; my $input_hashref = { number_field => 0, }; my $results; eval{ $results = Data::FormValidator->check($input_hashref, $input_profile); }; ok(!$@, 'survived validate'); is($results->valid->{number_field},0, 'using 0 in a constraint regexp works');