Contracts & knowledge · W3C constraint language
SHACL
Check RDF graph data against explicit shapes and constraints.
What it helps you do
Make graph-data expectations inspectable and report where actual data violates them.
Starting knowledge: Familiarity with RDF triples, identifiers, and typed literals is useful.
- Identify the target nodes to validate.
- Specify property constraints such as value type and cardinality.
- Review validation results against the correct data and shapes versions.
The problem it came from
W3C published SHACL as a Recommendation in 2017. It defines validation of RDF data graphs against conditions represented in a shapes graph.
Shapes can also document the graph structures a system expects. They are distinct from the domain facts being checked.
Work through an example
@prefix ex: <https://example.org/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
ex:WorkshopShape a sh:NodeShape ;
sh:targetClass ex:Workshop ;
sh:property [
sh:path ex:title ;
sh:minCount 1 ;
sh:datatype xsd:string
] .- The target identifies Workshop nodes.
- The shape requires at least one string title.
- It does not prove the title accurately names a real workshop.
Where it helps. Where it stops.
Use it when
- A knowledge graph must meet explicit structural requirements.
- Vocabulary data is exchanged between systems that expect particular properties.
Potential benefits
- A validation report can locate concrete graph-data violations.
- Separate shapes make expectations easier to review and reuse.
Limits and common mistakes
- A conforming graph may contain false statements.
- Validation coverage depends on target selection and the supplied shapes; unvalidated nodes do not become valid by omission.
The prompt below asks for this structure. It does not guarantee accuracy, complete coverage, better learning, or conformance to a standard. Treat those outcomes as separate checks.
Practise the judgment
Try a choice, inspect a boundary, then explain a case yourself. Hints and answers are available whenever you need them.
A shape has no target that selects the intended workshop nodes. What can go wrong?
Hint
Ask what was actually examined.
Explained answer
Best answer for this case: Those nodes may never be checked
Coverage depends on which nodes receive validation. Missing targets can make a report misleadingly quiet.
A graph passes the supplied shapes. What can you conclude?
Hint
Conformance is relative to constraints and targets.
Explained answer
Best answer for this case: The targeted data satisfied the checked constraints
Constraint validation does not independently establish truth or provenance.
What else should accompany a “graph validated” claim?
Hint
Could someone reproduce exactly what was checked?
Explained answer & self-review rubric
Record the data graph, shapes graph, their versions, the target scope, validator, and actual report. Explain which semantic or factual questions were not checked.
- Identify inputs
- State coverage
- Preserve the actual validation evidence
Take it into your own work
Manual template
Use this structure yourself, with a colleague, or in your preferred writing tool.
# Graph validation brief
Data graph and version:
Shapes graph and version:
Target nodes:
Required properties:
Value and cardinality constraints:
Severity and expected report:
Known limits outside validation:
Review the result
- Are the intended nodes targeted?
- Are data and shapes versions recorded?
- Are structural findings kept separate from truth claims?
Use this approach with your own AI tool
Help me apply SHACL to the material below.
Reader and existing knowledge: [describe]
Task and desired outcome: [describe]
Use these principles: Identify the target nodes to validate.; Specify property constraints such as value type and cardinality.; Review validation results against the correct data and shapes versions..
Preserve source facts, identifiers, quantities, conditions, exceptions, and uncertainty.
Separate supplied facts from assumptions. Ask for missing information instead of inventing it.
Explain your representation choices and provide a review checklist. Do not claim formal compliance or correctness from formatting alone.
Material: [paste only information you are permitted to share]Go to the source
History and the underlying approach are grounded in these references. Examples, prompts, and practice cases here are original educational adaptations. Edition-specific details should be checked against the referenced publication.
Last editorial review: 2026-10-24. An overview is not certification, and this guide is not a reproduction of a standard.