Documentation
¶
Index ¶
- func DefaultFreeProviders() map[string]struct{}
- type Options
- type ValidationResult
- type Validator
- func (v *Validator) LoadDisposableDomains(urlStr string) error
- func (v *Validator) LoadFreeProviders(urlStr string) error
- func (v *Validator) RegisterDisposableDomains(domains []string)
- func (v *Validator) RegisterFreeProviders(providers []string)
- func (v *Validator) Validate(email string) ValidationResult
- func (v *Validator) ValidateMany(emails []string) []ValidationResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultFreeProviders ¶
func DefaultFreeProviders() map[string]struct{}
DefaultFreeProviders returns the default free email providers
Types ¶
type Options ¶
type Options struct {
CheckDNS bool // Whether to perform DNS MX lookup
CheckDisposable bool // Whether to check for disposable domains
CheckFreeProvider bool // Whether to check for free email providers
DNSCacheTTL time.Duration // TTL for DNS cache
DNSCacheSize int // Maximum number of DNS cache entries
DNSTimeout time.Duration // Timeout for DNS lookups
DisposableListURL string // URL for disposable domains list
FreeProvidersURL string // URL for free email providers list
MaxEmailLength int // Maximum email length
MinDomainLength int // Minimum domain length
RejectDisposable bool // Whether to invalidate disposable domains
RejectFreeProvider bool // Whether to invalidate free email providers
RejectIPDomains bool // Whether to reject IP address domains
RejectNamedEmails bool // Whether to reject named email addresses (e.g. "First Last <first.last@example.com>")
RejectReserved bool // Whether to invalidate reserved example domains
}
Options contains configuration options for email validation
func DefaultOptions ¶
func DefaultOptions() Options
DefaultOptions returns the default validator options
type ValidationResult ¶
type ValidationResult struct {
Address string // Normalized email address
IsDisposable bool // Whether the domain is disposable
IsFreeProvider bool // Whether the domain is a free provider
IsIPDomain bool // Whether the domain is an IP address
IsReserved bool // Whether the domain is reserved
IsValid bool // Whether the email is valid
LastError error // Validation error
Name string // Parsed name from email
Original string // Original email address input
ValidationTime time.Duration // Time taken to validate
}
func (ValidationResult) ErrorMessage ¶ added in v0.0.3
func (vr ValidationResult) ErrorMessage() string
ErrorMessage returns the last validation error as a string if present, otherwise an empty string
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
func (*Validator) LoadDisposableDomains ¶
LoadDisposableDomains loads a list of disposable domains from a JSON file or URL
func (*Validator) LoadFreeProviders ¶
LoadFreeProviders loads a list of free email providers from a JSON file or URL
func (*Validator) RegisterDisposableDomains ¶
RegisterDisposableDomains manually adds domains to the disposable domains list
func (*Validator) RegisterFreeProviders ¶
RegisterFreeProviders manually adds domains to the free providers list
func (*Validator) Validate ¶
func (v *Validator) Validate(email string) ValidationResult
Validate checks a single email address
func (*Validator) ValidateMany ¶
func (v *Validator) ValidateMany(emails []string) []ValidationResult
ValidateMany validates multiple email addresses concurrently