package supplier import ( "fmt" "net/url" ) func validateUrl(u *url.URL) error { if u.Scheme == "" { return fmt.Errorf("scheme cannot be empty") } if u.Scheme != "http" && u.Scheme != "https" { return fmt.Errorf("%s scheme is not valid", u.Scheme) } if u.Host == "" { return fmt.Errorf("host can't be empty") } if u.User == nil { return fmt.Errorf("credentials must be provided") } if u.User.Username() == "" { return fmt.Errorf("username can't be empty") } if p, ok := u.User.Password(); !ok || p == "" { return fmt.Errorf("password can't be empty") } return nil }