Package web2py :: Package gluon :: Module validators :: Class IS_IN_SET
[hide private]
[frames] | no frames]

Class IS_IN_SET

source code

object --+    
         |    
 Validator --+
             |
            IS_IN_SET
Known Subclasses:
IS_IN_SUBSET

example:
   INPUT(_type='text', _name='name',
         requires=IS_IN_SET(['max', 'john'],zero=''))
the argument of IS_IN_SET must be a list or set
>>> IS_IN_SET(['max', 'john'])('max')
('max', None)
>>> IS_IN_SET(['max', 'john'])('massimo')
('massimo', 'value not allowed')
>>> IS_IN_SET(['max', 'john'], multiple=True)(('max', 'john'))
(('max', 'john'), None)
>>> IS_IN_SET(['max', 'john'], multiple=True)(('bill', 'john'))
(('bill', 'john'), 'value not allowed')
>>> IS_IN_SET(('id1','id2'), ['first label','second label'])('id1') # Traditional way
('id1', None)
>>> IS_IN_SET({'id1':'first label', 'id2':'second label'})('id1')
('id1', None)
>>> import itertools
>>> IS_IN_SET(itertools.chain(['1','3','5'],['2','4','6']))('1')
('1', None)
>>> IS_IN_SET([('id1','first label'), ('id2','second label')])('id1') # Redundant way
('id1', None)


Instance Methods [hide private]
 
__init__(self, theset, labels=1, error_message='value not allowed', multiple=True, zero='', sort=True)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
options(self, zero=True) source code
 
__call__(self, value) source code

Inherited from Validator: formatter

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, theset, labels=1, error_message='value not allowed', multiple=True, zero='', sort=True)
(Constructor)

source code 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Overrides: object.__init__
(inherited documentation)