rdf-validate-shacl
Advanced tools
Comparing version 0.5.5 to 0.5.6
{ | ||
"name": "rdf-validate-shacl", | ||
"version": "0.5.5", | ||
"version": "0.5.6", | ||
"description": "RDF SHACL validator", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -7,2 +7,3 @@ import clownface from 'clownface' | ||
const error = debug('validation-enging::error') | ||
const defaultMaxNodeChecks = 50 | ||
@@ -14,2 +15,3 @@ class ValidationEngine { | ||
this.maxErrors = options.maxErrors | ||
this.maxNodeChecks = options.maxNodeChecks === undefined ? defaultMaxNodeChecks : options.maxNodeChecks | ||
this.initReport() | ||
@@ -23,3 +25,3 @@ this.recordErrorsLevel = 0 | ||
clone() { | ||
return new ValidationEngine(this.context, { maxErrors: this.maxErrors }) | ||
return new ValidationEngine(this.context, { maxErrors: this.maxErrors, maxNodeChecks: this.maxNodeChecks }) | ||
} | ||
@@ -29,2 +31,3 @@ | ||
const { rdf, sh } = this.context.ns | ||
this.nodeCheckCounters = {} | ||
@@ -74,2 +77,14 @@ this.reportPointer = clownface({ | ||
if (this.maxNodeChecks > 0) { | ||
// check how many times we have already tested this focusNode against this shape | ||
const id = JSON.stringify([focusNode, shape.shapeNode]) | ||
const nodeCheckCounter = this.nodeCheckCounters[id] === undefined ? 0 : this.nodeCheckCounters[id] | ||
if (nodeCheckCounter > this.maxNodeChecks) { | ||
// max node checks reached, so bail out | ||
return false | ||
} | ||
// increment check counter for given focusNode/shape pair | ||
this.nodeCheckCounters[id] = nodeCheckCounter + 1 | ||
} | ||
const valueNodes = shape.getValueNodes(focusNode, dataGraph) | ||
@@ -76,0 +91,0 @@ let errorFound = false |
63854
1602