In-browser dataset validation.
Validating data sets against the rules listed here within a terminal or browser.
- Check license: Look for DCAT licenses
Fetches the page using fetch-ponyfill Check for
Cache-Control,ETagHTTP headers.CORS detection: Is only in header if CORS is supported. Detect
Access-Control-Allow-OriginHTTP header.
- Check if RDF1.1: Parse with ldfetch
- Maximum use of standards
Fragmented data: Check for hydra links and timestamps
European DCAT-AP standard
First install the package:
npm install sfvalidator
Then require it and start validating:
constsfv=require("sfvalidator")sfv.validate_url("https://www.example.com").then(result=>{console.log(result);}Install the package globaly:
npm install -g sfvalidator
Now you are able to run:
sfvalidator <URL>
sfvalidator --file <file-path>
Firstly install or download the module.
Secondely install browserify:
npm install -g browserifyThen use browserify to bundle the module and its dependencies:
browserify <path-to-module>/lib/browserify-validator.js -o bundle.jsNow you are able to include this bundle as a script in your webpage and use it:
<script src="bundle.js"></script> <script> validator = new window.sfvalidator(); validator.validate_url("https:://www.example.com").then(result => { console.log(result); } </script>
See the example folder for a more extensive example.
{Accessible: {first_attempt: Score,seconde_attempt: Score},License: Score,Headers: {Cache: Score,ETag: Score,Cors: Score},Rdf: Score,Fragmented: Score,Timestamped: Score}A Score is of this structure:
{
score: int->-1iffailed,0ifnotcheckedor1ifpassed
message: Object->themessagefromthevalidator}The message attribute can have different values when the element passed the validation:
- In case of
accessable,rdfandtimestampedit is just a string. - In case of the
headersit is the value of the header in the returned package. - In case of
licenseandfragmentedit is a list of found licenses and hydra links respectfully.
Run ./bin/validate.js https://linked.open.gent/parking.
Or run ./bin/validate.js --file example/url_examples.txt
Run npm run-script build-example and then run an http server in the example/in-browser folder.
- validate_url: Use this function to validate a url, returns a report. Takes a url as argument in the form of a string.
- validate_headers: This function validates the headers of the package the server sends back. Takes a url as input and returns a promise with a report. This function gets called by
validate_url. - validate_rdf: This function tries to parse the triples present in the data fetched from the url. Takes a url as argument and returns a promise that returns a report. Gets called by
validate_url. - validate_license: Checks if there is a license on the data within the triples. Takes triples and the url as input and returns a score. This function gets called by
validate_rdf. - validate_fragmentation: Searches for hydra links within the triples of the data that have the url as subject. Takes triples and the url as input and returns a score. Gets called by
validate_rdf. - validate_metadata: Checks for the precense of triples with DCT or DCAT metadata predicates about the url. Takes triples and the url as input and returns a score. Gets called by
validate_rdf. - validate_timestamped: Checks if the file is timestamped. Takes triples and the url as input and returns a score. Gets called by
validate_rdf.