MCPcopy Create free account
hub / github.com/SamNet-dev/snix / Parse

Function Parse

config/config.go:118–127  ·  view source on GitHub ↗

Parse validates a YAML document in memory. Exported so the TUI can validate as the user types.

(doc []byte)

Source from the content-addressed store, hash-verified

116// Parse validates a YAML document in memory. Exported so the TUI can
117// validate as the user types.
118func Parse(doc []byte) (*Config, error) {
119 var c Config
120 if err := yaml.Unmarshal(doc, &c); err != nil {
121 return nil, fmt.Errorf("config: parse yaml: %w", err)
122 }
123 if err := c.Validate(); err != nil {
124 return nil, err
125 }
126 return &c, nil
127}
128
129// Validate checks invariants and sets defaults in-place.
130func (c *Config) Validate() error {

Callers 4

TestParseValidFunction · 0.85
TestParseRejectsFunction · 0.85
TestDefaultsFunction · 0.85
LoadFunction · 0.85

Calls 1

ValidateMethod · 0.95

Tested by 3

TestParseValidFunction · 0.68
TestParseRejectsFunction · 0.68
TestDefaultsFunction · 0.68