Why does Email(not_empty=True) accept empty values?

Gustavo Narea <me-essWiSEiJ2uHaexy/[email protected]> Mon, 11 Aug 2008 21:03:25 +0200
Newsgroups gmane.comp.python.formencode
Message-ID <[email protected]>
Hello, everyone.

I don't understand why I get this:
> >>> validator = EmailValidator()
> >>> print validator.to_python('')
> None

being EmailValidator defined as:
====-start-=====
class EmailValidator(FancyValidator):
    
    def __init__(self, not_empty=True, resolve_domain=False, max=255,
                 **kwargs):
        super(EmailValidator, self).__init__(**kwargs)
        self.length_validator = MaxLength(max)
        self.email_validator = Email(not_empty=not_empty, strip=True,
                                     resolve_domain=resolve_domain)
    
    def validate_python(self, value, state):
        try:
            self.length_validator.to_python(value, state)
            return self.email_validator.to_python(value, state)
        except Invalid, msg:
            raise InvalidEmailError(msg, value, state)
=====-end-=====

Shouldn't validate_python() raise an exception if it receives an empty string?

Thanks in advance.
-- 
Gustavo Narea.
http://gustavonarea.net/

Get rid of unethical constraints! Switch to Freedomware:
http://softwareliberty.com/

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/