atom/logo.go

36 lines
682 B
Go

package atom
import (
"encoding/xml"
"fmt"
)
type Logo struct {
XMLName xml.Name `xml:"logo"`
*CommonAttributes
URI IRI `xml:",chardata"`
}
// NewLogo creates a new Logo. It returns a *Logo.
func NewLogo(uri IRI) (*Logo, error) {
if !isValidIRI(uri) {
return nil, fmt.Errorf("uri %v not correctly formatted", uri)
}
return &Logo{URI: uri}, nil
}
// Check checks the Logo for incompatibilities with RFC4287. It returns an
// error.
func (l *Logo) Check() error {
if l.URI == "" {
return fmt.Errorf("uri element of logo %v empty", l)
} else {
if !isValidIRI(l.URI) {
return fmt.Errorf("uri element of logo %v not correctly formatted", l)
}
}
return nil
}