Documentation ¶
Overview ¶
Package validator validates and normalizes email addresses and domain names.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidDomain = errors.New("invalid domain")
var ErrInvalidEmail = errors.New("invalid email address")
Functions ¶
func IsValidDomain ¶
IsValidDomain returns true if the domain is valid.
It uses a simple regular expression to check the domain validity.
func IsValidEmail ¶
IsValidEmail returns true if the given string is a valid email address.
It uses a simple regular expression to check the address validity.
func NormalizeDomain ¶
NormalizeDomain returns a normalized domain. It returns an empty string if the domain is not valid.
func NormalizeEmail ¶
NormalizeEmail returns a normalized email address. It returns an empty string if the email is not valid.
func ValidateDomainByResolvingIt ¶
ValidateDomainByResolvingIt queries DNS for the given domain name, and returns nil if the the name resolves, or an error.
func ValidateEmailByResolvingDomain ¶
ValidateEmailByResolvingDomain validates email address by looking up MX records on its domain.
This function can return various DNS errors, which may be temporary (e.g. caused by internet connection being offline) or permanent, e.g. the host doesn't exist or has no MX records.
The function returns nil if email is valid and its domain can accept email messages (however this doesn't guarantee that a user with such email address exists on the host).
Types ¶
This section is empty.