> So the failure is clearly due to the "sh:minLength" constraint.

Not so clear :-)

The message is coming from the sh:node because that is the validating constraint.

sh:node can refer to a large and complex collection of constraints.

A sh:node generates a violation only once even for multiple violations of the referred to shape happen.

You could write and be able to reuse share if written as a property shape referred to directly:

"""
regen:C02-ProjectShapeX a sh:NodeShape ;
  sh:targetClass regen:C02-Project ;
  sh:property regen:ProjectTypePropertyShape
.

# Property shapes can have URIs!
regen:ProjectTypePropertyShape
    # rdf:type not necessary
    rdf:type a sh:PropertyShape ;
    sh:path regen:projectType ;
    sh:minCount 1 ;
    sh:maxCount 1 ;
    sh:minLength 1 ;
    sh:datatype xsd:string ;
    sh:group regen:ProjectPageMetadataGroup ;
.
"""

will give

"MinLengthConstraint[1]: String too short: "

If written this way, all the violations of regen:ProjectTypePropertyShape will generate messages so you can get one for minLength and one for maxCount, say, if they both fail.

    Andy

On 08/09/2022 22:11, Kyle Lawlor-Bagcal wrote:
Hello,

I've got the following scenario. Upon running the shacl CLI tool, I'm seeing this as output:

[ rdf:type     sh:ValidationReport ;
   sh:conforms  false ;
   sh:result    [ rdf:type                      sh:ValidationResult ;
                  sh:focusNode                  _:b0 ;
                 sh:resultMessage "Node[<http://regen.network/ProjectBaseFieldsShape>] at focusNode _:Bfdf188221d60ec452edfe2e7c7c855b1" ;
                  sh:resultSeverity             sh:Violation ;
                  sh:sourceConstraintComponent sh:NodeConstraintComponent ;
                  sh:sourceShape regen:C02-ProjectShape ;
                  sh:value                      _:b0
                ]
] .

Where the relevant pieces of the shacl graph are:

@prefix schema: <http://schema.org/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix regen: <http://regen.network/> .
@prefix qudt: <http://qudt.org/schema/qudt/> .
@prefix unit: <http://qudt.org/vocab/unit/> .
@prefix geojson: <https://purl.org/geojson/vocab#> .
@prefix dash: <http://datashapes.org/dash#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

regen:C02-ProjectShape a sh:NodeShape ;
   sh:targetClass regen:C02-Project ;
   sh:node regen:ProjectBaseFieldsShape ;
.

regen:ProjectTypeFieldShape a sh:NodeShape ;
   sh:property [
     sh:path regen:projectType ;
     sh:minCount 1 ;
     sh:maxCount 1 ;
     sh:minLength 1 ;
     sh:datatype xsd:string ;
     sh:group regen:ProjectPageMetadataGroup ;
   ] ;
.

regen:ProjectBaseFieldsShape a sh:NodeShape ;
   sh:node regen:NameFieldShape ;
   sh:node regen:DescriptionFieldShape ;
   sh:node regen:LocationFieldShape ;
   sh:node regen:ProjectSizeFieldShape ;
   sh:node regen:ProjectActivityFieldShape ;
   sh:node regen:ProjectStartDateFieldShape ;
   sh:node regen:ProjectEndDateFieldShape ;
   sh:node regen:ProjectTypeFieldShape ;
.

And the relevant pieces of the data graph (json-ld) under validation are:

{
   "@context": {
     "schema": "http://schema.org/";,
     "regen": "http://regen.network/";,
     "qudt": "http://qudt.org/schema/qudt/";,
     "unit": "http://qudt.org/vocab/unit/";,
     "xsd": "http://www.w3.org/2001/XMLSchema#";,
   },
   "@type": "regen:C02-Project",
   "regen:projectType": ""
}

So the failure is clearly due to the "sh:minLength" constraint. But in the validation error report, that's not so clear. Is there a way to have the fact that the "sh:minLength" constraint was violated here?

Thank you,

Kyle

Reply via email to