package governance import ( "strings" "time" ) type UISettings struct { ID string `json:"id"` State string `json:"state"` DocumentRefreshSeconds int `json:"document_refresh_seconds"` ResourceRefreshSeconds int `json:"resource_refresh_seconds"` StalledAfterSeconds int `json:"stalled_after_seconds"` FinalizingAfterSeconds int `json:"finalizing_after_seconds"` UpdatedBy string `json:"updated_by"` CreatedAt time.Time `json:"created_at"` ActivatedAt *time.Time `json:"activated_at"` RetiredAt *time.Time `json:"retired_at"` ErrorCode string `json:"error_code"` } type CreateUISettingsCandidateRequest struct { DocumentRefreshSeconds int ResourceRefreshSeconds int StalledAfterSeconds int FinalizingAfterSeconds int UpdatedBy string Now time.Time } func (request CreateUISettingsCandidateRequest) Valid() bool { return oneOfInt(request.DocumentRefreshSeconds, 15, 30, 60) && oneOfInt(request.ResourceRefreshSeconds, 30, 60) && oneOfInt(request.StalledAfterSeconds, 1800, 3600) && oneOfInt(request.FinalizingAfterSeconds, 7200, 14400) && validSettingsActor(request.UpdatedBy) && !request.Now.IsZero() } func oneOfInt(value int, allowed ...int) bool { for _, candidate := range allowed { if value == candidate { return true } } return false } func validSettingsActor(value string) bool { trimmed := strings.TrimSpace(value) return trimmed == value && len(trimmed) >= 2 && len(trimmed) <= 128 && !strings.ContainsAny(trimmed, "\x00\r\n\t") }