ULB-Darmstadt / shacl-form

HTML5 web component for editing/viewing RDF data that conform to SHACL shapes
https://ulb-darmstadt.github.io/shacl-form/
MIT License
28 stars 5 forks source link

Error validating sh:maxCount on nested objects in the live demo #3

Closed calummackervoy closed 1 year ago

calummackervoy commented 1 year ago

Steps to reproduce

I'm using the following shape:

@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix mud: <https://raw.githubusercontent.com/Multi-User-Domain/vocab/main/mud.ttl#> .
@prefix mudchar: <https://raw.githubusercontent.com/Multi-User-Domain/vocab/main/mudchar.ttl#> .
@prefix mudcharshapes: <https://raw.githubusercontent.com/Multi-User-Domain/vocab/main/shapes/core/mudchar.ttl#> .

mudcharshapes:Character a sh:NodeShape ;
    sh:targetClass mudchar:Character ;
    sh:property mudcharshapes:SpeciesProperty .

mudcharshapes:SpeciesProperty
    sh:path mud:species ;
    sh:name "Species" ;
    sh:description "A Character is not obliged to have a species" ;
    sh:maxCount 1 ;
    sh:class mud:Species .

mudcharshapes:Species a sh:NodeShape ;
    sh:targetClass mud:Species ;
    sh:property [
        sh:name "@id" ;
        sh:description "Enter the urlid of the desired species" ;
        sh:defaultValue "https://raw.githubusercontent.com/Multi-User-Domain/vocab/main/mud.ttl#Human" ;
        sh:minCount 1 ;
        sh:maxCount 1 ;
    ] .

The live demo renders the form for Species correctly. When I select to add a species, it's rendered correctly (the sub-form is shown and the user is only able to add one urlid)

During validation I receive the following error in the console, and the graph isn't validated:

Uncaught (in promise) Error: Cannot find validator for constraint component http://www.w3.org/ns/shacl#MaxCountConstraintComponent

When I remove sh:maxCount from the mudcharshapes:Species NodeShape the error is removed and I can continue (but the user is able to add multiple urlid fields)

s-tittel commented 1 year ago

This seemingly is an issue with the validator I use: https://www.npmjs.com/package/rdf-validate-shacl

If you add an sh:path to your property, it shall work as expected.