trafaret icon indicating copy to clipboard operation
trafaret copied to clipboard

Valid emails do not fit trafaret.Email

Open lshostenko opened this issue 7 years ago • 5 comments

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

lshostenko avatar Apr 23 '18 13:04 lshostenko

@deepwalker have you a time to take a look?

asvetlov avatar May 15 '18 12:05 asvetlov

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

Deepwalker avatar May 17 '18 08:05 Deepwalker

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

Deepwalker avatar May 17 '18 08:05 Deepwalker

@LShostenko your opinion?

Deepwalker avatar May 24 '18 09:05 Deepwalker

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('[email protected]')

lshostenko avatar May 25 '18 09:05 lshostenko