@lde/pipeline-shacl-validator
v0.10.13
Published
SHACL validation for @lde/pipeline
Readme
@lde/pipeline-shacl-validator
SHACL validation for @lde/pipeline.
Validates RDF quads produced by pipeline stages against SHACL shapes, writing per-dataset report files in SHACL validation report format. Shapes can be provided in any RDF serialization (Turtle, JSON-LD, N-Triples etc.).
Usage
import { Pipeline, Stage, SparqlConstructExecutor } from '@lde/pipeline';
import { ShaclValidator } from '@lde/pipeline-shacl-validator';
const validator = new ShaclValidator({
shapesFile: './shapes.ttl',
reportDir: './validation',
});
const pipeline = new Pipeline({
// ...
stages: [
new Stage({
name: 'transform',
executors: new SparqlConstructExecutor({ query: '...' }),
validation: {
validator,
onInvalid: 'write', // 'write' | 'skip' | 'halt'
},
}),
],
});
await pipeline.run();onInvalid options
| Value | Behaviour |
| --------- | ---------------------------------------------------------------- |
| 'write' | Write quads to the output even if validation fails (default) |
| 'skip' | Discard invalid quads silently |
| 'halt' | Throw an error, stopping the pipeline |
Report files
Validation violations are written to <reportDir>/<dataset-iri>.validation.<ext>
as SHACL validation report triples. The output format defaults to Turtle (.ttl)
and can be changed with the reportFormat option:
const validator = new ShaclValidator({
shapesFile: './shapes.ttl',
reportDir: './validation',
reportFormat: 'N-Triples', // 'Turtle' (default) | 'N-Triples' | 'N-Quads'
});