2026-11-28 19:44:30 +00:00
|
|
|
# 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
|
2026-11-29 04:33:59 +00:00
|
|
|
go run ./cmd/validate -schema rpg/party@0.1.0 rpg/party/v0.1.0/examples/party.yml
|
|
|
|
|
go run ./cmd/validate -schema glossary@0.1.0 glossary/v0.1.0/examples/weather.yml
|
2026-11-28 19:44:30 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
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
|
2026-11-29 04:33:59 +00:00
|
|
|
/tmp/schemas-validate -root /path/to/distribution -schema glossary@0.1.0 /path/to/completed-glossary.yml
|
2026-11-28 19:44:30 +00:00
|
|
|
```
|
|
|
|
|
|
2026-11-29 04:33:59 +00:00
|
|
|
Select exactly `name@version` from [catalog.json](../catalog.json). All supplied
|
|
|
|
|
documents are validated against that definition, including their document marker.
|
|
|
|
|
Separate invocations select different schemas. Success reports the selected version.
|
2026-11-28 19:44:30 +00:00
|
|
|
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
|
2026-11-29 04:33:59 +00:00
|
|
|
validated; 2 means invalid command usage, missing/unknown selection, or an unusable distribution. Errors identify
|
2026-11-28 19:44:30 +00:00
|
|
|
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.
|
|
|
|
|
|
2026-11-28 23:25:12 +00:00
|
|
|
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)
|
2026-11-28 19:44:30 +00:00
|
|
|
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.
|
2026-11-28 23:25:12 +00:00
|
|
|
Explicitly tagged floats must have valid numeric syntax before normalization;
|
|
|
|
|
empty values or incomplete forms such as `!!float e3` are errors.
|
2026-11-28 19:44:30 +00:00
|
|
|
- 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
|
|
|
|
|
|
2026-11-29 04:33:59 +00:00
|
|
|
Every schema declares Draft 2020-12 and an exact versioned canonical `$id`. The harness
|
2026-11-28 19:44:30 +00:00
|
|
|
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.
|
2026-11-29 04:33:59 +00:00
|
|
|
Bundle the selected version directories and their exact referenced dependencies
|
|
|
|
|
from one selected CalVer snapshot, with their adjacent semantic documents. Configure editors
|
|
|
|
|
externally to associate document paths with a local schema or its canonical versioned
|
2026-11-28 19:44:30 +00:00
|
|
|
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.
|