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:

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=None, error_message='Value not allowed', multiple=False, zero='', sort=False)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
options(self, zero=True) source code
 
__call__(self, value) source code

Inherited from Validator: formatter

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

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, theset, labels=None, error_message='Value not allowed', multiple=False, zero='', sort=False)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

__call__(self, value)
(Call operator)

source code 
Overrides: Validator.__call__