Skip to content

SHACL Core components

What constraint components are supported and what each one asserts.

Target selectors — which nodes to validate

ComponentEffect
sh:targetClass <C>Pick every instance of class C as a focus node.
sh:targetNode <iri>Pick a specific IRI as a focus node.
sh:targetSubjectsOf <p>Pick every subject of predicate p.
sh:targetObjectsOf <p>Pick every object of predicate p.

Cardinality and shape

ComponentAsserts
sh:minCount nAt least n values on the path.
sh:maxCount nAt most n values on the path.

Type constraints

ComponentAsserts
sh:datatype <xsd:string>Value is a literal of the given datatype.
sh:nodeKind sh:IRI / sh:Literal / sh:BlankNode / sh:IRIOrLiteral / sh:BlankNodeOrIRI / sh:BlankNodeOrLiteralValue is of the given RDF node kind.
sh:class <C>Value is an instance of class C.

Value-set constraints

ComponentAsserts
sh:in (a b c)Value is one of the enumerated values.

String constraints

ComponentAsserts
sh:minLength n / sh:maxLength nLength bounds on the literal's lexical form.
sh:pattern "regex"Regex match against the literal's lexical form. Optional sh:flags.

Numeric range

ComponentAsserts
sh:minInclusive n / sh:maxInclusive nInclusive numeric bounds.
sh:minExclusive n / sh:maxExclusive nExclusive numeric bounds.

Composition

ComponentAsserts
sh:property [ … ]Apply the property-shape body to a property path.
sh:path <p>The path the property shape targets.
sh:and, sh:or, sh:not, sh:xoneBoolean composition of nested shape references.

Severity

ComponentEffect
sh:severity sh:Info / sh:Warning / sh:Violation (default)Choose the result severity reported in resultSeverity.

Beyond SHACL Core

ComponentStatus
SHACL-SPARQL constraint components (sh:sparql, sh:select, sh:ask)Shipped. Reachable via pgrdf.validate(…, mode => 'pgrdf') — the pgRDF-native SHACL-SPARQL handler, the authoritative gate for custom constraints. It evaluates sh:sparql / sh:select / sh:ask constraints directly against the hexastore (no N-Triples rehydrate) and returns the same sh:ValidationReport-shape JSONB with the correct W3C verdict. The alternate mode => 'sparql' (rudof SparqlEngine) reaches the engine but is E-014-buggy — it returns the wrong verdict on common topologies and is not a trusted gate. See SHACL-SPARQL.

The full SHACL Core component set above is shipped — including property paths in sh:path (the same SPARQL property-path engine, alternation / sequence / inverse).

Conformance + tests

mode => 'native' is W3C SHACL Core, conformant against the W3C SHACL Core test suite at 25/25. The engine is exercised end-to-end by tests/regression/sql/71-shacl-real.sql, and the W3C SHACL manifest runner is wired into CI under tests/w3c-shacl/ (part of the 294 pgrx + 93 pg_regress + 51 W3C-SPARQL + 25 W3C SHACL Core + 3 LUBM test bar).

MIT licensed. Documentation for pgRDF — built with VitePress, served via GitHub Pages.