Skip to content

Support validation of OO-LD schemas and instances (schemas via the OO-LD meta-schema) #90

@simontaurus

Description

@simontaurus

oold should provide validation, mirroring the CI checks now in OO-LD/schema (currently implemented in JS via scripts/validate.mjs), in Python.

Schema validation - validate that a document is a well-formed OO-LD schema by validating it against the OO-LD dialect meta-schema (meta/oold-meta-schema.json, introduced in OO-LD/schema#41): JSON-Schema 2020-12 conformance plus well-formed x-oold-* keywords (x-oold-range, x-oold-ref, x-oold-multilang-*, x-oold-instance-rdf-type, x-oold-reverse-*, ...).

Instance validation - validate an OO-LD instance against its OO-LD schema, resolving the schema via the spec's Schema Instances rules ($schema -> @context URL -> @type). The schema must permit $schema and @context as instance members (the additionalProperties: false caveat).

Approaches / libraries to consider:

  • jsonschema (Python) - direct JSON-Schema 2020-12 validation of instances against their schema, and of schemas against the OO-LD meta-schema. The most direct mapping of the JS/ajv CI.
  • pydantic - oold already generates pydantic models (via datamodel-code-generator); instance validation can run by parsing data into the generated model. Fits the code-as-schema / typed-object route and ties into object-graph binding (Add oold-python to the tutorial (object-graph binding examples) oold-tutorial#10).
  • check-json-schema-meta - the tool used in the tutorial; it reads the instance-side $schema, fetches the schema and validates. Consider reusing or aligning with it so the tutorial tooling and oold stay consistent.

Suggested API: oold.validate_schema(...) and oold.validate_instance(...).

Relates to OO-LD/schema#41 (meta-schema), OO-LD/schema#23 (CI), OO-LD/schema#34 (instance -> schema linking), OO-LD/oold-tutorial#10.

Metadata

Metadata

Assignees

Labels

M2Core Features CompleteenhancementNew feature or request

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions