Skip Menu |

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

Report information
The Basics
Id: 68260
Status: open
Priority: 0/
Queue: FormValidator-Simple

People
Owner: Nobody in particular
Requestors: abraxxa [...] cpan.org
Cc:
AdminCc:

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



Subject: LENGTH 0 validation fails
additional test demonstrating the bug: [ahartmai@ahartmai-nb FormValidator-Simple-0.28]$ diff -u t/08_length.t t/08_length-new.t --- t/08_length.t 2011-05-17 10:27:36.166427423 +0200 +++ t/08_length-new.t 2011-05-17 10:27:25.866412319 +0200 @@ -1,5 +1,5 @@ use strict; -use Test::More tests => 7; +use Test::More tests => 8; use CGI; BEGIN{ use_ok("FormValidator::Simple") } @@ -44,3 +44,8 @@ ok(!$r6->invalid('text')); +my $r7 = FormValidator::Simple->check( $q => [ + text => [[qw/LENGTH 0 8/]], +] ); + +ok(!$r7->invalid(''));
Show quoted text
> +ok(!$r7->invalid(''));
This should be ok(!$r7->invalid('text')); right?
No, an empty field should be valid when the length is allowed to be zero.
On 2011-5月-30 月 04:30:42, ABRAXXA wrote: Show quoted text
> No, an empty field should be valid when the length is allowed to be zero.
I guess you misunderstood usage. maybe you want to do my $q2 = CGI->new; $q2->param( param1 => '' ); my $r8 = FormValidator::Simple->check( $q2 => [ param1 => [[qw/LENGTH 0 8/]], ] ); ok(!$r8->invalid('param1'));
Ah, ok! This is the correct test then: --- t/08_length.t 2011-05-17 10:27:36.166427423 +0200 +++ t/08_length-new.t 2011-05-30 11:09:41.174279205 +0200 @@ -1,5 +1,5 @@ use strict; -use Test::More tests => 7; +use Test::More tests => 8; use CGI; BEGIN{ use_ok("FormValidator::Simple") } @@ -43,4 +43,10 @@ ok(!$r6->invalid('text')); +$q->param( empty => '' ); +my $r7 = FormValidator::Simple->check( $q => [ + empty => [[qw/LENGTH 0 8/]], +] ); + +ok(!$r7->invalid('empty')); Strangely this doesn't fail while my code does. You can close the ticket, I'll reopen it if I can reproduce my failure with a test case.