Use mail address schema field
authorThierry Florac <thierry.florac@onf.fr>
Tue, 19 Sep 2017 11:10:46 +0200
changeset 168 0d80c3c49bab
parent 167 9830acb98590
child 169 483b0f16e9a6
Use mail address schema field
src/pyams_content/component/links/interfaces/__init__.py
--- a/src/pyams_content/component/links/interfaces/__init__.py	Tue Sep 19 11:10:19 2017 +0200
+++ b/src/pyams_content/component/links/interfaces/__init__.py	Tue Sep 19 11:10:46 2017 +0200
@@ -14,7 +14,6 @@
 
 
 # import standard library
-import re
 
 # import interfaces
 from pyams_content.component.association.interfaces import IAssociationTarget, IAssociationItem
@@ -22,6 +21,7 @@
 # import packages
 from pyams_i18n.schema import I18nTextLineField, I18nTextField
 from pyams_sequence.schema import InternalReference, InternalReferencesList
+from pyams_utils.schema import MailAddressField
 from zope.interface import Interface
 from zope.schema import Choice, TextLine
 
@@ -69,16 +69,12 @@
                       required=False)
 
 
-EMAIL_REGEX = re.compile("[^@]+@[^@]+\.[^@]+")
-
-
 class IMailtoLink(IBaseLink):
     """Mailto link interface"""
 
-    address = TextLine(title=_("Target address"),
-                       description=_("Target email address"),
-                       constraint=EMAIL_REGEX.match,
-                       required=True)
+    address = MailAddressField(title=_("Target address"),
+                               description=_("Target email address"),
+                               required=True)
 
     address_name = TextLine(title=_("Address name"),
                             description=_("Address as displayed in address book"),