Create NewLogo and add checks
This commit is contained in:
parent
f11dee630d
commit
31cc803440
15
logo.go
15
logo.go
@ -1,15 +1,28 @@
|
||||
package atomfeed
|
||||
|
||||
import "errors"
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type Logo struct {
|
||||
*CommonAttributes
|
||||
URI IRI `xml:"uri"`
|
||||
}
|
||||
|
||||
func NewLogo() *Logo {
|
||||
return &Logo{URI: IRI(fmt.Sprint("urn:uuid:", uuid.New()))}
|
||||
}
|
||||
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user