aboutsummaryrefslogtreecommitdiff
path: root/contact.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-01-04 23:51:46 +0100
committerDimitri Sokolyuk <demon@dim13.org>2016-01-04 23:51:46 +0100
commitd534bb3fd336c8f69a7348a36084b487904b5b6a (patch)
treeb052af6d884a2ba98be9a31fbcfafe956ca39201 /contact.go
parent74e5ab64d63946c4ac1ce7317af08bc0a378ca93 (diff)
Separate contacts
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
+}