I'd like to check a field if it is a valid e-mail address.
It can be also empty.

The first trial was:
class ISzemely(Interface):
...
    email = TextLine(
        title=u"Email cim",
        description=u"Email cim",
        
constraint=re.compile("(^[\w\W]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,3}$)|(^$)").match
        )
...

The second was:
EMAIL_REGEX = 
re.compile("(^[\w\W]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,3}$)|(^$)")

def emailcheck(value):
    if value is None:
        return True
    return EMAIL_REGEX.match(value)

class ISzemely(Interface):
...
    email = TextLine(
        title=u"Email cim",
        description=u"Email cim",
        constraint=emailcheck
        )
...

If I do not fill in a value in the browser "Required input is
missing." message comes.
At the second version the execution even does not reach "emailcheck".

How to solve that?

-- 
Best regards,
 Adam                          mailto:[EMAIL PROTECTED]


_______________________________________________
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users

Reply via email to