Create NewIcon and appropriate checks
This commit is contained in:
parent
566227773e
commit
a65aa0a740
13
icon.go
13
icon.go
@ -1,15 +1,26 @@
|
||||
package atomfeed
|
||||
|
||||
import "errors"
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type Icon struct {
|
||||
*CommonAttributes
|
||||
URI URI `xml:"uri"`
|
||||
}
|
||||
|
||||
func NewIcon(uri string) *Icon {
|
||||
return &Icon{URI: URI(uri)}
|
||||
}
|
||||
|
||||
func (i *Icon) Check() error {
|
||||
if i.URI == "" {
|
||||
return errors.New("uri element of icon empty")
|
||||
} else {
|
||||
if !isValidURI(i.URI) {
|
||||
return fmt.Errorf("uri attribute %v of icon not correctly formatted", i.URI)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
Loading…
x
Reference in New Issue
Block a user