Bootstrap copied BFF and local accounts with public Sendico contracts (#34)
This commit is contained in:
1 parent
67dc5b5b1e
commit
7062672a87
556 files changed
+42291
-777
No files matched your search
@@ -0,0 +1,23 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"net/mail"
|
||||
"strings"
|
||||
|
||||
"git.sendico.io/tech/sxchnge/bff/pkg/merrors"
|
||||
)
|
||||
|
||||
func (i *Invitation) Validate() error {
|
||||
if i == nil {
|
||||
return merrors.InvalidArgument("invitation is required", "invitation")
|
||||
}
|
||||
if strings.TrimSpace(i.Content.Email) == "" {
|
||||
return merrors.InvalidArgument("invitation email must not be empty", "description.email")
|
||||
}
|
||||
trimmedEmail := strings.TrimSpace(i.Content.Email)
|
||||
parsed, err := mail.ParseAddress(trimmedEmail)
|
||||
if err != nil || parsed.Address != trimmedEmail {
|
||||
return merrors.InvalidArgument("invitation email is malformed", "description.email")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in new issue
Block a user