neosemantics
neosemantics copied to clipboard
SHACL datatype restriction problem
SHACL datatype restriction is not working in following situation: Import SHACL restriction (minVal is integer between 0 and 100):
call n10s.validation.shacl.import.inline('
@prefix dtc: <http://ttt/#> .
@prefix vs: <http:/ttt/vs#>.
@prefix sh: <http://www.w3.org/ns/shacl#> .
dtc:ObjectShape
a sh:NodeShape;
sh:targetClass vs:Object;
sh:property [
sh:path vs:minVal;
sh:datatype xsd:integer ;
sh:minInclusive 0;
sh:maxInclusive 100;
] ;
.
','Turtle')
... add trigger:
CALL apoc.trigger.add('shacl-validate','call n10s.validation.shacl.validateTransaction($createdNodes,$createdRelationships, $assignedLabels, $removedLabels, $assignedNodeProperties, $removedNodeProperties)', {phase:'before'})
Execute bad-query for checking:
CREATE(s:Object)
SET s.minVal = 200
... got:
Error executing triggers {shacl-validate=Failed to invoke procedure `n10s.validation.shacl.validateTransaction`: Caused by: n10s.validation.SHACLValidationException: {validationResult={severity=http://www.w3.org/ns/shacl#Violation, propertyShape=http://www.w3.org/ns/shacl#MinExclusiveConstraintComponent, shapeId=bnode://id/node1evs90kpex1, focusNode=12, resultPath=minVal, offendingValue=200, nodeType=Object, resultMessage=}}}
Execute:
CREATE(s:Object)
SET s.minVal = "200"
... got:
Error executing triggers {shacl-validate=Failed to invoke procedure `n10s.validation.shacl.validateTransaction`: Caused by: n10s.validation.SHACLValidationException: {validationResult={severity=http://www.w3.org/ns/shacl#Violation, propertyShape=http://www.w3.org/ns/shacl#DatatypeConstraintComponent, shapeId=bnode://id/node1evs90kpex1, focusNode=13, resultPath=minVal, offendingValue=200, nodeType=Object, resultMessage=property value should be of type integer}}}
... but execute:
CREATE(s:Object) SET s.minVal = "just-string-value"
... and get OK
Added 1 label, created 1 node, set 1 property, completed after 3 ms.
... but expected exception.