Last active
October 31, 2020 16:22
-
-
Save goujonbe/be9dabaf46239028fa9bd5f47c1e445e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class InvalidEmailAddressError(Exception): | |
pass | |
def validate_email_address(ctx, param, value): | |
regex = "^[a-z0-9]+[\._]?[a-z0-9]+[@]\w+[.]\w{2,3}$" | |
if not re.search(regex, value): | |
raise InvalidEmailAddressError(f"Invalid email address: {value}") | |
return value | |
@click.command() | |
@click.option("--email", callback=validate_email_address) | |
def main(email): | |
print(f"login: {email}") | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment