Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SHACL datatype restriction problem #213

Open
palandlom opened this issue Mar 3, 2021 · 0 comments
Open

SHACL datatype restriction problem #213

palandlom opened this issue Mar 3, 2021 · 0 comments

Comments

@palandlom
Copy link

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.

jbarrasa added a commit that referenced this issue Mar 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant