No default allowed limits - these must be configured via runtime config ValidateOverrides checks if the provided overrides only contain allowed limits
(overrides map[string]any, allowedLimits []string)
| 22 | |
| 23 | // ValidateOverrides checks if the provided overrides only contain allowed limits |
| 24 | func ValidateOverrides(overrides map[string]any, allowedLimits []string) error { |
| 25 | var invalidLimits []string |
| 26 | |
| 27 | for limitName := range overrides { |
| 28 | if !slices.Contains(allowedLimits, limitName) { |
| 29 | invalidLimits = append(invalidLimits, limitName) |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | if len(invalidLimits) > 0 { |
| 34 | return fmt.Errorf("%s: %s", ErrInvalidLimits, strings.Join(invalidLimits, ", ")) |
| 35 | } |
| 36 | |
| 37 | return nil |
| 38 | } |
| 39 | |
| 40 | // validateHardLimits checks if the provided overrides exceed any hard limits from the runtime config |
| 41 | func (a *API) validateHardLimits(overrides map[string]any, userID string) error { |