emailaddress

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2021 License: MIT Imports: 4 Imported by: 0

README

emailaddress

https://pkg.golang.ir/github.com/nishanths/emailaddress

The goal of the package is to never classify a valid email address as invalid; this is in contrast to the overly strict email address validation behavior often seen on the Internet.

It uses net/mail underneath.

API

func IsValid(email string) bool
func Parse(email string) (localPart, domain string, err error)

Contributing

  • If you plan to adopt this package for your project, please consider contributing back valid/invalid email address test cases you may already have in your project.

Documentation

Overview

Package emailaddress parses and validates emails addresses, using the standard library's net/mail package. The goal of the package is to never classify a valid email address as invalid; this is in contrast to the overly strict email address validation behavior often seen on the Internet.

This package at its core uses the net/mail package for parsing. The net/mail package appears to classify certain email addresses that are invalid according to RFCs and Wikipedia as valid. The same behavior is seen from this package as well.

The net/mail package only provides an interface to parse addresses of the form "Barry Gibbs <[email protected]>" (name and email address). This package provides an interface to parse and validate addresses without the name part (i.e. of the form "[email protected]").

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsValid

func IsValid(email string) bool

IsValid returns whether the email address is of valid format. It is a shorthand for the piece of code:

_, _, err := Parse(email)
return err != nil

Most callers will want to use strings.TrimSpace(email) before invoking this function.

func Parse

func Parse(email string) (localPart, domain string, err error)

Parse parses an email address into its local-part and domain. If the error is nil, the format of the email address can be considered valid.

Most callers will want to use strings.TrimSpace(email) before invoking this function.

Types

This section is empty.

Jump to

Keyboard shortcuts

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