-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofile.go
More file actions
32 lines (26 loc) 路 715 Bytes
/
Copy pathprofile.go
File metadata and controls
32 lines (26 loc) 路 715 Bytes
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
package pub
import (
"errors"
"fmt"
)
var (
ErrProfileMissingName = errors.New("profile: missing Name")
)
// Profile may represent an individual or an organization that is credited as either an author, contributor or publisher affliated with a [Book].
type Profile struct {
Name string `json:"name"`
NamesAlternate []string `json:"names_alternate"`
Content Content `json:"content"`
External []Reference `json:"external"`
}
func (p *Profile) EnsureValid() error {
if p.Name == "" {
return ErrProfileMissingName
}
for _, e := range p.External {
if err := e.EnsureValid(); err != nil {
return fmt.Errorf("profile \"%s\": %w", p.Name, err)
}
}
return nil
}