Hi all, I needed IS_NOT_IN_SET validator and added it in my custom "validators.py", do you think it is useful?
class IS_NOT_IN_SET(IS_IN_SET): """ example:: INPUT(_type='text', _name='name', requires=IS_NOT_IN_SET(['max', 'john'],zero='')) the argument of IS_NOT_IN_SET must be a list or set >>> IS_NOT_IN_SET(['max', 'john'])('max') ('max', 'value not allowed') >>> IS_NOT_IN_SET(['max', 'john'])('na') ('na', None) >>> IS_NOT_IN_SET(('id1','id2'), ['first label','second label'])('id100') ('id100', None) >>> IS_NOT_IN_SET(('id1','id2'), ['first label','second label'])('id1') ('id1', 'value not allowed') >>> IS_NOT_IN_SET(('id1','id2'), ['first label','second label'])('id2') ('id2', 'value not allowed') >>> IS_NOT_IN_SET({'id1':'first label', 'id2':'second label'}) ('id100') ('id100', None) >>> IS_NOT_IN_SET({'id1':'first label', 'id2':'second label'}) ('id1') ('id1', 'value not allowed') >>> IS_NOT_IN_SET({'id1':'first label', 'id2':'second label'}) ('id2') ('id2', 'value not allowed') >>> import itertools >>> IS_NOT_IN_SET(itertools.chain(['1','3','5'],['2','4','6'])) ('100') ('100', None) >>> IS_NOT_IN_SET(itertools.chain(['1','3','5'],['2','4','6'])) ('1') ('1', 'value not allowed') >>> IS_NOT_IN_SET(itertools.chain(['1','3','5'],['2','4','6'])) ('6') ('6', 'value not allowed') >>> IS_NOT_IN_SET(itertools.chain(['1','3','5'],['2','4','6'])) ('7') ('7', None) """ def __init__(self, *a, **b): IS_IN_SET.__init__(self, *a, **b) def __call__(self, value): value, error = IS_IN_SET.__call__(self, value) if error == None: return (value, self.error_message) else: return (value, None)