package corecfg import "gitea.epss.net.cn/klesh/ss/internal/model" // validateConfigMap applies the same field constraints as the Pydantic // Config model's validators (models.py) to a raw config map, checking only // the fields that are present. func validateConfigMap(data map[string]interface{}) error { cfg := model.DefaultConfig() if v, ok := data["refresh_interval_hours"]; ok { if n, ok := toInt(v); ok { cfg.RefreshIntervalHours = n } } if v, ok := data["timeout_seconds"]; ok { if n, ok := toInt(v); ok { cfg.TimeoutSeconds = n } } return cfg.Validate() } func toInt(v interface{}) (int, bool) { switch n := v.(type) { case int: return n, true case int64: return int(n), true case float64: return int(n), true default: return 0, false } }