Content can also be empty

This commit is contained in:
Jason Streifling 2024-10-17 18:40:52 +02:00
parent 5a82f1799f
commit e73b78ef30
2 changed files with 8 additions and 4 deletions

View File

@ -16,8 +16,10 @@ type Category struct {
// NewCategory creates a new Category. It returns a *Category and an error. // NewCategory creates a new Category. It returns a *Category and an error.
func NewCategory(term, content string) (*Category, error) { func NewCategory(term, content string) (*Category, error) {
if !isValidXML(content) { if content != "" {
return nil, fmt.Errorf("%v not valid XML", content) if !isValidXML(content) {
return nil, fmt.Errorf("%v not valid XML", content)
}
} }
return &Category{Term: term, Content: content}, nil return &Category{Term: term, Content: content}, nil

View File

@ -19,8 +19,10 @@ type Link struct {
// NewLink creates a new Link. It returns a *Link and an error. // NewLink creates a new Link. It returns a *Link and an error.
func NewLink(href, content string) (*Link, error) { func NewLink(href, content string) (*Link, error) {
if !isValidXML(content) { if content != "" {
return nil, fmt.Errorf("%v not valid XML", content) if !isValidXML(content) {
return nil, fmt.Errorf("%v not valid XML", content)
}
} }
return &Link{Href: IRI(href), Content: content}, nil return &Link{Href: IRI(href), Content: content}, nil