-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmailValidation.py
More file actions
44 lines (32 loc) · 1.13 KB
/
EmailValidation.py
File metadata and controls
44 lines (32 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import re
import DataBase as db
class EmailValidation:
def isValidEmail(self, email):
"""
Validate the email format using a regular expression.
Args:
email (str): The email address to validate.
Returns:
bool: True if the email is valid, False otherwise.
"""
# Regular expression pattern for email validation
regex = r'^[\w\.-]+@[\w\.-]+\.\w+$'
# Check if the email matches the regex pattern
return bool(re.match(regex, email))
def isDublicated(self, name):
"""
Check if the email address is already duplicated in the database.
Args:
name (str): The email address to check.
Returns:
bool: True if the email is duplicated, False otherwise.
"""
# Create a new database object
db1 = db.Database()
# Get the ID by email from the database
id_by_email = db1.getIdbyEmail(name)
# Check if the email exists in the database
if id_by_email == '-1':
return False
else:
return True