When instance data contains a xsd:gYear literal in where the year value contains more than 4 digits, and a SHACL PropertyShape uses a DatatypeConstraintComponent', the SHACL validation report incorrectly marks this value as an error: with this message:
Value does not have datatype <http://www.w3.org/2001/XMLSchema#gYear>.
I assume there are similar issues with other XSD date-like datatypes, for sure with gYearMonth (see in this example code), etc.
The issue is caused by a RegExp that only allows 4 digits for a year in the 'ref-validate-datatype' module, see here. I've created a pull request to implement the correct RexExp.
How to reproduce
import fs from 'fs'
import factory from 'rdf-ext'
import ParserN3 from '@rdfjs/parser-n3'
import SHACLValidator from 'rdf-validate-shacl'
import assert from 'assert'
async function loadDataset (filePath) {
const stream = fs.createReadStream(filePath)
const parser = new ParserN3({ factory })
return factory.dataset().import(parser.import(stream))
}
const shapes = await loadDataset('shapes.ttl')
const data = await loadDataset('data.ttl')
const validator = new SHACLValidator(shapes, { factory })
const report = await validator.validate(data)
if (report.conforms === false) {
console.error('Expected report to validate, it did not:')
for (const result of report.results) {
console.error(`'${result.message} on path ${result.path}`)
}
}
When instance data contains a xsd:gYear literal in where the year value contains more than 4 digits, and a SHACL PropertyShape uses a DatatypeConstraintComponent', the SHACL validation report incorrectly marks this value as an error: with this message:
The W3C XML Schema Definition Language (XSD) 1.1 Part 2: Datatypes defines a gYear with this lexical space, so literals like '10000' are valid gYear literal values:
I assume there are similar issues with other XSD date-like datatypes, for sure with gYearMonth (see in this example code), etc.
The issue is caused by a RegExp that only allows 4 digits for a year in the 'ref-validate-datatype' module, see here. I've created a pull request to implement the correct RexExp.
How to reproduce
Content of file
data.ttl
Content of file
shapes.ttl