Documentation
¶
Index ¶
- Constants
- Variables
- func HexColorValidator(color string) error
- func SpecialCharValidator(name string) error
- func ValidateDomains() func(domains []string) error
- func ValidateFilter(filter string, exportType enums.ExportType) error
- func ValidateIPAddress() func(ipAddress string) error
- func ValidatePhoneNumber(phoneNumber string) bool
- func ValidateURL() func(u string) error
- func ValidateURLs() func(urls []string) error
- type AllowedEmailTypes
- type EmailVerificationConfig
- type EmailVerifier
Constants ¶
const ( // ResultDisposable indicates the email is disposable ResultDisposable = "disposable" // ResultFree indicates the email is from a free provider ResultFree = "free" // ResultRole indicates the email is a role-based account, e.g. info@, support@ ResultRole = "role" // ResultSyntax indicates the email has invalid syntax ResultSyntax = "syntax" // ResultUnknown indicates the email verification result is unknown, usually due to an error during verification ResultUnknown = "unknown" // ResultValid indicates the email is valid ResultValid = "valid" )
const InvalidChars = "!@#$%^*()+{}|:\"<>?`=[]\\;'/~"
InvalidChars is a list of characters not allowed to be used as part of a name/title
Variables ¶
var (
ErrEmailNotAllowed = errors.New("email address is not allowed, please use your corporate email address")
)
var ErrInvalidGraphQLFilter = errors.New("invalid graphql filter provided")
Functions ¶
func HexColorValidator ¶ added in v0.34.5
HexColorValidator validates a color field for hex color codes
func SpecialCharValidator ¶ added in v0.6.21
SpecialCharValidator validates a name field for special characters returns an error if the name contains special characters. Only hyphens, underscores, periods, commas, and ampersands are allowed
func ValidateDomains ¶
ValidateDomains validates a list of domains and returns an error if any of them are invalid domains can be up to 255 characters long and follow a known domain regex
func ValidateFilter ¶ added in v0.38.1
func ValidateFilter(filter string, exportType enums.ExportType) error
func ValidateIPAddress ¶ added in v0.49.4
ValidateIPAddress validates an IP address and returns an error if it is invalid It accepts both IPv4 and IPv6 addresses but does not allow loopback or unspecified IPs
func ValidatePhoneNumber ¶
ValidatePhoneNumber validates a phone number using the phone numbers library this is light validation as it just need to be valid in _any_ region to be considered valid
func ValidateURL ¶ added in v0.7.2
ValidateURL validates a url and returns an error if it is invalid urls can be up to 2048 characters long and follow the same domain regex
func ValidateURLs ¶ added in v0.43.0
ValidateURL validates a url and returns an error if it is invalid urls can be up to 2048 characters long and follow the same domain regex
Types ¶
type AllowedEmailTypes ¶ added in v0.36.0
type AllowedEmailTypes struct {
// Disposable indicates whether disposable email addresses are allowed
Disposable bool `json:"disposable" koanf:"disposable" default:"false" description:"allow disposable email addresses"`
// Free indicates whether free email addresses are allowed
Free bool `json:"free" koanf:"free" default:"false" description:"allow free email addresses"`
// Role indicates whether role-based email addresses are allowed
Role bool `json:"role" koanf:"role" default:"false" description:"allow role-based email addresses such as info@, support@"`
}
AllowedEmailTypes defines the allowed email types for verification
type EmailVerificationConfig ¶ added in v0.36.0
type EmailVerificationConfig struct {
// Enabled indicates whether email verification is enabled
Enabled bool `json:"enabled" koanf:"enabled" default:"false" description:"enable email verification"`
// EnableAutoUpdateDisposable indicates whether to automatically update disposable email addresses
EnableAutoUpdateDisposable bool `` /* 145-byte string literal not displayed */
// EnableGravatarCheck indicates whether to check for Gravatar existence
EnableGravatarCheck bool `json:"enablegravatarcheck" koanf:"enablegravatarcheck" default:"true" description:"check for Gravatar existence"`
// EnableSMTPCheck indicates whether to check email by smtp
EnableSMTPCheck bool `json:"enablesmtpcheck" koanf:"enablesmtpcheck" default:"false" description:"check email by smtp"`
// AllowedEmailTypes defines the allowed email types for verification
AllowedEmailTypes AllowedEmailTypes `json:"allowedemailtypes" koanf:"allowedemailtypes"`
}
EmailVerificationConfig is the configuration for email verification
func (*EmailVerificationConfig) NewVerifier ¶ added in v0.36.0
func (c *EmailVerificationConfig) NewVerifier() *EmailVerifier
type EmailVerifier ¶ added in v0.36.0
type EmailVerifier struct {
// Client is the email verifier client
Client *emailverifier.Verifier
// AllowedEmailTypes defines the allowed email types for verification
AllowedEmailTypes AllowedEmailTypes
}
EmailVerifier is a wrapper around the emailverifier.Verifier with additional configuration
func (*EmailVerifier) IncludesFreeDomain ¶ added in v0.36.4
func (c *EmailVerifier) IncludesFreeDomain(domains []string) bool
IsFreeDomain checks if the domain of the given email is a free email domain If there is no client configured, it returns false
func (*EmailVerifier) VerifyEmailAddress ¶ added in v0.36.0
func (c *EmailVerifier) VerifyEmailAddress(email string) (bool, *emailverifier.Result, error)
VerifyEmailAddress verifies the given email address based on the configuration and returns whether it is verified, the verification result, and any error encountered