Skip to content

Commit 3ae8807

Browse files
authored
Merge pull request #417 from devsetgo/dev
adding missing requirement
2 parents 7ab08e3 + 250448a commit 3ae8807

File tree

7 files changed

+106
-4
lines changed

7 files changed

+106
-4
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.12.3
2+
current_version = 0.12.4
33
commit = False
44
tag = False
55
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(-(?P<release>[a-z]+)(?P<num>\d+))?

coverage.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" ?>
2-
<coverage version="7.5.1" timestamp="1715882846152" lines-valid="674" lines-covered="674" line-rate="1" branches-covered="0" branches-valid="0" branch-rate="0" complexity="0">
2+
<coverage version="7.5.1" timestamp="1715884369689" lines-valid="674" lines-covered="674" line-rate="1" branches-covered="0" branches-valid="0" branch-rate="0" complexity="0">
33
<!-- Generated by coverage.py: https://coverage.readthedocs.io/en/7.5.1 -->
44
<!-- Based on https://raw.githubusercontent.com/cobertura/web/master/htdocs/xml/coverage-04.dtd -->
55
<sources>

docs/recipes/emailValidation.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Validating Email Addresses
2+
Example of how to use in a script
3+
4+
```python
5+
6+
from dsg_lib.common_functions.email_validation import validate_email_address
7+
8+
import pprint
9+
import time
10+
11+
12+
if __name__ == "__main__":
13+
14+
# create a list of email addresses to check if valid
15+
email_addresses = [
16+
"bob@devsetgo.com",
17+
"bob@devset.go",
18+
"foo@yahoo.com",
19+
"bob@gmail.com",
20+
"very fake@devsetgo.com",
21+
"jane.doe@example.com",
22+
"john_doe@example.co.uk",
23+
"user.name+tag+sorting@example.com",
24+
"x@example.com", # shortest possible email address
25+
"example-indeed@strange-example.com",
26+
"admin@mailserver1", # local domain name with no TLD
27+
"example@s.example", # see the list of Internet top-level domains
28+
'" "@example.org', # space between the quotes
29+
'"john..doe"@example.org', # quoted double dot
30+
"mailhost!username@example.org", # bangified host route used for uucp mailers
31+
"user%example.com@example.org", # percent sign in local part
32+
"user-@example.org", # valid due to the last character being an allowed character
33+
# Invalid email addresses
34+
"Abc.example.com", # no @ character
35+
"A@b@c@example.com", # only one @ is allowed outside quotation marks
36+
'a"b(c)d,e:f;g<h>i[j\\k]l@example.com', # none of the special characters in this local part are allowed outside quotation marks
37+
'just"not"right@example.com', # quoted strings must be dot separated or the only element making up the local-part
38+
'this is"not\\allowed@example.com', # spaces, quotes, and backslashes may only exist when within quoted strings and preceded by a backslash
39+
'this\\ still\\"not\\\\allowed@example.com', # even if escaped (preceded by a backslash), spaces, quotes, and backslashes must still be contained by quotes
40+
"1234567890123456789012345678901234567890123456789012345678901234+x@example.com", # local part is longer than 64 characters
41+
42+
# Emails with empty local part
43+
"@example.com", # only valid if allow_empty_local is True
44+
45+
# Emails with non-ASCII characters
46+
"üñîçøðé@example.com", # only valid if allow_smtputf8 is True
47+
"user@üñîçøðé.com", # only valid if allow_smtputf8 is True
48+
49+
# Emails with quoted local part
50+
'"john.doe"@example.com', # only valid if allow_quoted_local is True
51+
'"john..doe"@example.com', # only valid if allow_quoted_local is True
52+
53+
# Emails with display name
54+
'John Doe <john@example.com>', # only valid if allow_display_name is True
55+
56+
# Emails with domain literal
57+
'user@[192.0.2.1]', # only valid if allow_domain_literal is True
58+
59+
# Emails with long local part
60+
"a"*65 + "@example.com", # local part is longer than 64 characters
61+
62+
# Emails with invalid characters
63+
"john doe@example.com", # space is not allowed
64+
"john@doe@example.com", # only one @ is allowed
65+
"john.doe@.com", # domain can't start with a dot
66+
"john.doe@example..com", # domain can't have two consecutive dots
67+
"test@google.com",
68+
]
69+
70+
# create a list of configurations
71+
configurations = [
72+
{"check_deliverability": True, "test_environment": False, "allow_smtputf8": False, "allow_empty_local": False, "allow_quoted_local": False, "allow_display_name": False, "allow_domain_literal": False, "globally_deliverable": None, "timeout": 10, "dns_type": 'timeout'},
73+
{"check_deliverability": False, "test_environment": True, "allow_smtputf8": True, "allow_empty_local": True, "allow_quoted_local": True, "allow_display_name": True, "allow_domain_literal": True, "globally_deliverable": None, "timeout": 5, "dns_type": 'dns'},
74+
{"check_deliverability": True},
75+
{"check_deliverability": False, "test_environment": False, "allow_smtputf8": True, "allow_empty_local": False, "allow_quoted_local": True, "allow_display_name": False, "allow_domain_literal": True, "globally_deliverable": None, "timeout": 15, "dns_type": 'timeout'},
76+
{"check_deliverability": True, "test_environment": True, "allow_smtputf8": False, "allow_empty_local": True, "allow_quoted_local": False, "allow_display_name": True, "allow_domain_literal": False, "globally_deliverable": None, "timeout": 20, "dns_type": 'dns'},
77+
{"check_deliverability": False, "test_environment": False, "allow_smtputf8": True, "allow_empty_local": True, "allow_quoted_local": True, "allow_display_name": True, "allow_domain_literal": True, "globally_deliverable": None, "timeout": 25, "dns_type": 'timeout'},
78+
{"check_deliverability": True, "test_environment": True, "allow_smtputf8": False, "allow_empty_local": False, "allow_quoted_local": False, "allow_display_name": False, "allow_domain_literal": False, "globally_deliverable": None, "timeout": 30, "dns_type": 'dns'},
79+
{"check_deliverability": False, "test_environment": True, "allow_smtputf8": True, "allow_empty_local": False, "allow_quoted_local": True, "allow_display_name": True, "allow_domain_literal": False, "globally_deliverable": None, "timeout": 35, "dns_type": 'timeout'},
80+
{"check_deliverability": True, "test_environment": False, "allow_smtputf8": False, "allow_empty_local": True, "allow_quoted_local": True, "allow_display_name": False, "allow_domain_literal": True, "globally_deliverable": None, "timeout": 40, "dns_type": 'dns'},
81+
{"check_deliverability": False, "test_environment": True, "allow_smtputf8": True, "allow_empty_local": False, "allow_quoted_local": False, "allow_display_name": True, "allow_domain_literal": True, "globally_deliverable": None, "timeout": 45, "dns_type": 'timeout'},
82+
]
83+
84+
t0 = time.time()
85+
validity=[]
86+
87+
for email in email_addresses:
88+
for config in configurations:
89+
90+
res = validate_email_address(email, **config)
91+
validity.append(res)
92+
t1 = time.time()
93+
validity = sorted(validity, key=lambda x: x['email'])
94+
95+
for v in validity:
96+
pprint.pprint(v, indent=4)
97+
98+
print(f"Time taken: {t1 - t0:.2f}")
99+
```

dsg_lib/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# -*- coding: utf-8 -*-
22

3-
__version__ = '0.12.3'
3+
__version__ = '0.12.4'

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ nav:
3434
- Async Database: 'recipes/asyncDatabase.md'
3535
- Logging: 'recipes/loggingExample.md'
3636
- Patterns: 'recipes/patterns.md'
37+
- EmailValidation: 'recipes/emailValidation.md'
3738
- About:
3839
- Contributing: 'contribute.md'
3940
- Release Notes: release-notes.md

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ build-backend = "hatchling.build"
88

99
[project]
1010
name = "devsetgo_lib"
11-
version = "0.12.3"
11+
version = "0.12.4"
1212
requires-python = ">=3.9"
1313
description = "DevSetGo Common Library provides reusable Python functions for enhanced code efficiency. It includes utilities for file operations, calendar, pattern matching, logging, FastAPI endpoints, and async database handling with CRUD operations."
1414
readme = "README.md"
@@ -34,6 +34,7 @@ classifiers = [
3434
dependencies = [
3535
"loguru>=0.7.0",
3636
"packaging>=20.0",
37+
"email-validator>=2.1.1"
3738
]
3839
# loguru = ">=0.7.0"
3940
# packaging = ">=20.0"

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ loguru==0.7.2 # Vulnerabilities: None
1515
mkdocs-material==9.5.23 # From 9.5.18 | Vulnerabilities: None
1616
mkdocs-print-site-plugin==2.4.1 # From 2.4.0 | Vulnerabilities: None
1717
mkdocstrings[python,shell]==0.25.1 # From 0.24.3 | Vulnerabilities: None
18+
1819
packaging==24.0 # Vulnerabilities: None
1920
pre-commit==3.7.1 # From 3.7.0 | Vulnerabilities: None
2021
psycopg2==2.9.9 # Vulnerabilities: None

0 commit comments

Comments
 (0)