Skip to content

Commit

Permalink
added display of possible properties when ize.toml has invalid syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
psihachina committed Oct 11, 2022
1 parent 8a973ac commit 96981be
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion internal/schema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,18 @@ func Validate(config map[string]interface{}) error {
} else {
i = strings.ReplaceAll(i[2:], "/", ".")
}
return fmt.Errorf("%s in %s of config file (or environment variables)", m, i)
errMsg := fmt.Sprintf("%s in %s of config file (or environment variables)", m, i)
if strings.Contains(errMsg, "additionalProperties") {
errMsg += ". The following options are available:\n"
properties := GetSchema()
if i != "root" {
properties = properties[strings.Split(i, ".")[0]].Items
}
for k := range properties {
errMsg += fmt.Sprintf("- %s\n", k)
}
}
return fmt.Errorf(errMsg)
}

return nil
Expand Down

0 comments on commit 96981be

Please sign in to comment.