hi my secound stupid beginner question but i cant get behind it. i have a list:ref.. to choose multiple values but i need it to be not empty. the problem when i use the IS_NOT_EMPTY validator is that the field is not empty but "||" for an empty list i think (thats what i have in database in this case)
so i started to write my own Validator and check against that. this isnt my first validator , but this time i doesn't work as i exspect. every time i submit the form only "INIT IS_NOT_EMPTY_LIST" is printet out .. but no "CALL IS_NOT_EMPTY_LIST" .. as in my other validators. if there is an other way around checking empty lists this would be also fine .. here's the code class IS_NOT_EMPTY_LIST(object): def __init__(self, unused, error_message='failed ..'): self.unused = unused self.error_message = error_message print "INIT IS_NOT_EMPTY_LIST" def __call__(self, value): print "CALL IS_NOT_EMPTY_LIST" try: if value == "||" and value == "": return (value, self.error_message) else: return (value, None) except: return (value, self.error_message) db.define_table('element', Field('name')) db.define_table('data', Field('name', 'string'), Field('elements','list:reference element' )) db.data.elements.requires = IS_IN_DB(db,'element.id',multiple=True, _and=IS_NOT_EMPTY_LIST(None, error_message='foo'))