RE: [PEAR-DEV] Quickform nonzero rule bug (?)
| From: | David Sklar | Date: | Wed, 25 Jun 2003 15:07:46 +0000 |
| Subject: | RE: [PEAR-DEV] Quickform nonzero rule bug (?) | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-17706@lists.php.net to get a copy of this message | ||
On Wednesday, June 25, 2003 11:04 AM, mailto:bmansion@mamasam.com wrote:
> <sklar@sklar.com> wrote :
>
>> On Wednesday, June 25, 2003 5:22 AM, ‰@
>> ´,ÎMø&—Šê‡mailto:jeroen@terena.nl wrote:
>>
>>>>> Anything below 10 won't validate. The rule on line 226 of
>>>>> Quickform.php is:
>>>>>
>>>>> 'nonzero' =>array('regex',
>>>>> '/^[1-9][0-9]+/'),
>>>>>
>>>>> Regex is not my strongest point, can anyone tell me of this looks
>>>>> right? It looks like it expect two digits..
>>>>>
>>>>>
>>>>
>>>> Hi Jeroen,
>>>>
>>>> You can probably use this regex instead: /^[1-9][0-9]?/
>>>>
>>>>
>>> Yep that works better. Any number except 0 will validate. Will you
>>> change it in CVS?
>>
>> I reported this a month ago
> (http://bugs.php.net/bug.php?id=23762) and it
>> was fixed and then rolled back.
>
> I rolled back because it changed the purpose of the rule which was to
> validate 2345 and not 02345. I guess it's not very useful and I don't
> know how it made it into QuickForm in the first place :) I never used
> this rule myself.
>
> Now, if no one objects, I can maybe change it for :
>
> /^-?[1-9][0-9]*$/ as you suggested AFAIK. But that's a BC break and
> it's quite easy to use 'regex' instead.
I think /^-?[1-9][0-9]*$/ is clearer if the name of the rule is "nonzero"
but if you don't want to change it (and you're right, it is easy to use
'regex' instead) then just make sure it's clear in the documentation what
the "nonzero" rule does.
David