Get rid of checks when creating constructs. Check should handle this.
This commit is contained in:
28
link.go
28
link.go
@@ -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
|
||||
|
Reference in New Issue
Block a user