Documentation

7.6 Unknown keys, types and range validation

Configuration validation occurs in layers. Understanding the layer that rejected a file makes correction faster and prevents “fixes” that change scientific intent.

1. TOML syntax

The parser first checks quotes, brackets, table headers and assignments. A malformed document cannot be deserialized. Line and column context identifies where parsing stopped, which may be just after the actual missing delimiter.

2. Structure, names and types

Strict command configurations reject unknown keys and unexpected tables. The Chapter 7 negative fixture writes methdo = "fim". nlmx exits 4 and reports:

unknown field `methdo`, expected one of `method`, `alpha`,
`target_power`, `ci_level`, `seed`, `threads`

This strictness is important: silently ignoring a misspelled scientific option would make the run appear successful while using a default. Type mismatches—such as a string where an integer is required—fail in the same deserialization phase.

3. Semantic validation

After successful parsing, command code checks allowed values and relationships: probabilities may require bounded ranges, required paths must be present, lists may need elements, and paired settings must be coherent. A value can be valid TOML of the correct type and still be scientifically or operationally invalid.

4. Runtime feasibility

Some conditions become knowable only after loading inputs: a requested parameter may not exist, a column may be absent, or an output destination may be unsafe. These are not configuration syntax defects, although they can originate from a valid setting.

Validation strategy

Correct one layer at a time. Do not respond to an unknown-key message by weakening strict parsing or moving the key randomly. Compare it to the generated template for the same command and version. After the file parses, read all remaining validation messages before launching a full analysis.

For compatibility studies, add negative fixtures. A release test should prove that critical misspellings are rejected, not merely that correct files pass.

Common mistakes

  • Interpreting “valid TOML” as “valid nlmx configuration.”
  • Assuming an unknown key will be ignored.
  • Correcting syntax while overlooking an invalid scientific range.

Checklist

  • Classify the failure as syntax, structure/type, semantic or runtime.
  • Compare against a version-matched template.
  • Retain failing fixtures for regression testing.

Further reading

See error messages, templates and review practices.