Added more error handling and necessary functions

This commit is contained in:
2024-10-19 12:28:09 +02:00
parent d4e7bce5e2
commit f4dfd6d060
22 changed files with 317 additions and 122 deletions

6
id.go
View File

@@ -9,16 +9,16 @@ import (
type ID struct {
XMLName xml.Name `xml:"id"`
*CommonAttributes
URI IRI `xml:",chardata"`
URI string `xml:",chardata"` // IRI
}
// NewID creates a new ID. It returns a *ID and an error.
func NewID(uri IRI) (*ID, error) {
func NewID(uri string) (*ID, error) {
if !isValidIRI(uri) {
return nil, fmt.Errorf("uri %v not correctly formatted", uri)
}
return &ID{URI: IRI(uri)}, nil
return &ID{URI: uri}, nil
}
// Check checks the ID for incompatibilities with RFC4287. It returns an error.