aboutsummaryrefslogtreecommitdiff
path: root/contact.go
diff options
context:
space:
mode:
Diffstat (limited to 'contact.go')
-rw-r--r--contact.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/contact.go b/contact.go
index 8b0b054..7d6446c 100644
--- a/contact.go
+++ b/contact.go
@@ -4,6 +4,7 @@ import (
"encoding"
"encoding/json"
"errors"
+ "net/mail"
"strings"
)
@@ -46,3 +47,19 @@ func (c *Contacts) UnmarshalJSON(b []byte) error {
}
return nil
}
+
+func (c *Contacts) AddMail(email string) error {
+ m, err := mail.ParseAddress(email)
+ if err != nil {
+ return err
+ }
+ *c = append(*c, Mail(m.Address))
+ return nil
+}
+
+func (c *Contacts) AddPhone(phone string) error {
+ if ph := strings.TrimSpace(phone); ph != "" {
+ *c = append(*c, Phone(ph))
+ }
+ return nil
+}