many thanks @snide ; it works well for me; thanks a lot

On Tuesday, March 9, 2021 at 11:58:10 PM UTC+5:30 snide...@gmail.com wrote:

> On Monday, March 8, 2021 at 8:53:08 PM UTC-8 karthikio...@gmail.com wrote:
>
>> Hai , I have a doubt in web2py model - conditional and validator.
>>
>> I am making a mobile contact management for customers .
>>
>> I am using
>>
>> * db.cusReg.cus_phone_number_1.requires = IS_NOT_IN_DB(db, 
>> 'cusReg.cus_phone_number_1')*
>>
>> *db.cusReg.email_id.requires = IS_NOT_IN_DB(db, 'cusReg.email_id')*
>>
>> to  avoid duplication of phone number and email address
>>
>>
>> it works well for 1 user ( consider its USER A )
>>
>>
>> when a new user ( consider its USER B )
>>  likes to add their customer its violating to add them because it is 
>> already added by USER A
>>
>> so how to make conditional in db.py that makes user 1 and user 2 can add 
>> same customer but they can’t repeatedly add it within them ?
>>
>
>
> I think the answer is in Chapter 7,  where 
> <URL:
> http://web2py.com/books/default/chapter/29/07/forms-and-validators#Database-validators
> >
> is the link to the paragraphs on IS_IN_DB  and IS_NOT_IN_DB.  They each 
> have an example that you can use.  The first example shows how to exclude 
> duplicates during a 10 day period using IS_NOT_IN_DB, the second  shows how 
> to use the _and keywrod with IS_IN_DB.  Both validators can use sets (query 
> results) rather than the whole table, and the examples are built on that.
>
> You can also use an onvalidation function
> <URL:
> http://web2py.com/books/default/chapter/29/07/forms-and-validators#onvalidation
> >.
> or a custom validator
> <URL:
> http://web2py.com/books/default/chapter/29/07/forms-and-validators#Custom-validators
> >
>
> I would keep reading after the last link for the topics Multiple 
> Validators and Validators with dependencies
> but I would think the easiest approach is the _and keyword, since you're 
> going to want to verify that userB is in the DB. 
>
> /dps
>  
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/35fb31b0-9313-4d97-a43c-b293ff1d5307n%40googlegroups.com.

Reply via email to