rdf-ext/shacl-engine

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

Opened this issue · 3 comments

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

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('...')] }])

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.

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.