Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/swift-cars-flow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"rdf-validate-shacl": patch
---

Nodes targeted by `sh:targetNode` should fail validation even if they are not explicitly used in the Data Graph (fixes #107)
9 changes: 1 addition & 8 deletions src/shapes-graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,14 +336,7 @@ export class Shape {
results.addAll(getInstancesOf(dataGraph.node(targetClass), ns))
})

const targetNodes = this.shapeNodePointer.out(sh.targetNode).terms
// Ensure the node exists in data graph before considering it as a validatable target node
.filter((targetNode) => (
dataGraph.dataset.match(targetNode).size > 0 ||
dataGraph.dataset.match(null, targetNode).size > 0 ||
dataGraph.dataset.match(null, null, targetNode).size > 0
))
results.addAll(targetNodes)
results.addAll(this.shapeNodePointer.out(sh.targetNode).terms)

this.shapeNodePointer
.out(sh.targetSubjectsOf)
Expand Down
1 change: 0 additions & 1 deletion test/data/data-shapes/custom/manifest.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
mf:include <uniqueLang-false.ttl> ;
mf:include <multiLevelInheritance.ttl> ;
mf:include <multiLevelInheritanceWithImplicitTarget.ttl> ;
mf:include <targetNodeDoesNotExist.ttl> ;
mf:include <lessThan-moreTypes.ttl> ;
mf:include <circularReferences.ttl> ;
mf:include <and-minCount.ttl> ;
Expand Down

This file was deleted.

32 changes: 0 additions & 32 deletions test/data/data-shapes/custom/targetNodeDoesNotExist.ttl

This file was deleted.