mailidator 0.1.0

A lightweight Rust library for checking email address misspellings
Documentation
//! Domain and TLD definitions for email spell checking
//!
//! This module contains lists of popular email domains, second-level domains,
//! and top-level domains used for suggesting corrections.

/// Popular email domains that are commonly used
/// Listed in order of popularity (most popular first)
pub const POPULAR_DOMAINS: &[&str] = &[
    // Top 5 most popular email providers
    "gmail.com",
    "yahoo.com",
    "outlook.com",
    "hotmail.com",
    "icloud.com",
    // Other major providers
    "aol.com",
    "live.com",
    "msn.com",
    "protonmail.com",
    "mail.com",
    // Regional and other providers
    "yandex.com",
    "zoho.com",
    "fastmail.com",
    "tutanota.com",
    "gmx.com",
    // Japanese mobile carriers
    "docomo.ne.jp",
    "ezweb.ne.jp",
    "softbank.ne.jp",
    "au.com",
    "rakuten.jp",
    "i.softbank.jp",
    "vodafone.ne.jp",
    "yahoo.co.jp",
    "yahoo.co.uk",
    "yahoo.fr",
    "yahoo.de",
    "yahoo.es",
    "yahoo.it",
    "yahoo.com.br",
    "yahoo.com.au",
    "yahoo.ca",
    // Business/corporate
    "company.com",
    "business.com",
    "office.com",
    "enterprise.com",
    // Educational
    "edu",
    "ac.uk",
    "edu.au",
    "edu.br",
    // Government
    "gov",
    "gov.uk",
    "gov.au",
    "gov.ca",
    // Common test/example domains
    "example.com",
    "test.com",
    "demo.com",
];

/// Common second-level domains used in email addresses
pub const SECOND_LEVEL_DOMAINS: &[&str] = &[
    "gmail",
    "yahoo",
    "outlook",
    "hotmail",
    "icloud",
    "aol",
    "live",
    "msn",
    "mail",
    "protonmail",
    "yandex",
    "zoho",
    "fastmail",
    "tutanota",
    "gmx",
    // Japanese mobile carriers
    "docomo",
    "ezweb",
    "softbank",
    "rakuten",
    "vodafone",
    "company",
    "business",
    "office",
    "enterprise",
    "example",
    "test",
    "demo",
    "admin",
    "info",
    "support",
    "contact",
    "sales",
    "help",
    "service",
];

/// Common top-level domains and country codes
pub const TOP_LEVEL_DOMAINS: &[&str] = &[
    // Generic TLDs
    "com",
    "org",
    "net",
    "edu",
    "gov",
    "mil",
    "int",
    "info",
    "biz",
    "name",
    "pro",
    "museum",
    // New generic TLDs
    "app",
    "dev",
    "tech",
    "online",
    "site",
    "website",
    "email",
    "work",
    "business",
    "company",
    "enterprise",
    "solutions",
    "services",
    "consulting",
    "agency",
    "studio",
    "design",
    "digital",
    "media",
    "news",
    "blog",
    "store",
    "shop",
    "market",
    "finance",
    "bank",
    "insurance",
    "health",
    "medical",
    "legal",
    "law",
    "travel",
    "hotel",
    "restaurant",
    "food",
    "game",
    "games",
    "sport",
    "sports",
    "music",
    "art",
    "photo",
    "video",
    "film",
    "tv",
    "radio",
    "social",
    "community",
    "club",
    "group",
    "team",
    "family",
    "kids",
    "baby",
    "love",
    "life",
    "world",
    "earth",
    "global",
    "international",
    "local",
    "city",
    "town",
    "country",
    "region",
    // Country code TLDs (popular ones)
    "us", // United States
    "uk", // United Kingdom
    "ca", // Canada
    "au", // Australia
    "de", // Germany
    "fr", // France
    "it", // Italy
    "es", // Spain
    "nl", // Netherlands
    "be", // Belgium
    "ch", // Switzerland
    "at", // Austria
    "se", // Sweden
    "no", // Norway
    "dk", // Denmark
    "fi", // Finland
    "pl", // Poland
    "cz", // Czech Republic
    "hu", // Hungary
    "gr", // Greece
    "pt", // Portugal
    "ie", // Ireland
    "jp", // Japan
    "cn", // China
    "kr", // South Korea
    "in", // India
    "sg", // Singapore
    "hk", // Hong Kong
    "tw", // Taiwan
    "th", // Thailand
    "my", // Malaysia
    "id", // Indonesia
    "ph", // Philippines
    "vn", // Vietnam
    "br", // Brazil
    "mx", // Mexico
    "ar", // Argentina
    "cl", // Chile
    "co", // Colombia
    "pe", // Peru
    "za", // South Africa
    "eg", // Egypt
    "tr", // Turkey
    "il", // Israel
    "ae", // UAE
    "sa", // Saudi Arabia
    "ru", // Russia
    "ua", // Ukraine
    "by", // Belarus
    "kz", // Kazakhstan
    "uz", // Uzbekistan
    // Multi-level country domains
    "co.uk",
    "co.jp",
    "co.kr",
    "co.in",
    "co.za",
    "co.nz",
    "com.au",
    "com.br",
    "com.mx",
    "com.ar",
    "com.co",
    "com.pe",
    "com.tr",
    "com.eg",
    "com.sa",
    "com.ae",
    "com.my",
    "com.sg",
    "com.hk",
    "com.tw",
    "com.th",
    "com.ph",
    "com.vn",
    "com.id",
    "org.uk",
    "net.au",
    "edu.au",
    "gov.au",
    "edu.br",
    "gov.br",
    "ac.uk",
    "ac.jp",
    "ac.kr",
    "ac.in",
    "ac.za",
    "ne.jp",
    "edu.in",
    "gov.in",
    "org.in",
    "net.in",
];

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_no_duplicates_in_popular_domains() {
        let mut unique_domains = std::collections::HashSet::new();
        for domain in POPULAR_DOMAINS {
            assert!(
                unique_domains.insert(domain),
                "Duplicate domain found: {domain}"
            );
        }
    }

    #[test]
    fn test_no_duplicates_in_slds() {
        let mut unique_slds = std::collections::HashSet::new();
        for sld in SECOND_LEVEL_DOMAINS {
            assert!(unique_slds.insert(sld), "Duplicate SLD found: {sld}");
        }
    }

    #[test]
    fn test_no_duplicates_in_tlds() {
        let mut unique_tlds = std::collections::HashSet::new();
        for tld in TOP_LEVEL_DOMAINS {
            assert!(unique_tlds.insert(tld), "Duplicate TLD found: {tld}");
        }
    }
}