atom/logo.go

36 lines
708 B
Go

package atom
import (
"encoding/xml"
"fmt"
)
type Logo struct {
XMLName xml.Name `xml:"logo"`
*CommonAttributes
URI string `xml:",chardata"` // IRI
}
// NewLogo creates a new Logo. It returns a *Logo and an error.
func NewLogo(uri string) (*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
}