Skip to content

Commit

Permalink
Add datatype package
Browse files Browse the repository at this point in the history
  • Loading branch information
chasehensel committed May 28, 2020
1 parent 64be597 commit a196b02
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions internal/datatypes/email.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package datatypes

import (
"regexp"
)

//https://www.alexedwards.net/blog/validation-snippets-for-go#email-validation
var rxEmail = regexp.MustCompile("^[a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$")


func MatchEmail(s string) bool {
return rxEmail.MatchString(s);
}

0 comments on commit a196b02

Please sign in to comment.