Skip to content

Commit

Permalink
Use email-validator instead of a custom regex
Browse files Browse the repository at this point in the history
  • Loading branch information
TheReverend403 committed Feb 27, 2024
1 parent cc954bd commit fc5cd0b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pste/commands/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
# You should have received a copy of the GNU General Public License
# along with pste. If not, see <https://www.gnu.org/licenses/>.

import re
import shutil

import click
import email_validator
from flask.cli import AppGroup

from pste.extensions import db
Expand All @@ -31,11 +31,12 @@


def validate_email(ctx, param, value):
if not re.match(r"[^@]+@[^@]+\.[^@]+", value):
try:
email_validator.validate_email(value, check_deliverability=False)
except email_validator.EmailNotValidError:
click.secho("Not a valid email address.", fg=ERROR_FG)
value = click.prompt(param.prompt)
return validate_email(ctx, param, value)

return value


Expand Down

0 comments on commit fc5cd0b

Please sign in to comment.