auto-generated validators based on field spec?

6 views
Skip to first unread message

rctay

unread,
Dec 31, 2008, 9:55:54 PM12/31/08
to web2py Web Framework
Hi,

i'm wondering if it's possible to add validation based on the field
spec into web2py.

for example, if a field 'text' has length 25, then the field.requires
list should contain the validator IS_LENGTH(25). this might apply to
conditions like unique, non-empty, as well.

mdipierro

unread,
Jan 1, 2009, 5:24:36 AM1/1/09
to web2py Web Framework
Hi rctay,

some of this is done already. In particular in the example you mention
if a "string" field has length=78, you atomtalically get a IS_LENGTH
(78) validators. Similarly a date field gets a IS_DATE() validators,
etc. This does not apply to 'text' because most databases impose no
length contraints on TEXT.

Anyway, I will look into improving this without breaking backward
compatibility.

Massimo
Reply all
Reply to author
Forward
0 new messages