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
|
2024-10-16 17:33:25 +02:00
|
|
|
URI IRI `xml:"uri"`
|
2024-10-13 17:19:40 +02:00
|
|
|
}
|
|
|
|
|
2024-10-16 17:03:23 +02:00
|
|
|
func NewIcon(uri string) *Icon {
|
2024-10-16 17:33:25 +02:00
|
|
|
return &Icon{URI: IRI(uri)}
|
2024-10-16 17:03:23 +02:00
|
|
|
}
|
|
|
|
|
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 {
|
2024-10-16 17:33:25 +02:00
|
|
|
if !isValidIRI(i.URI) {
|
2024-10-16 17:03:23 +02:00
|
|
|
return fmt.Errorf("uri attribute %v of icon not correctly formatted", i.URI)
|
|
|
|
}
|
2024-10-13 17:19:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|