Check whether there is a link element with a rel attribute of "alternate" if there is no content element in an entry element
This commit is contained in:
parent
cd61cb4f27
commit
1ecda50f34
14
entry.go
14
entry.go
@ -43,6 +43,16 @@ func (e *Entry) checkAuthors() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func alternateRelExists(l []*Link) bool {
|
||||
for _, link := range l {
|
||||
if link.Rel == "alternate" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (e *Entry) AddExtension(name string, value any) {
|
||||
e.Extensions = append(e.Extensions, &ExtensionElement{XMLName: xml.Name{Local: name}, Value: value})
|
||||
}
|
||||
@ -72,6 +82,10 @@ func (e *Entry) Check() error {
|
||||
if err := (*e.Content).Check(); err != nil {
|
||||
return fmt.Errorf("content element of entry %v: %v", e.ID.URI, err)
|
||||
}
|
||||
} else {
|
||||
if !alternateRelExists(e.Links) {
|
||||
return errors.New("no content element of entry %v and no link element with rel \"alternate\"")
|
||||
}
|
||||
}
|
||||
|
||||
if e.Contributors != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user