Create and use isValidURL

This commit is contained in:
2024-10-16 16:14:34 +02:00
parent 4f70da9a17
commit 14696371e2
3 changed files with 8 additions and 4 deletions

View File

@@ -5,7 +5,6 @@ import (
"errors"
"fmt"
"net/mail"
"net/url"
)
type Person struct {
@@ -30,7 +29,7 @@ func (p *Person) Check() error {
}
if p.URI != "" {
if _, err := url.ParseRequestURI(string(p.URI)); err != nil {
if !isValidURL(p.URI) {
return fmt.Errorf("uri element of person %v not correctly formatted", p.Name)
}
}