Skip to content

Commit f2ef2d0

Browse files
committed
feat: add bulk email validation REST endpoint with comprehensive testing
1 parent dc24068 commit f2ef2d0

8 files changed

Lines changed: 517 additions & 5 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "email-sanitizer"
3-
version = "0.8.0+sprint4"
3+
version = "0.9.0+sprint4"
44
edition = "2024"
55

66
[dependencies]
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
POST http://localhost:8080/api/v1/validate-emails-bulk
2+
Content-Type: application/json
3+
4+
{
5+
"emails": []
6+
}
7+
8+
// Expected Response:
9+
// HTTP/1.1 200 OK
10+
// content-type: application/json
11+
//
12+
// {
13+
// "results": [],
14+
// "valid_count": 0,
15+
// "invalid_count": 0
16+
// }
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
POST http://localhost:8080/api/v1/validate-emails-bulk
2+
Content-Type: application/json
3+
4+
{
5+
"emails": [
6+
7+
"invalid-email",
8+
9+
10+
]
11+
}
12+
13+
// Expected Response:
14+
// HTTP/1.1 200 OK
15+
// content-type: application/json
16+
//
17+
// {
18+
// "results": [
19+
// {
20+
// "email": "[email protected]",
21+
// "validation": {
22+
// "is_valid": true,
23+
// "status": "VALID",
24+
// "error": null
25+
// }
26+
// },
27+
// {
28+
// "email": "invalid-email",
29+
// "validation": {
30+
// "is_valid": false,
31+
// "status": null,
32+
// "error": {
33+
// "code": "INVALID_SYNTAX",
34+
// "message": "Email address has invalid syntax"
35+
// }
36+
// }
37+
// },
38+
// {
39+
// "email": "[email protected]",
40+
// "validation": {
41+
// "is_valid": false,
42+
// "status": null,
43+
// "error": {
44+
// "code": "INVALID_DOMAIN",
45+
// "message": "Email domain has no valid DNS records"
46+
// }
47+
// }
48+
// },
49+
// {
50+
// "email": "[email protected]",
51+
// "validation": {
52+
// "is_valid": false,
53+
// "status": null,
54+
// "error": {
55+
// "code": "DISPOSABLE_EMAIL",
56+
// "message": "The email address domain is a provider of disposable email addresses"
57+
// }
58+
// }
59+
// }
60+
// ],
61+
// "valid_count": 1,
62+
// "invalid_count": 3
63+
// }
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
POST http://localhost:8080/api/v1/validate-emails-bulk?check_role_based=true
2+
Content-Type: application/json
3+
4+
{
5+
"emails": [
6+
7+
8+
9+
]
10+
}
11+
12+
// Expected Response:
13+
// HTTP/1.1 200 OK
14+
// content-type: application/json
15+
//
16+
// {
17+
// "results": [
18+
// {
19+
// "email": "[email protected]",
20+
// "validation": {
21+
// "is_valid": true,
22+
// "status": "VALID",
23+
// "error": null
24+
// }
25+
// },
26+
// {
27+
// "email": "[email protected]",
28+
// "validation": {
29+
// "is_valid": false,
30+
// "status": null,
31+
// "error": {
32+
// "code": "ROLE_BASED_EMAIL",
33+
// "message": "Email address uses a role-based local part"
34+
// }
35+
// }
36+
// },
37+
// {
38+
// "email": "[email protected]",
39+
// "validation": {
40+
// "is_valid": false,
41+
// "status": null,
42+
// "error": {
43+
// "code": "ROLE_BASED_EMAIL",
44+
// "message": "Email address uses a role-based local part"
45+
// }
46+
// }
47+
// }
48+
// ],
49+
// "valid_count": 1,
50+
// "invalid_count": 2
51+
// }
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
POST http://localhost:8080/api/v1/validate-emails-bulk
2+
Content-Type: application/json
3+
4+
{
5+
"emails": [
6+
7+
8+
9+
]
10+
}
11+
12+
// Expected Response:
13+
// HTTP/1.1 200 OK
14+
// content-type: application/json
15+
//
16+
// {
17+
// "results": [
18+
// {
19+
// "email": "[email protected]",
20+
// "validation": {
21+
// "is_valid": true,
22+
// "status": "VALID",
23+
// "error": null
24+
// }
25+
// },
26+
// {
27+
// "email": "[email protected]",
28+
// "validation": {
29+
// "is_valid": true,
30+
// "status": "VALID",
31+
// "error": null
32+
// }
33+
// },
34+
// {
35+
// "email": "[email protected]",
36+
// "validation": {
37+
// "is_valid": true,
38+
// "status": "VALID",
39+
// "error": null
40+
// }
41+
// }
42+
// ],
43+
// "valid_count": 3,
44+
// "invalid_count": 0
45+
// }

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ MIT License.
171171
- **DoD**: Blocklists loaded at startup, role detection accuracy >95%. ✅
172172
173173
8. **Bulk Processing**
174-
- Add async bulk validation endpoint (`POST /bulk/validate`).
174+
- Add async bulk validation endpoint (`POST /bulk/validate`).
175175
- Implement job queue (Redis or MongoDB).
176176
- **DoD**: Processes 10K emails in <5 mins, returns job status.
177177

0 commit comments

Comments
 (0)