Skip to content

NodeJs project for validating Sturctured Data with ShEx and SHACL. Is mainly used in a form of a bundle as a core part of the Schema.org Content Checker demo (https://www.gnomus042.com/).

License

Notifications You must be signed in to change notification settings

Gnomus042/schema_validation_core

Repository files navigation

Schema.org Content Checker CORE

NodeJs project for validating Sturctured Data with ShEx and SHACL. Is mainly used in a form of a bundle as a core part of the Schema.org Content Checker demo.

Main tasks:

Usage example

ShEx validation

const ShexValidator = require('./schemarama/shexValidator').Validator;
const annotations = {
    description: 'http://www.w3.org/2000/01/rdf-schema#comment',
    severity: 'http://www.w3.org/2000/01/rdf-schema#label'
}
// shapes - JSON object with shapes in ShEx format
const validator = new ShexValidator(shapes, {annotations: annotations});
const startShape = 'http://schema.org/validation#ValidSchemaThing'
// data - string or n3.js Store, that should be validated
validator.validate(data, startShape, {baseUrl: 'http://example.org/test'}) 
    .then(report => report.failures.forEach(failure => console.log(failure)));

SHACL validation

const ShaclValidator = require('./schemarama/shaclValidator').Validator;
const annotations = {
    description: 'http://www.w3.org/2000/01/rdf-schema#comment',
    severity: 'http://www.w3.org/2000/01/rdf-schema#label'
}
// shapes - JSON object with shapes in ShEx format
const validator = new ShaclValidator(shapes, {annotations: annotations});
// data - string or n3.js Store, that should be validated
validator.validate(data, {baseUrl: 'http://example.org/test'}) 
    .then(report => report.failures.forEach(failure => console.log(failure)));

Cli mode

To use this project as a cli, first you need to do an npm install

Parsing:

node cli --parse
Required arguments:
--input <file path> - path to the input file.
Optional arguments:
--output <file path> - path to the output file. If not specified, output will be printed to the console.
--format <format> - one of the output formats. Available formats: nquads|ntriples|turtle|trig. 'nquads' is used by default.

ShEx validation:

node cli --validate
Required arguments:
--shex <file path> - path to ShEx shapes. Could be either local or URL
--input <file path> - path to the input file.
--target <shapeURI> - target shape, e.g. http://example.org/shex#Thing.
Optional arguments:
--output <file path> - path to the output file. If not specified, output will be printed to the console.
--base <URI> - base data URI (@id). If not specified, random URI will be used.
--annotations <file path> - path to the annotation correspondence file, in JSON format, where keys are keys in the failure report object and values are annotation predicates. If not specified, annotations will be ignored.

SHACL validation:

node cli --validate Required arguments:
--shex <file path> - path to SHACL shapes. Could be either local or URL
--input <file path> - path to the input file.
Optional arguments:
--output <file path> - path to the output file. If not specified, output will be printed to the console.
--base <URI> - base data URI (@id). If not specified, random URI will be used.
--annotations <file path> - path to the annotation correspondence file, in JSON format, where keys are keys in the failure report object and values are annotation predicates. If not specified, annotations will be ignored.
--subclasses <file path> - additional triples that should be added to data for every validation. Originally used for adding schema.org subclasses structure to the data.

About

NodeJs project for validating Sturctured Data with ShEx and SHACL. Is mainly used in a form of a bundle as a core part of the Schema.org Content Checker demo (https://www.gnomus042.com/).

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published