Deepwalker / trafaret

Ultimate transformation library that supports validation, contexts and aiohttp.
http://trafaret.readthedocs.org/en/latest/
BSD 2-Clause "Simplified" License
177 stars 31 forks source link

Valid emails do not fit trafaret.Email #33

Open lshostenko opened 6 years ago

lshostenko commented 6 years ago
trafaret.Email('contaсt@kmgaszbut.104.ua')

~/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
asvetlov commented 6 years ago

@deepwalker have you a time to take a look?

Deepwalker commented 6 years ago

"context" has a cyrillic C. Check this PR https://github.com/Deepwalker/trafaret/pull/36

Deepwalker commented 6 years ago

BTW maybe it will be good thing to depend on https://github.com/JoshData/python-email-validator

Deepwalker commented 6 years ago

@LShostenko your opinion?

lshostenko commented 6 years ago

Hi @Deepwalker. It seems email-validator is the a good solution, but still it doesn't fit to all examples from Wikipedia:

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('luka.shostenko@gmail.com')