Validation with SHACL
We need easy support to validate requests bodies. Probably a plugin which will add a handler before all requests which we'd want validated.
Which requests do we want validated? By default I expect that all bodies should attempt validation unless there is a flag on the select Resource Shape such as kl:validate false.
The crucial part is finding the right shape(s). I see three possible options:
- Selecting shapes based on the request payload and targets of known shapes
- Declaring concrete shapes graphs to use for a given request on Resource Shape level
- Preload shapes at app start
To retrieve shapes on-demand using SPARQL is expensive so we could favour option 3. For example to load all shapes typed as a hypothetical kl:ValidationShape. They would be loaded early in the app lifecycle and used for requests without requiring further queries. The downside is that app changes to these graphs won't be reflected automatically. Might as well load them solely from the filesystem.