validate provided HEX-Code

This commit is contained in:
Mitsu
2025-07-09 20:42:30 +02:00
parent 684cd08c1c
commit 34a1a6d13d
2 changed files with 12 additions and 0 deletions
+6
View File
@@ -4,6 +4,7 @@ import (
"encoding/json"
"errors"
"net/http"
"regexp"
"strconv"
"time"
@@ -20,6 +21,11 @@ func IDtoInt(id string) (int, error) {
}
return idInt, nil
}
func IsValidHexColor(color string) bool {
pattern := `^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$`
match, _ := regexp.MatchString(pattern, color)
return match
}
func HTTPErrorHandling(w http.ResponseWriter, r *http.Request, status int, message string) {
timestamp := time.Now().Format("2006-01-02_15-04-05")