Get rid of checks when creating constructs. Check should handle this.

This commit is contained in:
2024-10-19 14:12:51 +02:00
parent 960889f9e7
commit 57db4178d0
21 changed files with 143 additions and 345 deletions

28
link.go
View File

@@ -17,31 +17,9 @@ type Link struct {
Length uint `xml:"length,attr,omitempty"`
}
// NewLink creates a new Link. It returns a *Link and an error.
func NewLink(href string) (*Link, error) {
if !isValidIRI(href) {
return nil, fmt.Errorf("href %v not correctly formatted", href)
}
return &Link{Href: href}, nil
}
// SetType sets the Type attribute of the Link. It returns an error.
func (l *Link) SetType(t string) error {
if !isValidMediaType(t) {
return fmt.Errorf("type %v invalid media type", t)
}
return nil
}
// SetHrefLang sets the HrefLang attribute of the Link. It returns an error.
func (l *Link) SetHrefLang(h string) error {
if !isValidLanguageTag(h) {
return fmt.Errorf("hreflang %v invalid language tag", h)
}
return nil
// NewLink creates a new Link. It returns a *Link.
func NewLink(href string) *Link {
return &Link{Href: href}
}
// Check checks the Link for incompatibilities with RFC4287. It returns an