Commit a574882
committed
feat: Extract and validate email components (username and domain)
🎯 Purpose:
Implements email string parsing to separate and validate username and domain components
of an email address, with specific validation for Gmail domains.
🧠 Logic:
1. Email Parsing:
- Locates '@' symbol using indexOf() to split email components
- Extracts username portion before '@' using substring(0, indexOf('@'))
- Extracts domain portion after '@' using substring(indexOf('@') + 1)
2. Domain Validation:
- Performs Gmail-specific domain validation using two approaches:
a) startsWith("Gmail") to check domain beginning
b) equalsIgnoreCase("gmail") for case-insensitive exact match
- Extracts domain name before '.com' for precise validation
🔍 Technical Details:
- Uses String methods: indexOf(), substring(), startsWith(), equalsIgnoreCase()
- Handles email format: "[email protected]"
- Implements case-insensitive domain validation
- Separates domain validation logic from extraction logic
📋 Example:
Input: "[email protected]"
Output:
- Username: "Programmer"
- Domain: "Gmail.com"
- Gmail Validation: true
💡 Note:
This implementation focuses on basic email component extraction and Gmail domain
validation. For production use, consider adding additional validation rules and
error handling for malformed email addresses.
Signed-off-by: Somesh diwan <[email protected]>1 parent 0f45150 commit a574882
1 file changed
+0
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | 4 | | |
6 | 5 | | |
7 | 6 | | |
| |||
0 commit comments