Something like:

FORM(INPUT(_name='phone',
    requires=lambda v: IS_NOT_IN_DB(db, 
'yourtable.phone')(cleanUpNumber(v))))

Anthony


On Saturday, October 8, 2011 8:10:51 AM UTC-4, Ed Greenberg wrote:
>
> I have a table of US phone numbers in ten digit form. When I store 
> them, I take out all non-numeric characters using: 
>
> def cleanUpNumber(number): 
>     return re.sub(r'\D',"",number)[-10:] 
>
> I use a FORM() to get the numbers. Not a SQLFORM or CRUD. 
>
> I would like to use IS_NOT_IN_DATABASE(...) to make sure that I don't 
> get duplicates. 
>
> How can I get the validator to run the values through cleanUpNumber() 
> before looking in the database? 
>
> Ed

Reply via email to