package config import ( "fmt" "gopkg.in/yaml.v3" ) // UnmarshalYAML tracks explicit normalize.output_path presence so validation can // distinguish omitted vs explicitly empty values. func (cfg *NormalizeConfig) UnmarshalYAML(node *yaml.Node) error { if node.Kind != yaml.MappingNode { return fmt.Errorf("normalize must be a mapping") } allowedKeys := map[string]struct{}{ "output_path": {}, "output_schema": {}, "report": {}, } for i := 0; i+1 < len(node.Content); i += 2 { key := node.Content[i].Value if _, ok := allowedKeys[key]; !ok { return fmt.Errorf("field %q not found in type config.NormalizeConfig", key) } } type rawNormalize NormalizeConfig var raw rawNormalize if err := node.Decode(&raw); err != nil { return err } *cfg = NormalizeConfig(raw) for i := 0; i+1 < len(node.Content); i += 2 { if node.Content[i].Value == "output_path" { cfg.outputPathSet = true break } } return nil } // outputPathSet records whether normalize.output_path appeared in YAML. // This is intentionally unexported and not serialized. func (cfg *NormalizeConfig) outputPathWasSet() bool { if cfg == nil { return false } return cfg.outputPathSet }