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

Carl Franks fireartist at gmail.com
Fri Dec 8 08:55:04 GMT 2006


On 08/12/06, Xavier Robin <robin0 at etu.unige.ch> wrote:
> 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.

This has already been fixed in svn, commit 5203.

Maybe time for another cpan release.

Thanks,
Carl



More information about the Html-widget mailing list