verifiedPillar 4 — Validation (SHACL Core)
pgrdf.validate(data_graph_id BIGINT, shapes_graph_id BIGINT, mode TEXT DEFAULT 'native') → JSONB validates the data graph against the shapes graph and returns a W3C sh:ValidationReport-shape JSONB document.
The default mode => 'native' is W3C SHACL Core — the full SHACL Core constraint set, conformant against the W3C SHACL Core test suite at 25/25. Backed by the shacl crate (0.3.2) from the rudof project. The mode argument also exposes 'pgrdf' — the shipped, authoritative SHACL-SPARQL gate, the pgRDF-native handler that evaluates sh:sparql / sh:select / sh:ask custom constraints directly against the hexastore and returns the correct W3C verdict. The alternate 'sparql' (rudof SparqlEngine) reaches the engine but carries an open correctness caveat (E-014). See SHACL-SPARQL.
Topics in this pillar
- info Mental model.
- description Worked example — minCount, datatype, nodeKind constraints.
- verified SHACL Core components — what's supported.
- fact_check Report as data — querying violations with regular SQL.
- verified SHACL-SPARQL — the shipped
mode => 'pgrdf'custom-constraint gate (pgRDF-native, authoritative, direct hexastore evaluation); the alternate'sparql'(rudofSparqlEngine) reaches the engine but is E-014-buggy.
At a glance
SELECT pgrdf.validate(1, 2);
-- → { "conforms": false, "results": [ {...}, {...} ] }auto_storiesTraining
Validation is the simplest of the four pillars conceptually — one UDF, one report — but the SHACL Core surface is broad. Take the pages in order:
- info Start with the Mental model — what a shapes graph is, what a validation report is, why this matters.
- description Run the Worked example — minCount + datatype + nodeKind constraint composition, end-to-end in psql.
- verified Read the SHACL Core components reference — what's supported and what's not. Bookmark this page.
- fact_check Then Report as data — SHACL reports are JSONB. Querying violations with regular SQL is the gate-ingestion idiom.
- verified Then SHACL-SPARQL — the shipped
mode => 'pgrdf'gate for custom constraint components defined as embedded SPARQL, the authoritative pgRDF-native handler evaluating them directly against the hexastore; the alternate'sparql'(rudofSparqlEngine) reaches the engine but carries the E-014 caveat.
Learn more
- school Shapes Constraint Language (SHACL) — the W3C recommendation.
- school SHACL Playground — paste a data graph + shapes graph, see the report in your browser. Great for prototyping.
- code rudof project's
shaclcrate — the engine pgRDF wraps for'native'(SHACL Core) and the alternate'sparql'mode (E-014-caveated); the authoritative SHACL-SPARQL'pgrdf'mode is pgRDF-native. - school Knublauch & Kontokostas, Validating RDF Data — book on SHACL by the spec editors.