feat(app) lab 3 implemented

This commit is contained in:
imadev
2026-10-30 18:11:30 +03:00
parent f731f9b460
commit 48a616e910
57 changed files with 1390 additions and 303 deletions
+14 -1
View File
@@ -8,7 +8,10 @@ import (
"github.com/google/uuid"
)
var usernameRegex = regexp.MustCompile(`^[a-z0-9_]{3,32}$`)
var (
usernameRegex = regexp.MustCompile(`^[a-z0-9_]{3,32}$`)
idempotencyKeyRegex = regexp.MustCompile(`^[A-Za-z0-9._:-]{1,128}$`)
)
func blank(s string) bool {
return strings.TrimSpace(s) == ""
@@ -71,6 +74,16 @@ func ValidateMessageText(text string) string {
return ""
}
func ValidateIdempotencyKey(key string) string {
if key == "" {
return "Idempotency-Key header is required"
}
if !idempotencyKeyRegex.MatchString(key) {
return "Idempotency-Key must match ^[A-Za-z0-9._:-]{1,128}$"
}
return ""
}
func ValidateMemberIDs(ids []uuid.UUID, callerID uuid.UUID) string {
if len(ids) < 1 || len(ids) > 100 {
return "member_ids must contain between 1 and 100 members"