This commit is contained in:
Vladislav Kunetskiy
2026-10-15 20:45:29 +03:00
parent 1fdaf6299a
commit f4bd361f12
140 changed files with 12784 additions and 2198 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)
}