https://github.com/TopQuadrant/shacl-js
SHACL API in JavaScript
https://github.com/TopQuadrant/shacl-js
Last synced: 7 months ago
JSON representation
SHACL API in JavaScript
- Host: GitHub
- URL: https://github.com/TopQuadrant/shacl-js
- Owner: TopQuadrant
- License: apache-2.0
- Created: 2017-07-15T23:16:32.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-05-10T23:15:52.000Z (over 5 years ago)
- Last Synced: 2025-04-28T09:05:03.071Z (7 months ago)
- Language: JavaScript
- Size: 470 KB
- Stars: 70
- Watchers: 15
- Forks: 18
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-semantic-shapes - shacl-js - commit/TopQuadrant/shacl-js" align="top"> - SHACL API; `Apache` license; `JavaScript`. Recommends migration to `rdf-validate-shacl` ☠️. (SHACL Validators)
README
# SHACL.js [](https://travis-ci.org/TopQuadrant/shacl-js)
## Status
This project is not really actively maintained anymore.
For a more modern JavaScript implementation, see https://github.com/zazuko/rdf-validate-shacl
## Usage
Create a new SHACL validator and load shapes and data to trigger the validation.
The validation function returns a `ValidationReport` object that can be used to inspect conformance rand results.
```javascript
var validator = new SHACLValidator();
validator.validate(data, "text/turtle", shapes, "text/turtle", function (e, report) {
console.log("Conforms? " + report.conforms());
if (report.conforms() === false) {
report.results().forEach(function(result) {
console.log(" - Severity: " + result.severity() + " for " + result.sourceConstraintComponent());
});
}
});
```
## Building for the web
A browser version of the library will be built in the `dist` directory using the gulp `browserify` task.
## Running the tests
Tests can be run using the `test` gulp task.
## Running the web tests
Tests can be run for the browser version running the `test-web` gulp task. This task will generate the test cases from
the node version and start a server in port 3000. The browser version of the library must have been built before running
this task.
## Regenerating vocabularies and libraries
The vocabularies for SHACL and DASH are located in the `vocabularies` directory. After modifying these files, they must
be transformed into library code using the `generate-vocabularies` gulp task.
The JS libraries referenced in the DASH vocabulary can be found in the `shared` directory. They can be bundled into the
library build using the `generate-libraries` gulp command. If they are not bundled, the library will try to de-reference
them using HTTP.