Validate a model#
This guide checks an OSDL document against the schemas and the component libraries it uses. Validation is mechanical JSON Schema checking; no engine is required.
Two phases#
Model validation always has two phases:
- The document is validated against the model schema. This checks structure, but treats every component's
paramsobject as opaque. - Each component's
paramsis validated against the parameter schema published in its type's library definition, with the core schema registered so shared value forms resolve.
A document can pass phase one and fail phase two. Phase two is what catches a misspelled parameter or a distribution where a scalar is required.
Run the repository validator#
The OSDL repository ships a validator that performs both phases over the specification's own schemas, libraries, and examples. From a checkout of github.com/simcrafthq/osdl, with Node.js 22:
bash validate.shThe command compiles all six schemas, checks each library document, and validates every example in both phases. When the Lean toolchain is available it also builds the reference machine and checks the conformance catalogue; set OSDL_REQUIRE_LEAN=1 to fail when Lean is missing, which is what continuous integration does.
Validate your own documents#
Any JSON Schema draft 2020-12 validator works for phase one. Point it at the published model schema and your document:
npx ajv-cli validate --spec=draft2020 -s schemas/osdl.schema.json -d my-model.osdl.jsonFor phase two, validate each component's params against the matching params schema in the library definition, registering osdl.schema.json so $ref references to core value forms resolve.
Two rules save debugging time:
- Identifiers match
^[A-Za-z_][A-Za-z0-9_-]*$, and component ids must be unique within their scope. - A parameter reference to an undeclared name, or a connection to a port that does not exist, is a load-time error even in a schema-valid document. Engines check references when they prepare the model.
Read more#
- Names and references in the specification.
- The library definition schema, the contract for phase two.