package admin import ( "bytes" "gopkg.in/yaml.v3" "thehouseoficarus/internal/casino" ) // Validate before any room/link writes. Only casino fields are decoded here; // the room editor's unrelated fields retain their existing representation. func validateRoomCasinoMap(m map[string]any) error { fields := map[string]any{} for _, key := range []string{"casino_tables", "casino_machines"} { if value, ok := m[key]; ok { fields[key] = value } } data, err := yaml.Marshal(fields) if err != nil { return err } var cfg struct { Tables []casino.TableConfig `yaml:"casino_tables"` Machines []casino.MachineConfig `yaml:"casino_machines"` } decoder := yaml.NewDecoder(bytes.NewReader(data)) decoder.KnownFields(true) if err := decoder.Decode(&cfg); err != nil { return err } return casino.ValidateRoomConfigs(cfg.Tables, cfg.Machines) }