This is a good point but the fact is that
db.table.field.requires=[IS_IN_SET(['a','b','c'])]
is different from
db.table.field.requires=IS_IN_SET(['a','b','c'])
Both validate the input in the same way but the latter also make a
select/option dropbox.
Moreover doing
db.table.field.requires.append(....)
assumes that you can append any validator you want and you do not care
about previous validators. This is not the case since validators are
also filters. For example IS_INT_IN_RANGE() converts the input string
to an integer, thus it cannot be piped with validators that expect a
string.
Massimo
On Jan 2, 9:12 am, rctay <[email protected]> wrote:
> Hi,
>
> (this is somewhat related to my
> posthttp://groups.google.com/group/web2py/browse_thread/thread/fa10eaed05...)
>
> i noticed that there is a somewhat inconsistent usage of the
> 'requires' attribute as a list sometimes and a scalar at others.
>
> for example, in the SQLFORM __init__ treats the field 'requires' as a
> scalar, while the validation method in INPUT makes sure it is a list.
>
> i hope that the 'requires' field is a list by default (at construction
> time).
>
> this would not only help in type safety, it would also be convenient
> for the user, who can just do
>
> field.requires.append(IS_NOT_EMPTY())
>
> and he wouldn't overwrite the automatically-generated validator
> (although he could do something like
>
> field.requires = [IS_NOT_EMPTY(), field.requires]
> )
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" 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
-~----------~----~----~----~------~----~------~--~---