MCPcopy Index your code
hub / github.com/foxcpp/maddy / Valid

Function Valid

framework/address/validation.go:34–51  ·  view source on GitHub ↗

* Rules for validation are subset of rules listed here: https://emailregex.com/email-validation-summary/ */ Valid checks whether ths string is valid as a email address as defined by RFC 5321.

(addr string)

Source from the content-addressed store, hash-verified

32// Valid checks whether ths string is valid as a email address as defined by
33// RFC 5321.
34func Valid(addr string) bool {
35 if len(addr) > 320 { // RFC 3696 says it's 320, not 255.
36 return false
37 }
38
39 mbox, domain, err := Split(addr)
40 if err != nil {
41 return false
42 }
43
44 // The only case where this can be true is "postmaster".
45 // So allow it.
46 if domain == "" {
47 return true
48 }
49
50 return ValidMailboxName(mbox) && ValidDomain(domain)
51}
52
53var validGraphic = map[rune]bool{
54 '!': true, '#': true,

Callers 3

NormalizeAutoFunction · 0.92
rewriteMethod · 0.92
validMatchRuleFunction · 0.92

Calls 3

SplitFunction · 0.85
ValidMailboxNameFunction · 0.85
ValidDomainFunction · 0.85

Tested by

no test coverage detected