Hi Kyle,
sh:message worked for use in a similar situation.
https://www.w3.org/TR/shacl/#message

Best Merlin
________________________________
Von: Kyle Lawlor-Bagcal <[email protected]>
Gesendet: Thursday, September 8, 2022 11:11:22 PM
An: [email protected] <[email protected]>
Betreff: Is it possible to get more info out of the shacl validation messages?

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