_and does not work with multiple. This is not an easy fix because it presents a logical problem: it is not clear if the _and should apply to the list or to each element.
You can do: class IS_NOT_EMPTY_LIST_OF_REFERENCES(IS_IN_DB): def __init__(self, *a, **b): IS_IN_DB.__init__(self,*a,**b) def __call__(self, value): if value == "||" or value == "": return (value, self.error_message) else: return IS_IN_DB.__call__(self,value) db.data.elements.requires = IS_NOT_EMPTY_LIST_OF_REFERENCES(db,'element.id',multiple=True) On Sep 15, 10:36 am, "dustin.b" <dustin.bens...@googlemail.com> wrote: > 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'))