Open matthieu-fesselier opened 5 years ago
ShEx.Loader.load is a convenience function to load schema and data remotely. If you've already got the data loaded, you should be able to just
let theGraph = someTriplifier(dataObject); # turn the dataObject into triples
ShEx.Loader.load([validationShape], [], [], []).then(function (loaded) {
var db = ShEx.Util.makeN3DB(theGraph);
var validator = ShEx.Validator.construct(loaded.schema, { results: "api" });
var result = validator.validate(db, [{node: dataID, shape: shapeURL}]);
return result;
}).catch(e => console.error(e));
If course the magic is in that someTriplifier()
function I invented. If dataObject
is JSON-LD, you should be able to create an @context
and use toRDF()
from the jsonld npm package.
Thanks for the informations and sorry for the late reply.
The jsonld.toRDF()
returns a string, but in the makeN3DB()
function, you are using a N3Store
, is that right?
How can I create this store? When I try to use N3, I have this error during the validation:
TypeError: db.getTriplesByIRI is not a function
Is it a N3 version problem?
I obviously dropped the ball on this issue, but A. yeah, it looked like a version issue and B. shex.js now uses a 1.0.x N3.js
I didn't manage to use a local object to be validated. This works:
But this throw an error:
Throw
TypeError: Cannot use 'in' operator to search for 'productions' in undefined
Here is dataObject:
Am I doing something wrong?