This commit is contained in:
Vladislav Kunetskiy
2026-10-15 20:52:43 +03:00
parent 4300d49c20
commit 4e84354642
125 changed files with 12049 additions and 2120 deletions
+14 -1
View File
@@ -30,7 +30,20 @@ func (d ChatDraft) Validate() error {
return err
}
if !slices.Contains(d.MemberIDs, d.CallerID) {
if len(d.MemberIDs) == 0 {
return fmt.Errorf("member_ids must not be empty: %w", ErrValidation)
}
seen := make(map[uuid.UUID]struct{}, len(d.MemberIDs))
for _, id := range d.MemberIDs {
if _, ok := seen[id]; ok {
return fmt.Errorf("member_ids contains duplicates: %w", ErrValidation)
}
seen[id] = struct{}{}
}
if _, ok := seen[d.CallerID]; !ok {
return fmt.Errorf("member_ids must contain the caller: %w", ErrValidation)
}