zazuko / rdf-validate-shacl

Validate RDF data purely in JavaScript. An implementation of the W3C SHACL specification on top of the RDFJS stack.
MIT License
98 stars 13 forks source link

False negative when validating XoneConstraintComponent #56

Closed tpluscode closed 3 years ago

tpluscode commented 3 years ago

shapes graph

@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix schema: <http://schema.org/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix ex: <http://example.com/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix dash: <http://datashapes.org/dash#> .

ex:PersonShape
  a sh:Shape ;
  sh:targetClass schema:Person ;
  rdfs:label "Person" ;
  sh:xone (
    [
      rdfs:label "Full name" ;
      sh:property [
        sh:name "Full name" ;
        sh:path ex:fullName ;
        # sh:minCount 1 ;
        sh:maxCount 1 ;
      ]
    ]
    [
      rdfs:label "First & last name" ;
      sh:property [
        sh:name "First name";
        sh:path ex:firstName ;
        # sh:minCount 1 ;
        sh:maxCount 1 ;
      ] ,
      [
        sh:name "Last name" ;
        sh:path ex:lastName ;
        # sh:minCount 1 ;
        sh:maxCount 1 ;
      ]
    ]
  ) ;
.

data graph

{
  "@context": {
    "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
    "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
    "xsd": "http://www.w3.org/2001/XMLSchema#",
    "schema": "http://schema.org/",
    "foaf": "http://xmlns.com/foaf/0.1/",
    "vcard": "http://www.w3.org/2006/vcard/ns#"
  },
  "@id": "http://example.com/John_Doe",
  "@type": "schema:Person",
  "http://example.com/fullName": "John Doe"
}

expected behaviour

The data should be valid.

actual behaviour

A violation is reported by sh:XoneConstraintComponent. It goes away when sh:minCount is uncommented

other

See this reply by @HolgerKnublauch and this exact example in Shaperone playground

tpluscode commented 3 years ago

Oh wait, maybe this is correct after all. 🤦

This is exactly what Holger wrote

Having no sh:minCount means that both branches will always be satisfied

which is exactly the Xone violation

martinmaillard commented 3 years ago

Can I close this?