atom/extensionElement.go

28 lines
604 B
Go
Raw Normal View History

2024-10-16 21:28:04 +02:00
package atom
2024-10-13 17:19:40 +02:00
import (
"encoding/xml"
"errors"
)
type ExtensionElement struct {
Value any `xml:",innerxml"`
XMLName xml.Name
}
2024-10-16 19:59:28 +02:00
// NewExtensionElement creates a new ExtensionElement. It returns a
// *ExtensionElement.
func NewExtensionElement(name string, value any) *ExtensionElement {
return &ExtensionElement{XMLName: xml.Name{Local: name}, Value: value}
}
2024-10-16 19:59:28 +02:00
// Check checks the ExtensionElement for incompatibilities with RFC4287. It
// returns an error.
2024-10-13 17:19:40 +02:00
func (e *ExtensionElement) Check() error {
if e.Value == nil {
2024-10-18 19:04:08 +02:00
return errors.New("value element of extension empty")
2024-10-13 17:19:40 +02:00
}
return nil
}