Non-empty list validator in schema

Graham Stratton <gns24-ChQETwBkFSdCgCasaBwmdgC/[email protected]>
Newsgroups gmane.comp.python.formencode
Message-ID <[email protected]>
Hi,

I want to validate a non-empty list of integers as part of a
schema.  The validation works provided that a key exists in the data for
the list, but if it doesn't exist the validator return an empty list:


>>> class S(Schema):
>>>
...   a = formencode.ForEach(formencode.validators.Int(),  
not_empty=True)
...


>>> S.to_python({'a':None})
>>>
formencode.api.Invalid: a: Please enter a value


>>> S.to_python({})
>>>
{'a': []}

I've tried setting other parameters, but I can't work out what to do  
about
this.  Any help would be greatly appreciated.

Thanks,

Graham

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.