Content can also be empty
This commit is contained in:
		| @@ -16,9 +16,11 @@ 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 content != "" { | ||||||
| 		if !isValidXML(content) { | 		if !isValidXML(content) { | ||||||
| 			return nil, fmt.Errorf("%v not valid XML", content) | 			return nil, fmt.Errorf("%v not valid XML", content) | ||||||
| 		} | 		} | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	return &Category{Term: term, Content: content}, nil | 	return &Category{Term: term, Content: content}, nil | ||||||
| } | } | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								link.go
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								link.go
									
									
									
									
									
								
							| @@ -19,9 +19,11 @@ 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 content != "" { | ||||||
| 		if !isValidXML(content) { | 		if !isValidXML(content) { | ||||||
| 			return nil, fmt.Errorf("%v not valid XML", 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 | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user