Valid emails do not fit trafaret.Email
trafaret.Email('contaс[email protected]')
~/py/ocean/ocean_ai/env/lib/python3.6/site-packages/trafaret/base.py in __call__(self, val, context)
154
155 def __call__(self, val, context=None):
--> 156 return self.check(val, context=context)
157
158
~/py/ocean/ocean_ai/env/lib/python3.6/site-packages/trafaret/base.py in check(self, value, context)
116 """
117 if hasattr(self, 'transform'):
--> 118 return self.transform(value, context=context)
119 elif hasattr(self, 'check_value'):
120 self.check_value(value)
~/py/ocean/ocean_ai/env/lib/python3.6/site-packages/trafaret/base.py in transform(self, value, context)
304 if isinstance(res, DataError):
305 raise DataError
--> 306 res = self.other(res, context=context)
307 if isinstance(res, DataError):
308 raise res
~/py/ocean/ocean_ai/env/lib/python3.6/site-packages/trafaret/base.py in __call__(self, val, context)
154
155 def __call__(self, val, context=None):
--> 156 return self.check(val, context=context)
157
158
~/py/ocean/ocean_ai/env/lib/python3.6/site-packages/trafaret/base.py in check(self, value, context)
116 """
117 if hasattr(self, 'transform'):
--> 118 return self.transform(value, context=context)
119 elif hasattr(self, 'check_value'):
120 self.check_value(value)
~/py/ocean/ocean_ai/env/lib/python3.6/site-packages/trafaret/base.py in transform(self, value, context)
166 return self.trafaret(value, context=context)
167 except DataError:
--> 168 raise DataError(self.message, value=value)
169
170
DataError: value is not a valid email address
@deepwalker have you a time to take a look?
"context" has a cyrillic C. Check this PR https://github.com/Deepwalker/trafaret/pull/36
BTW maybe it will be good thing to depend on https://github.com/JoshData/python-email-validator
@LShostenko your opinion?
Hi @Deepwalker. It seems email-validator is the a good solution, but still it doesn't fit to all examples from Wikipedia:
- [email protected]
- admin@mailserver1,
- #!$%&'*+-/=?^_`{}|[email protected]
- "()<>[]:,;@\"!#$%&'-/=?^_`{}| ~.a"@example.org
- [email protected]
- user@localserver
- user@[2001:DB8::1]
are treated as invalid. Another disadvantage is that the package requires internet connection to work correctly, it raises EmailUndeliverableError when the connection is turned off even for existing ascii email address validate_email('[email protected]')