Validate OSCAL data against the schema
playbooks/validate-dataNobody has checked this yet
still a draft
Written 2026-10-29 by ktl-librarian (automation).
The full record
- Checks
- none recorded
- Sources
- References
- About
- Graph
- Open this concept in the knowledge graph
- IRI
https://w3id.org/lmodel/oscal/knowledge/playbooks/validate-data- Licence
- CC BY 4.0
- Files
- MarkdownJSON-LDSource on GitHubHistory on GitHub
Validate OSCAL data against the schema
Section titled “Validate OSCAL data against the schema”The _test-linkml-validate recipe in project.justfile, which just test runs, validates each example with linkml-validate. It names the module that defines the example’s class, and the class itself.1 For one file, the command is:
uv run linkml-validate -s src/oscal/schema/oscal_catalog.yaml -C Catalog tests/data/valid/Catalog-001.yamlThe recipe checks a class that its map gives no module against the umbrella, src/oscal/schema/oscal.yaml.
OSCAL’s hyphenated keys
Section titled “OSCAL’s hyphenated keys”A comment in the recipe says that native OSCAL JSON uses hyphenated keys, and that the schema uses underscores. So the recipe rewrites every key of a CNCF fixture with underscores before it validates the fixture as a ComponentDefinitionDocument. tests/test_data.py does the same before it checks a fixture against the generated JSON Schema, and rewrites keys only, never values such as the property name fedramp-high.2 Its docstring says that the keys of the fixtures in tests/data/valid/ and tests/data/invalid/ were migrated to underscores for JSON Schema compatibility.
What each check covers
Section titled “What each check covers”tests/test_data.py checks every example two ways:
- against the class’s definition in the generated JSON Schema,
project/jsonschema/oscal.schema.json, which a test’s docstring calls the schema-level backstop for pattern, strict-enum and other constraints; - by loading it into the generated dataclasses in
oscal.datamodel.oscal, which check less. A comment says that the dataclasses check no minimum, and four counter-examples, such asAtFrequency-zero-period.yaml, load into them without an error.
A generated enum class raises on a value outside its declared set, even for an enum that allows other values, and the tests mark that as an expected failure. A dataclass, on the other hand, stores any string for an Observation’s methods, which problem/invalid/Observation-bad-enum.yaml documents as a known limitation.
What no tool here checks
Section titled “What no tool here checks”The README says that the schema does not check the keys an index, index-has-key or is-unique constraint names, expect tests or has-cardinality counts. So a document that passes it can still fail NIST’s own validators.3 Scope, influences and mappings says what else the schema leaves out.