validator

package module
v0.0.0-...-8e45250 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 17, 2019 License: BSD-2-Clause Imports: 4 Imported by: 8

README

validator

Build Status

Go package validator validates and normalizes email addresses and domain names.

Installation

$ go get github.com/dchest/validator

Documentation

http://godoc.org/github.com/dchest/validator

Documentation

Overview

Package validator validates and normalizes email addresses and domain names.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidDomain = errors.New("invalid domain")
View Source
var ErrInvalidEmail = errors.New("invalid email address")

Functions

func IsValidDomain

func IsValidDomain(domain string) bool

IsValidDomain returns true if the domain is valid.

It uses a simple regular expression to check the domain validity.

func IsValidEmail

func IsValidEmail(email string) bool

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

func NormalizeDomain(domain string) string

NormalizeDomain returns a normalized domain. It returns an empty string if the domain is not valid.

func NormalizeEmail

func NormalizeEmail(email string) string

NormalizeEmail returns a normalized email address. It returns an empty string if the email is not valid.

func ValidateDomainByResolvingIt

func ValidateDomainByResolvingIt(domain string) error

ValidateDomainByResolvingIt queries DNS for the given domain name, and returns nil if the the name resolves, or an error.

func ValidateEmailByResolvingDomain

func ValidateEmailByResolvingDomain(email string) error

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL