TopQuadrant / shacl

SHACL API in Java based on Apache Jena
Apache License 2.0
215 stars 61 forks source link

sh:minCount 0 not causing constraint to be ignored #132

Closed beaudet closed 2 years ago

beaudet commented 2 years ago

Greetings,

The following property constraint is conveniently executing, but I'm wondering if that might change in the future as the SHACL validator might not be following the SHACL spec:

    sh:property [
        sh:path crm:P46_is_composed_of;
        sh:class crm:E22_Human-Made_Object;
        sh:minCount 0;
    ];

which says:

4.2.1 sh:minCount
sh:minCount specifies the minimum number of value nodes that satisfy the condition. 
If the minimum cardinality value is 0 then this constraint is always satisfied and so may be omitted.

Do you think the spec is suggesting that the validator should ignore the constraint altogether rather than validating the sh:class and reporting that as a validation failure despite the minCount == 0?

HolgerKnublauch commented 2 years ago

The spec writes about "this constraint" which is only about sh:minCount 0. It does not say that other constraints that happen to be at the same property shape should also be ignored.

So you can safely use sh:minCount 0 if you want to, and the implementation is correct and will continue to check the sh:class constraint.

beaudet commented 2 years ago

awesome, thanks.