atom/logo.go

37 lines
690 B
Go

package atom
import (
"encoding/xml"
"errors"
"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 errors.New("uri element of logo empty")
} else {
if !isValidIRI(l.URI) {
return fmt.Errorf("uri element %v of logo not correctly formatted", l.URI)
}
}
return nil
}