rdf-ext / shacl-engine

A fast RDF/JS SHACL engine
MIT License
30 stars 0 forks source link

Is it possible to have one instance and validate for multiple classes? #18

Open danielbeeke opened 8 months ago

danielbeeke commented 8 months ago

Is it possible to have one instance and validate for multiple classes?

bergos commented 7 months ago

You can pass a list of shapes to the .validate() method.

If you use grapoi, you can directly pass the pointer:

await validator.validate({ dataset }, ptr)

Otherwise, the structure must contain a terms property:

await validator.validate({ dataset }, [{ terms: [rdf.namedNode('...')] }])
danielbeeke commented 7 months ago

Okay, that works. It fails when there is no shape loaded for a class.

file:///home/daniel/Development/centergraph/node_modules/shacl-engine/Validator.js:69
        targets = shape.resolveTargets(shapeContext)
                        ^

TypeError: Cannot read properties of null (reading 'resolveTargets')
    at Validator.validate (file:///home/daniel/Development/centergraph/node_modules/shacl-engine/Validator.js:69:25)

If you agree that that should be fixed, I can do a PR.

bergos commented 7 months ago

I will have a closer look. I'm not sure yet if it should be ignored when the shapes are explicitly given and don't exist.