Documentation
¶
Index ¶
- Constants
- func DefaultGetMD5Hash(str string) []byte
- func DomainCacheKeyGetter(input Input, _ ...ValidationResult) interface{}
- func EmailCacheKeyGetter(input Input, _ ...ValidationResult) interface{}
- func NewDepsError() error
- type AValidationResult
- func (a *AValidationResult) DecodeMsgpack(dec *msgpack.Decoder) error
- func (a *AValidationResult) EncodeMsgpack(enc *msgpack.Encoder) error
- func (a *AValidationResult) Errors() []error
- func (a *AValidationResult) HasErrors() bool
- func (a *AValidationResult) HasWarnings() bool
- func (a *AValidationResult) IsValid() bool
- func (a *AValidationResult) SetErrors(errors []error)
- func (a *AValidationResult) SetWarnings(warnings []error)
- func (a *AValidationResult) ValidatorName() ValidatorName
- func (a *AValidationResult) Warnings() []error
- type AValidatorWithoutDeps
- type BanWordsUsernameError
- type BlackListDomainsError
- type BlackListEmailsError
- type CacheKeyGetter
- type ChangeableValidationResult
- type DepBuilder
- type DepResult
- type DepValidationResult
- type DepsError
- type DisposableError
- type EmptyMXsError
- type FreeError
- type GetMD5Hash
- type GravatarError
- type GravatarOptions
- type GravatarOptionsDTO
- type GravatarValidationResult
- type Input
- type IsWarning
- type KVOption
- type MXValidationResult
- type RoleError
- type SyntaxError
- type SyntaxValidatorResult
- type ValidationResult
- type Validator
- func DefaultNewMXValidator() Validator
- func FreeDefaultValidator() Validator
- func GetDefaultSMTPValidator(dto evsmtp.CheckerDTO) Validator
- func NewBanWordsUsername(inStrings contains.InStrings) Validator
- func NewBlackListEmailsValidator(d contains.InSet) Validator
- func NewBlackListValidator(d contains.InSet) Validator
- func NewCacheDecorator(validator Validator, cache evcache.Interface, getKey CacheKeyGetter) Validator
- func NewDepValidator(deps ValidatorMap) Validator
- func NewDisposableValidator(d contains.InSet) Validator
- func NewFreeValidator(f contains.InSet) Validator
- func NewGravatarValidator() Validator
- func NewGravatarValidatorWithURL(gravatarURL string) Validator
- func NewMXValidator(lookupMX evsmtp.FuncLookupMX) Validator
- func NewRoleValidator(r contains.InSet) Validator
- func NewSMTPValidator(Checker evsmtp.Checker) Validator
- func NewSyntaxRegexValidator(emailRegex *regexp.Regexp) Validator
- func NewSyntaxValidator() Validator
- func NewWarningsDecorator(validator Validator, isWarning IsWarning) Validator
- func NewWhiteListValidator(d contains.InSet) Validator
- type ValidatorMap
- type ValidatorName
- type WarningSet
- type WhiteListError
Constants ¶
const ( // GravatarValidatorName is name for validation by https://www.gravatar.com/ GravatarValidatorName ValidatorName = "Gravatar" // GravatarURL is url for gravatar validation GravatarURL string = "https://www.gravatar.com/avatar/%x?d=404" // DefaultGravatarTimeout is default timeout for gravatar connection DefaultGravatarTimeout = 5 * time.Second )
const BanWordsUsernameErr = "BanWordsUsernameError"
BanWordsUsernameErr is text for BanWordsUsernameError.Error
const BlackListEmailsErr = "BlackListEmailsError"
BlackListEmailsErr is text for BlackListEmailsError.Error
const DisposableErr = "DisposableError"
DisposableErr is text for DisposableError.Error
const FreeErr = "FreeError"
FreeErr is text for FreeError.Error
const GravatarErr = "GravatarError"
GravatarErr is text for GravatarError.Error
const RoleErr = "RoleError"
RoleErr is text for RoleError.Error
const SyntaxErr = "SyntaxErr"
SyntaxErr is text for SyntaxError.Error
const WhiteListErr = "WhiteListError"
WhiteListErr is text for WhiteListError.Error
Variables ¶
This section is empty.
Functions ¶
func DefaultGetMD5Hash ¶
DefaultGetMD5Hash is a default implementation of GetMD5Hash
func DomainCacheKeyGetter ¶
func DomainCacheKeyGetter(input Input, _ ...ValidationResult) interface{}
DomainCacheKeyGetter generates key as domain
func EmailCacheKeyGetter ¶
func EmailCacheKeyGetter(input Input, _ ...ValidationResult) interface{}
EmailCacheKeyGetter generates key as full email
Types ¶
type AValidationResult ¶
type AValidationResult struct {
// contains filtered or unexported fields
}
AValidationResult is abstract class for extending of validation
func (*AValidationResult) DecodeMsgpack ¶
func (a *AValidationResult) DecodeMsgpack(dec *msgpack.Decoder) error
DecodeMsgpack is used to fix this problem https://github.com/vmihailenco/msgpack/issues/294
func (*AValidationResult) EncodeMsgpack ¶
func (a *AValidationResult) EncodeMsgpack(enc *msgpack.Encoder) error
EncodeMsgpack is used to fix this problem https://github.com/vmihailenco/msgpack/issues/294
func (*AValidationResult) Errors ¶
func (a *AValidationResult) Errors() []error
Errors of result after validation
func (*AValidationResult) HasErrors ¶
func (a *AValidationResult) HasErrors() bool
HasErrors checks for the presence of the Errors
func (*AValidationResult) HasWarnings ¶
func (a *AValidationResult) HasWarnings() bool
HasWarnings checks for the presence of the Warnings
func (*AValidationResult) IsValid ¶
func (a *AValidationResult) IsValid() bool
IsValid is status of validation
func (*AValidationResult) SetErrors ¶
func (a *AValidationResult) SetErrors(errors []error)
SetErrors sets errors
func (*AValidationResult) SetWarnings ¶
func (a *AValidationResult) SetWarnings(warnings []error)
SetWarnings sets warnings
func (*AValidationResult) ValidatorName ¶
func (a *AValidationResult) ValidatorName() ValidatorName
ValidatorName returns name of validator
func (*AValidationResult) Warnings ¶
func (a *AValidationResult) Warnings() []error
Warnings of result after validation
type AValidatorWithoutDeps ¶
type AValidatorWithoutDeps struct{}
AValidatorWithoutDeps is an abstract structure for validator without dependencies
func (AValidatorWithoutDeps) GetDeps ¶
func (a AValidatorWithoutDeps) GetDeps() []ValidatorName
GetDeps returns dependencies of Validator
type BanWordsUsernameError ¶
type BanWordsUsernameError struct{}
BanWordsUsernameError is BanWordsUsernameValidatorName error
func (BanWordsUsernameError) Error ¶
func (BanWordsUsernameError) Error() string
type BlackListDomainsError ¶
type BlackListDomainsError struct{}
BlackListDomainsError is BlackListEmailsValidatorName error
func (BlackListDomainsError) Error ¶
func (BlackListDomainsError) Error() string
type BlackListEmailsError ¶
type BlackListEmailsError struct{}
BlackListEmailsError is BlackListEmailsValidatorName error
func (BlackListEmailsError) Error ¶
func (BlackListEmailsError) Error() string
type CacheKeyGetter ¶
type CacheKeyGetter func(input Input, results ...ValidationResult) interface{}
CacheKeyGetter is type for key generators To use complex keys you can use https://github.com/vmihailenco/msgpack/
type ChangeableValidationResult ¶
ChangeableValidationResult is ValidationResult with changeable errors and warnings
type DepBuilder ¶
type DepBuilder struct {
// contains filtered or unexported fields
}
DepBuilder is used to form Validator
func NewDepBuilder ¶
func NewDepBuilder(validators ValidatorMap) *DepBuilder
NewDepBuilder instantiates Validator with ValidatorMap or GetDefaultFactories validators
func (*DepBuilder) Build ¶
func (d *DepBuilder) Build() Validator
Build builds Validator based on configuration
func (*DepBuilder) Delete ¶
func (d *DepBuilder) Delete(names ...ValidatorName) *DepBuilder
Delete deletes validators by ValidatorName...
func (*DepBuilder) Get ¶
func (d *DepBuilder) Get(name ValidatorName) Validator
Get returns validator by ValidatorName
func (*DepBuilder) Has ¶
func (d *DepBuilder) Has(names ...ValidatorName) bool
Has checks for existing validators by ValidatorName...
func (*DepBuilder) Set ¶
func (d *DepBuilder) Set(name ValidatorName, validator Validator) *DepBuilder
Set sets validator by ValidatorName
type DepResult ¶
type DepResult map[ValidatorName]ValidationResult
DepResult is alias for results of nested validators
type DepValidationResult ¶
type DepValidationResult interface { ValidationResult GetResults() DepResult }
DepValidationResult is representation of DepValidatorName result
type DisposableError ¶
type DisposableError struct{}
DisposableError is DisposableValidatorName error
func (DisposableError) Error ¶
func (DisposableError) Error() string
type EmptyMXsError ¶
type EmptyMXsError struct{}
EmptyMXsError is error of MXValidatorName
func (EmptyMXsError) Error ¶
func (EmptyMXsError) Error() string
type GetMD5Hash ¶
GetMD5Hash is function interface, which returns md5 for string
type GravatarError ¶
type GravatarError struct{}
GravatarError is GravatarValidatorName error
func (GravatarError) Error ¶
func (GravatarError) Error() string
type GravatarOptions ¶
GravatarOptions describes gravatar options
func DefaultGravatarOptions ¶
func DefaultGravatarOptions() GravatarOptions
DefaultGravatarOptions returns options with default values
func NewGravatarOptions ¶
func NewGravatarOptions(dto GravatarOptionsDTO) GravatarOptions
NewGravatarOptions instantiates GravatarOptions
type GravatarOptionsDTO ¶
GravatarOptionsDTO is dto for NewGravatarOptions
type GravatarValidationResult ¶
type GravatarValidationResult interface { URL() string ValidationResult }
GravatarValidationResult is result of GravatarValidatorName
func NewGravatarValidationResult ¶
func NewGravatarValidationResult(url string, result *AValidationResult) GravatarValidationResult
NewGravatarValidationResult instantiates result of GravatarValidationResult
type Input ¶
type Input interface { Email() evmail.Address Option(name ValidatorName) interface{} }
Input consists of input data for Validator.Validate
func NewInputFromMap ¶
func NewInputFromMap(email evmail.Address, options map[ValidatorName]interface{}) Input
NewInputFromMap create Input from evmail.Address and options
type IsWarning ¶
IsWarning is type to detect error as warning
func NewIsWarning ¶
func NewIsWarning(warningMap WarningSet, isWarning func(warningMap WarningSet) IsWarning) IsWarning
NewIsWarning creates function for detection of warnings
type KVOption ¶
type KVOption struct { Name ValidatorName Option interface{} }
KVOption needs to form options in Input
func NewKVOption ¶
func NewKVOption(name ValidatorName, option interface{}) KVOption
NewKVOption instantiates KVOption
type MXValidationResult ¶
type MXValidationResult interface { MX() evsmtp.MXs ValidationResult }
MXValidationResult is result of MXValidatorName
func NewMXValidationResult ¶
func NewMXValidationResult(mx evsmtp.MXs, result *AValidationResult) MXValidationResult
NewMXValidationResult instantiates result of MXValidatorName
type SyntaxError ¶
type SyntaxError struct{}
SyntaxError is error of SyntaxValidatorName
func (SyntaxError) Error ¶
func (SyntaxError) Error() string
type SyntaxValidatorResult ¶
type SyntaxValidatorResult interface { ValidationResult }
SyntaxValidatorResult is interface of SyntaxValidatorName result
type ValidationResult ¶
type ValidationResult interface { // IsValid is status of validation IsValid() bool // Errors of result after validation Errors() []error // HasErrors checks for the presence of the Errors HasErrors() bool // Warnings of result after validation Warnings() []error // HasWarnings checks for the presence of the Warnings HasWarnings() bool // ValidatorName returns name of validator ValidatorName() ValidatorName }
ValidationResult is interface to represent result of validation
func NewDepValidatorResult ¶
func NewDepValidatorResult(isValid bool, results DepResult) ValidationResult
NewDepValidatorResult returns DepValidatorName result
func NewResult ¶
func NewResult(isValid bool, errors []error, warnings []error, name ValidatorName) ValidationResult
NewResult returns result of validation by parameters
func NewValidResult ¶
func NewValidResult(name ValidatorName) ValidationResult
NewValidResult returns valid validation result
type Validator ¶
type Validator interface { GetDeps() []ValidatorName Validate(input Input, results ...ValidationResult) ValidationResult }
Validator is interface for validators
func DefaultNewMXValidator ¶
func DefaultNewMXValidator() Validator
DefaultNewMXValidator instantiates default MXValidatorName based on evsmtp.LookupMX
func FreeDefaultValidator ¶
func FreeDefaultValidator() Validator
FreeDefaultValidator instantiates default FreeValidatorName based on free.NewWillWhiteSetFree()
func GetDefaultSMTPValidator ¶
func GetDefaultSMTPValidator(dto evsmtp.CheckerDTO) Validator
GetDefaultSMTPValidator instantiates default SMTPValidatorName
func NewBanWordsUsername ¶
NewBanWordsUsername instantiates BanWordsUsernameValidatorName validator
func NewBlackListEmailsValidator ¶
NewBlackListEmailsValidator instantiates BlackListEmailsValidatorName validator
func NewBlackListValidator ¶
NewBlackListValidator instantiates BlackListDomainsValidatorName validator
func NewCacheDecorator ¶
func NewCacheDecorator(validator Validator, cache evcache.Interface, getKey CacheKeyGetter) Validator
NewCacheDecorator instantiates cache decorator
func NewDepValidator ¶
func NewDepValidator(deps ValidatorMap) Validator
NewDepValidator instantiates DepValidatorName validator
func NewDisposableValidator ¶
NewDisposableValidator instantiates DisposableValidatorName
func NewFreeValidator ¶
NewFreeValidator instantiates FreeValidatorName
func NewGravatarValidator ¶
func NewGravatarValidator() Validator
NewGravatarValidator instantiates GravatarValidatorName validator with GravatarURL for validation
func NewGravatarValidatorWithURL ¶
NewGravatarValidatorWithURL instantiates GravatarValidatorName validator
func NewMXValidator ¶
func NewMXValidator(lookupMX evsmtp.FuncLookupMX) Validator
NewMXValidator instantiates MXValidatorName based on evsmtp.FuncLookupMX
func NewRoleValidator ¶
NewRoleValidator instantiates RoleValidatorName
func NewSMTPValidator ¶
NewSMTPValidator instantiates SMTPValidatorName
func NewSyntaxRegexValidator ¶
NewSyntaxRegexValidator creates SyntaxValidatorName, based on *regexp.Regexp Example of regular expressions HTML5 - https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address Different variations - http://emailregex.com/, RFC 5322 is used as default emailRegex
func NewSyntaxValidator ¶
func NewSyntaxValidator() Validator
NewSyntaxValidator instantiates SyntaxValidatorName based on mail.ParseAddress
func NewWarningsDecorator ¶
NewWarningsDecorator creates warning decorator to skip some errors
func NewWhiteListValidator ¶
NewWhiteListValidator instantiates WhiteListDomainValidatorName
type ValidatorMap ¶
type ValidatorMap map[ValidatorName]Validator
ValidatorMap alias for map[ValidatorName]Validator
func GetDefaultFactories ¶
func GetDefaultFactories() ValidatorMap
GetDefaultFactories returns default list ValidatorMap
type ValidatorName ¶
type ValidatorName string
ValidatorName is type to represent validator name
const BanWordsUsernameValidatorName ValidatorName = "BanWordsUsername"
BanWordsUsernameValidatorName is name of ban words username If email username has ban worlds, the email is invalid
const BlackListDomainsValidatorName ValidatorName = "BlackListDomains"
BlackListDomainsValidatorName is name of black domain It checks an domain of email in list. If the address domain is in, the email is invalid.
const BlackListEmailsValidatorName ValidatorName = "BlackListEmails"
BlackListEmailsValidatorName is name of black list emails It checks an email in list. If the address is in, the email is invalid.
const DepValidatorName ValidatorName = "depValidator"
DepValidatorName is name of validator with dependencies
const DisposableValidatorName ValidatorName = "DisposableValidator"
DisposableValidatorName is name of disposable validator
const FreeValidatorName ValidatorName = "FreeValidator"
FreeValidatorName is name of free validator
const MXValidatorName ValidatorName = "MXValidator"
MXValidatorName is name of mx validator
const OtherValidator ValidatorName = "other"
OtherValidator is ValidatorName for unknown Validator
const RoleValidatorName ValidatorName = "RoleValidator"
RoleValidatorName is name of role validator
const SMTPValidatorName ValidatorName = "SMTPValidator"
SMTPValidatorName is name of smtp validator
const SyntaxValidatorName ValidatorName = "syntaxValidator"
SyntaxValidatorName is name of syntax validator
const WhiteListDomainValidatorName ValidatorName = "WhiteListDomain"
WhiteListDomainValidatorName name of whiteListValidator
func (ValidatorName) String ¶
func (v ValidatorName) String() string
type WhiteListError ¶
type WhiteListError struct{}
WhiteListError is error for WhiteListDomainValidatorName
func (WhiteListError) Error ¶
func (WhiteListError) Error() string
Source Files
¶
- decorator_cache.go
- decorator_warnings.go
- validator.go
- validator_banwords_username.go
- validator_blacklist_domain.go
- validator_blacklist_email.go
- validator_dep.go
- validator_dep_builder.go
- validator_disposable.go
- validator_free.go
- validator_gravatar.go
- validator_input.go
- validator_mx.go
- validator_role.go
- validator_smtp.go
- validator_syntax.go
- validator_whitelist_domain.go