--- a/src/pyams_utils/schema.py Mon Sep 11 14:59:37 2017 +0200
+++ b/src/pyams_utils/schema.py Tue Sep 19 11:20:41 2017 +0200
@@ -14,6 +14,7 @@
# import standard library
+import re
import string
# import interfaces
@@ -163,3 +164,23 @@
def __init__(self, value_type=None, unique=False, **kw):
super(TextLineListField, self).__init__(value_type=TextLine(), unique=True, **kw)
+
+
+#
+# Mail address field
+#
+
+class IMailAddressField(ITextLine):
+ """Marker interface for mail address field"""
+
+
+EMAIL_REGEX = re.compile("^[^ @]+@[^ @]+\.[^ @]+$")
+
+
+@implementer(IMailAddressField)
+class MailAddressField(TextLine):
+ """Mail address field"""
+
+ def __init__(self, *args, **kwargs):
+ kwargs['constraint'] = EMAIL_REGEX.match
+ super(MailAddressField, self).__init__(*args, **kwargs)