diff --git a/cmd/internal/db/queries.go b/cmd/internal/db/queries.go index 4d347ad..0fbbc18 100644 --- a/cmd/internal/db/queries.go +++ b/cmd/internal/db/queries.go @@ -104,7 +104,7 @@ func ViewColor(id int) (*models.LampState, error) { func SetColor(id int, color string) error { if !utils.IsValidHexColor(color) { - return errors.New("invalid HEX Code: %s") + return errors.New("invalid HEX Code") } currentColor, err := ViewColor(id) if err != nil { diff --git a/cmd/utils/utils.go b/cmd/utils/utils.go index f14f194..a3cd5c9 100644 --- a/cmd/utils/utils.go +++ b/cmd/utils/utils.go @@ -26,7 +26,7 @@ func IDtoInt(id string) (int, error) { } func IsValidHexColor(color string) bool { - pattern := `^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$` + pattern := `^#(?:[A-Fa-f0-9]{3}|[A-Fa-f0-9]{6})$` match, _ := regexp.MatchString(pattern, color) return match }