MCPcopy Create free account
hub / github.com/tbphp/gpt-load / validateGroupReorderItems

Function validateGroupReorderItems

internal/handler/group_handler.go:146–166  ·  view source on GitHub ↗
(items []GroupReorderItemRequest)

Source from the content-addressed store, hash-verified

144}
145
146func validateGroupReorderItems(items []GroupReorderItemRequest) error {
147 if len(items) == 0 {
148 return services.NewI18nError(app_errors.ErrValidation, "validation.reorder_items_required", nil)
149 }
150
151 seen := make(map[uint]struct{}, len(items))
152 for _, item := range items {
153 if item.ID == 0 {
154 return services.NewI18nError(app_errors.ErrValidation, "validation.reorder_group_id", nil)
155 }
156 if item.Sort < 0 {
157 return services.NewI18nError(app_errors.ErrValidation, "validation.reorder_sort_negative", nil)
158 }
159 if _, exists := seen[item.ID]; exists {
160 return services.NewI18nError(app_errors.ErrValidation, "validation.reorder_duplicate_group", map[string]any{"id": item.ID})
161 }
162 seen[item.ID] = struct{}{}
163 }
164
165 return nil
166}
167
168// UpdateGroup handles updating an existing group.
169func (s *Server) UpdateGroup(c *gin.Context) {

Callers 1

ReorderGroupsMethod · 0.85

Calls 1

NewI18nErrorFunction · 0.92

Tested by

no test coverage detected