On Oct 20, 2009, at 6:33 AM, mdipierro wrote:
>
> In trunk now. Please try it.
I notice that the int & float versions use conflicting interpretations
of "between":
if value == fvalue and self.minimum <= value <
self.maximum:
if self.minimum <= value <= self.maximum:
...but the error messages don't reflect the difference. My sense is
that the usual meaning of "a number between 1 and 5" is the inclusive
range (1 <= value <= 5) and not the internal Python range meaning. We
could correct the message without affecting backwards compatibility by
reporting (max-1) in the error message.
Also, since the INT version enforces being an integer, I suggest
changing this:
"input a number between %(min)s and %(max)s"
to this:
"input a whole number between %(min)s and %(max)s"
I'm conjecturing that "a whole number" is easier to understand than
"an integer", but I'm not sure. The problem I'm trying to address is
something like this: suppose the range specified is 1..10, and the
user enters 5.5. The user will get an error message:
"input a number between 1 and 10"
which is a little confusing, because the user just did that.
>
> On Oct 20, 8:19 am, mdipierro <[email protected]> wrote:
>> Yes, I can add this.
>>
>> On Oct 20, 12:38 am, Iceberg <[email protected]> wrote:
>>
>>>> On Oct 19, 11:00 pm, Richard <[email protected]> wrote:
>>
>>>>> hello,
>>
>>>>> I find the validator error "too small or too large" too general.
>>>>> Ideally they should return "not a number" if the int/float cast
>>>>> fails,
>>>>> or "too big" / "too small" when out of range.
>>
>>>>> Would this work with the current API, or does each validator
>>>>> need to
>>>>> have a single error message?
>>
>>>>> Richard
>>
>>> On Oct20, 12:53pm, mdipierro <[email protected]> wrote:
>>
>>>> True but than one would need to pass two error messages. You can
>>>> pipe
>>>> two validators
>>
>>>> [IS_MATCH('\-?\d+',error_message='not a number'),IS_INT_IN_RANGE
>>>> (0,100)]
>>
>>> So, to avoid the complexity of piping two validators, I still think
>>> only one error messasge "Please input a number between %(min)s and %
>>> (max)s" really fits all, from logical point of view. Yet from i18n
>>> point of view, I hope the error_message is easier customizable.
>>> Please
>>> refer to my old post here.http://groups.google.com/group/web2py/
>>> msg/a760d3cfe03196c1
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---