From 31cc8034405af3b2036a3d54910e9530677fcbf5 Mon Sep 17 00:00:00 2001 From: Jason Streifling Date: Wed, 16 Oct 2024 18:33:23 +0200 Subject: [PATCH] Create NewLogo and add checks --- logo.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/logo.go b/logo.go index 5c0fe63..949fbd5 100644 --- a/logo.go +++ b/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