# Validation Validate a completed domain document after the composing application has resolved imports, inheritance, and layering. ConfigKit owns those operations; this repository defines the handoff format. Partial authoring contributions may use schema definitions for editor assistance without conforming to a complete root. ## Command With Go 1.27 or later, run from the selected schema-set checkout or unpacked source archive: ```sh go mod download go run ./cmd/validate examples/party.yml examples/campaign.yml examples/glossary.yml ``` Dependencies are pinned in `go.mod` and `go.sum`. Once prepared, validation is offline. A built tool can select another unpacked distribution: ```sh go build -o /tmp/schemas-validate ./cmd/validate /tmp/schemas-validate -root /path/to/schemas-v1.0.0 /path/to/completed-glossary.yml ``` Flags precede filenames. All files are checked even if an earlier file fails. Exit 0 means all documents passed; 1 means a document could not be read or validated; 2 means invalid command usage or an unusable schema set. Errors identify the document and distinguish `decode`, `structure`, and `semantic`. Decoding errors include field paths and source positions where the YAML library or node profile provides them. Structural errors include JSON instance locations. Semantic duplicate-ID errors identify the collection and entry index. The harness uses Go's standard JSON decoder for JSON syntax, including Unicode surrogate-pair escapes, and [go-yaml v4](https://github.com/yaml/go-yaml/tree/v4.0.0) otherwise. Both paths reject duplicate keys and preserve number precision. It uses [jsonschema v6](https://github.com/santhosh-tekuri/jsonschema/tree/v6.0.3) for Draft 2020-12 validation. It performs glossary ID uniqueness after structural validation. It does not resolve domain references, check resource installation, infer consumer support, populate defaults, or rewrite files. ## YAML decoding profile Use one document containing string-keyed mappings, sequences, strings, finite numbers, booleans, and null. JSON is an equivalent serialization; `.json` files must use JSON syntax. The same duplicate-key and semantic rules apply to both. - Duplicate mapping keys are errors at every level. Keys compare as strings. - Mapping keys must resolve to strings; quote numeric or boolean-looking keys when they are intended to be names. Mapping order carries no domain meaning. - `true` and `false` (including YAML case variants) are booleans. `yes`, `no`, `on`, and `off` remain strings; a schema never coerces them into booleans. - Date-like and timestamp scalars are strings containing their authored text. Quote ambiguous values when authoring for other YAML tools with different scalar-resolution policies. - `null`, `Null`, `NULL`, `~`, and an empty scalar are null. Quoted forms are strings. Absence, null, and empty containers are distinct. - YAML integer spellings supported by go-yaml include decimal, `0x` hexadecimal, `0o` octal, `0b` binary, legacy leading-zero octal, and separators. Decimal floats may use a sign, exponent, leading dot, trailing dot, or separators. Numeric scalar resolution follows go-yaml, with plain JSON number spellings additionally recognized beyond machine numeric range. The adapter preserves decimal precision as JSON numbers rather than converting through machine floating point. NaN and infinities are errors. Explicitly tagged floats must have valid numeric syntax before normalization; empty values or incomplete forms such as `!!float e3` are errors. - Anchors and aliases are accepted and resolved to values. Cycles are errors. Anchors, aliases, comments, and formatting are serialization details. - Standard mapping, sequence, string, integer, float, boolean, null, and timestamp tags have the representations above. Custom tags, binary values, sets, ordered-map tags, complex keys, and merge keys have no representation in this completed-document profile. Resolve authoring composition before this boundary; a quoted string key `"<<"` remains an ordinary extension key. This is an explicit profile, not a promise to accept every YAML feature. Consumers using other parsers should test the same cases before claiming compatibility. Native library limits remain implementation safeguards, not additional domain constraints. ## Structural and semantic boundaries All defined fields are validated when present. Objects permit extensions unless a field is itself a named-record mapping, whose values must satisfy that record schema. For example, every item in `collections` is a collection, not arbitrary document metadata. Put metadata on the envelope, collection, or entry. The semantic inventory is in [the initial inventory](inventory.md). The harness checks entry-ID uniqueness within each glossary collection using exact string comparison. Party-ID uniqueness is already covered by duplicate-key rejection. The initial contract defines no cross-document referential-integrity rule. Structural success alone does not prove these semantic rules or that a consumer can use the document for a particular operation. ## Offline schema use and editors Every schema declares Draft 2020-12 and an immutable release `$id`. The harness registers the bundled schemas under those IDs before compiling them and rejects unresolved resource loads. The schema engine supplies the standard meta-schema; ordinary validation performs no network requests. Other validators can likewise register local files under their `$id` values. Keep the complete schema directory from one release together. Configure editors externally to associate document paths with a local schema or its immutable raw URL. Operator documents use `schema_version`; they do not need a `$schema` field. Schema validation supplies editor feedback for known fields. Optional tooling can warn about likely misspellings without rejecting extensions.