components-contrib/internal/utils/utils.go

17 lines
365 B
Go

package utils
import (
"strings"
)
// IsTruthy returns true if a string is a truthy value.
// Truthy values are "y", "yes", "true", "t", "on", "1" (case-insensitive); everything else is false.
func IsTruthy(val string) bool {
switch strings.ToLower(strings.TrimSpace(val)) {
case "y", "yes", "true", "t", "on", "1":
return true
default:
return false
}
}