utils/validators.go
2023-10-02 23:42:16 +02:00

25 lines
444 B
Go

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
}