Files
warmbly/internal/utils/validate/uuid.go
T
Matthew MeszarosandDevin AI dfed1e1593 feat: validate API UUIDs, recover expired Gmail history and guard consumer startup and stale frontend assets
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-10-07 07:19:15 +00:00

41 lines
716 B
Go

package validate
import (
"github.com/google/uuid"
"github.com/warmbly/warmbly/internal/errx"
)
func Uuid(id string) (*string, *errx.Error) {
if id == "" {
return nil, nil
}
uid, err := uuid.Parse(id)
if err != nil {
return nil, errx.ErrUuid
}
uidstr := uid.String()
return &uidstr, nil
}
func Uuids(ids []string) ([]string, *errx.Error) {
if ids == nil {
return nil, nil
}
out := make([]string, 0, len(ids))
seen := make(map[uuid.UUID]struct{}, len(ids))
for _, id := range ids {
parsed, err := uuid.Parse(id)
if err != nil {
return nil, errx.ErrUuid
}
if _, ok := seen[parsed]; !ok {
out = append(out, parsed.String())
seen[parsed] = struct{}{}
}
}
return out, nil
}