iro/validate.py
branchdevel
changeset 181 8a5be61f34c5
parent 178 ee4a6eb5a34b
child 193 e5ec4bfa4929
--- a/iro/validate.py	Thu Feb 23 16:52:06 2012 +0100
+++ b/iro/validate.py	Thu Feb 23 16:53:32 2012 +0100
@@ -3,6 +3,7 @@
 import re
 from decorator import decorator
 from inspect import getcallargs
+import types
 
 from .error import ValidateException, InvalidTel, InvalidMail
 from .telnumber import Telnumber
@@ -76,6 +77,10 @@
     this\\ still\\"not\\allowed@example.com
     '''
     ret = []
+    str_=False
+    if type(value) is types.StringType:
+        str_=True
+        value=[value]
     for v in value:
         parts= re.match(r'^(.*)@(.+?)$',v)
         if not parts:
@@ -118,6 +123,8 @@
             raise InvalidMail(v,field)
         if v not in ret:
             ret.append(v)
+    if str_:
+        ret=ret[0]
     return ret
 
 def validate(kwd,func, need=True,*args,**kargs):