TopQuadrant / shacl

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

Shacl validation fails with spec 2017-04-04 while passes with 2017-07-20 #105

Closed umbreak closed 3 years ago

umbreak commented 3 years ago

While the W3C shacl of Shacl points to this url: https://www.w3.org/ns/shacl-shacl and the version there is 2017-04-04, the one provided here (rdf/shacl.ttl) has a date of 2017-07-20.

This is not concerning on itself. However I've tried to validate a schema against the shacl of shacl and it does pass when using your version but it doesn't using the one on the W3C website:

{
  "@context": [
    "https://bluebrain.github.io/nexus/contexts/shacl-20170720.json",
    {
      "some": "https://example.com/some/"
    }
  ],
  "@type": "some:Schema",
  "id": "some:myschema",
  "shapes": [
    {
      "@id": "some:MyShape",
      "@type": "sh:NodeShape",
      "nodeKind": "sh:BlankNodeOrIRI",
      "targetClass": "some:Custom",
      "property": [
        {
          "@id": "some:NameProperty",
          "path": "some:name",
          "datatype": "xsd:string",
          "minCount": "wrong-value"
        }
     ]
    }
  ]
}

The field which should not satisfy the SHACL of SHACL definition is: "minCount": "wrong-value"

However it passes:

// Passes validation
ValidationUtil.validateModel(schema, SHACLSystemModel.getSHACLModel, true)
// Fails validation
ValidationUtil.validateModel(schema, shacl_04_04_model, true)
HolgerKnublauch commented 3 years ago

I believe you are comparing two different scenarios. The SHACL-SHACL (shsh) graph is very different from the SHACL (sh) graph. shsh contains shapes to validate SHACL definitions, while sh does not define such constraints, so will not produce validation results.

The shsh graph was added to the W3C site late in the process because a reviewer suggested we create it as an example of using SHACL, here: to validate itself.

umbreak commented 3 years ago

Thanks. After a bit of fighting I understood that myself. I was a bit puzzled by the difference. Now it is clear.

Thanks for the clarification. I close this ticket.