30 lines
518 B
Go
30 lines
518 B
Go
package atom
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
)
|
|
|
|
type ID struct {
|
|
*CommonAttributes
|
|
URI IRI `xml:",chardata"`
|
|
}
|
|
|
|
// NewID creates a new ID. It returns a *ID.
|
|
func NewID(uri IRI) *ID {
|
|
return &ID{URI: IRI(uri)}
|
|
}
|
|
|
|
// Check checks the ID for incompatibilities with RFC4287. It returns an error.
|
|
func (i *ID) Check() error {
|
|
if i.URI == "" {
|
|
return errors.New("uri element of id empty")
|
|
} else {
|
|
if !isValidIRI(i.URI) {
|
|
return fmt.Errorf("uri element %v of id not correctly formatted", i.URI)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|