atom/icon.go

28 lines
410 B
Go
Raw Normal View History

2024-10-13 17:19:40 +02:00
package atomfeed
2024-10-16 17:03:23 +02:00
import (
"errors"
"fmt"
)
2024-10-13 17:19:40 +02:00
type Icon struct {
*CommonAttributes
URI URI `xml:"uri"`
}
2024-10-16 17:03:23 +02:00
func NewIcon(uri string) *Icon {
return &Icon{URI: URI(uri)}
}
2024-10-13 17:19:40 +02:00
func (i *Icon) Check() error {
if i.URI == "" {
return errors.New("uri element of icon empty")
2024-10-16 17:03:23 +02:00
} else {
if !isValidURI(i.URI) {
return fmt.Errorf("uri attribute %v of icon not correctly formatted", i.URI)
}
2024-10-13 17:19:40 +02:00
}
return nil
}