ejp-rd-vp / resource-metadata-validator

0 stars 0 forks source link

Improve validation messages, especially when a validation error is experienced. #1

Open henrietteharmse opened 2 years ago

henrietteharmse commented 2 years ago

Currently there is no why to provide a concise error message when validation fails. I.e., if we use the organization shape and data that is missing is thedct:title for organisation:

@prefix : <http://purl.org/ejp-rd/metadata-model/v1/example-rdf/> .
@prefix dct:   <http://purl.org/dc/terms/> .
@prefix foaf:  <http://xmlns.com/foaf/0.1/> .

:ErdriDOR  a  foaf:Organisation ;
  dct:spatial  :ErdriDORLocation ;
  foaf:page    <https://eu-rd-platform.jrc.ec.europa.eu/erdridor/> .

:ErdriDORLocation a dct:Location ;
  dct:title  "Italy" .

with shape mapping, it results in this short message:

:ErdriDOR@!:organisationShape when detail=false. The ! indicates that there is an issue with the organisationShape. However, it does not tell you why validation failed. This is the intended purpose of detail=true. But this currently returns this very unhelpful message:

:ErdriDOR@!:organisationShape
   # Error matching expression.
   #  Error: es.weso.rbe.NonNullableError: Required properties not found: <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>{0,0},dct:title,dct:description*,dct:spatial*,foaf:page*
   # Regular expression: <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>,dct:title,dct:description*,dct:spatial*,foaf:page*
   # Properties found: {| <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> -> 1, dct:spatial -> 1, foaf:page -> 1 |}
   # Extra symbols: dct:title/1 
   # Open?: false
   # 
   #  Attempt: Attempt: [<http://purl.org/ejp-rd/metadata-model/v1/example-rdf/ErdriDOR>,<http://purl.org/ejp-rd/metadata-model/v1/shex/organisationShape>]
   # path:  
   #  Candidate line:
   #  Candidate line:
   # <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Organisation> as <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>/[<http://xmlns.com/foaf/0.1/Organisation>]

This messages comes form the underlying Shex validation library used. Currently there seems to be no easy way to improve these validation error messages. See this issue.

labra commented 2 years ago

Thanks for using the ShEx-s library. Your are right that the current natural language description of the errors should be improved.

There is also the possibility that the generated result shape map in ShEx-s is generated in JSON which could later be converted to a more helpful message if you want.