utils/validators.go

25 lines
444 B
Go
Raw Permalink Normal View History

2023-10-02 23:42:16 +02:00
package utils
import "net/url"
// IsStringInSliceOfStrings returns true, if slice contains target
func IsStringInSliceOfStrings(slice []string, target string) bool {
for _, v := range slice {
if v == target {
return true
}
}
return false
}
// IsValidUrl returns true, if s is a valid URL
func IsValidUrl(s string) bool {
u, err := url.Parse(s)
if err != nil || u.Scheme == "" || u.Host == "" {
return false
}
return true
}