-
Notifications
You must be signed in to change notification settings - Fork 10
/
owner_accessors.go
68 lines (50 loc) · 1.26 KB
/
owner_accessors.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package config
import (
"github.com/benpate/rosetta/schema"
)
func OwnerSchema() schema.Element {
return schema.Object{
Properties: schema.ElementMap{
"displayName": schema.String{MaxLength: 100, Required: true},
"username": schema.String{MaxLength: 255, Required: true},
"emailAddress": schema.String{MaxLength: 255, Format: "email", Required: true},
"phoneNumber": schema.String{MaxLength: 20},
"mailingAddress": schema.String{MaxLength: 1000},
},
}
}
func (owner Owner) GetStringOK(name string) (string, bool) {
switch name {
case "displayName":
return owner.DisplayName, true
case "username":
return owner.Username, true
case "emailAddress":
return owner.EmailAddress, true
case "phoneNumber":
return owner.PhoneNumber, true
case "mailingAddress":
return owner.MailingAddress, true
}
return "", false
}
func (owner *Owner) SetString(name string, value string) bool {
switch name {
case "displayName":
owner.DisplayName = value
return true
case "username":
owner.Username = value
return true
case "emailAddress":
owner.EmailAddress = value
return true
case "phoneNumber":
owner.PhoneNumber = value
return true
case "mailingAddress":
owner.MailingAddress = value
return true
}
return false
}