rdf-validate-shacl alternatives and similar libraries
Based on the "Validation" category.
Alternatively, view rdf-validate-shacl alternatives based on common mentions on social networks and blogs.
-
FormValidation
DISCONTINUED. The best @jquery plugin to validate form fields. Designed to use with Bootstrap + Zurb Foundation + Pure + SemanticUI + UIKit + Your own frameworks. -
Validator, for Bootstrap 3
DISCONTINUED. A user-friendly HTML5 form validation jQuery plugin for Bootstrap 3 -
BootstrapValidator
DISCONTINUED. For anyone who want to use the previous version (BootstrapValidator)
CodeRabbit: AI Code Reviews for Developers
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of rdf-validate-shacl or a related project?
README
rdf-validate-shacl
Validate RDF data purely in JavaScript. An implementation of the W3C SHACL specification on top of the RDFJS stack.
We provide a SHACL playground based on this library.
Usage
The library only handles SHACL validation and not data loading/parsing. The following example uses rdf-utils-fs for this purpose. For more information about handling RDF data in JavaScript, check out Get started with RDF in JavaScript.
The validation function returns a ValidationReport
object that can be used
to inspect conformance and results. The ValidationReport
also has a
.dataset
property, which provides the report as RDF data.
const fs = require('fs')
const factory = require('rdf-ext')
const ParserN3 = require('@rdfjs/parser-n3')
const SHACLValidator = require('rdf-validate-shacl')
async function loadDataset (filePath) {
const stream = fs.createReadStream(filePath)
const parser = new ParserN3({ factory })
return factory.dataset().import(parser.import(stream))
}
async function main() {
const shapes = await loadDataset('my-shapes.ttl')
const data = await loadDataset('my-data.ttl')
const validator = new SHACLValidator(shapes, { factory })
const report = await validator.validate(data)
// Check conformance: `true` or `false`
console.log(report.conforms)
for (const result of report.results) {
// See https://www.w3.org/TR/shacl/#results-validation-result for details
// about each property
console.log(result.message)
console.log(result.path)
console.log(result.focusNode)
console.log(result.severity)
console.log(result.sourceConstraintComponent)
console.log(result.sourceShape)
}
// Validation report as RDF dataset
console.log(report.dataset)
}
main();
Validator options
The SHACLValidator
constructor accepts an optional options object as second
parameter. The available options are:
factory
: RDF/JS data factory (must have a.dataset()
method)maxErrors
: max number of errors after which the validation process should stop. By default, it only stops after all the errors are found.
Running the tests
$ npm test
Regenerating vocabularies
The SHACL vocabulary is imported from @zazuko/rdf-vocabularies
and
pre-parsed in src/vocabularies/shacl.js
.
After updating the @zazuko/rdf-vocabularies
dependency, run
npm run generate-vocabularies
to regenerate the pre-parsed vocabulary.
Limitations
rdf-validate-shacl does not support SHACL-SPARQL constraints
About
rdf-validate-shacl was originally a fork of shacl-js meant to make it compatible with RDF/JS libraries. Since then, we dropped support for the SHACL-JS extension and adapted the API to suit our needs.