-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
truemail.go
27 lines (21 loc) · 1.07 KB
/
truemail.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package truemail
// Validate is main truemail entrypoint. Accepts validation type as option.
// Available types are: regex, mx, mx_blacklist, smtp. By default uses
// validation layer specified in Configuration.ValidationTypeDefault
func Validate(email string, configuration *Configuration, options ...string) (*ValidatorResult, error) {
validationType, err := variadicValidationType(options, configuration.ValidationTypeDefault)
if err != nil {
return nil, err
}
return newValidator(email, validationType, configuration).run(), err
}
// IsValid is shortcut for Validate() function. Returns boolean as email validation result.
// Accepts validation type as option. Available types are: regex, mx, mx_blacklist, smtp.
// By default uses validation layer specified in Configuration.ValidationTypeDefault
func IsValid(email string, configuration *Configuration, options ...string) bool {
validationType, err := variadicValidationType(options, configuration.ValidationTypeDefault)
if err != nil {
return false
}
return newValidator(email, validationType, configuration).run().Success
}