Closed sigmavirus24 closed 8 years ago
Adapting from web2py's validator module (which adapted from I Knew How To Validate An Email Address Until I Read The RFC), the following expression works:
regex_email = re.compile('''^((?!\.)(?:[-a-z0-9!\#$%&'*+/=?^_`{|}~]|(?<!\.)\.)+(?<!\.)@(?:localhost|(?:[a-z0-9](?:[-\w]*[a-z0-9])?\.)+[a-z]{2,}))$''', re.IGNORECASE)
Although, it is not clear whether it is a good idea to support all email addresses allowed in RFC 822.
Helios uses a separate package to manage it: https://github.com/benadida/helios-server/blob/master/requirements.txt#L25 Instead of trying to maintain this ourselves, I would suggest that if we want to validate email addresses, we should use a package that is maintained and used by peers.
I agree. BTW. web2py has a very good one and we have been maintaining it for here. Now sure why we are not use that since we are using the framework. I will fix it.
:+1: thanks @mdipierro
See https://github.com/mdipierro/evote/blob/8b48a6d449bbc1f10f34e94aafee660bf9197435/modules/ballot.py#L13 for more details