[Html-widget] Bug in Constraint::Range with 0 for min and max.

Xavier Robin robin0 at etu.unige.ch
Fri Dec 8 08:44:15 GMT 2006


Hello,

When you set a Range constraint with min(0) and/or max(0), they are ignored.

I don't know if it is by design, but it took me a while to find out why my 
Range definitions were ignored. If it is by design, it should be clearly 
stated in the docs, because it is commonplace to check for positivity or 
negativity of numbers. If it is a bug, I explain the fix below.

I opened Range.pm and replaced 

>     if ( !$failed && $minimum ) {
>         $failed++ unless ( $value >= $minimum );
>     }

by 

>     if ( !$failed && defined $minimum ) {
>         $failed++ unless ( $value >= $minimum );
>     }

(Same for maximum, of course.)

Checking the "defined" status of $minimum rather than $minimum itself seems to 
work fine (a $minimum of 0 returned false and the check was ignored).

Now I can check for positive or negative numbers.

Greetings,
Xavier



More information about the Html-widget mailing list