# SHACL validation for virtual graphs

**URL:** <https://community.stardog.com/t/shacl-validation-for-virtual-graphs/3238>\
**Category:** Support\
**Created:** [September 3, 2021, 6:01am UTC](https://community.stardog.com/t/shacl-validation-for-virtual-graphs/3238 "2021-09-03T06:01:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sam](https://avatars.discourse-cdn.com/v4/letter/s/5f9b8f/32.png) [@Sam](https://community.stardog.com/u/Sam)\
**Post date:** [September 3, 2021, 6:01am UTC](https://community.stardog.com/t/shacl-validation-for-virtual-graphs/3238/1 "2021-09-03T06:01:10Z")

</div>

Hi Team,

We are validating the capabilities of stardog by making PoC's.

I could see the release notes - the stardog supports shacl validation for Virtual graphs.

But there's no clear documentation about the process of implementing shacl validation for virtual graphs, like it is there for the stardog database (ICV validation).

Could you please explain how can i add the shacl.ttl file which has shacl validations, to a virtual graph and validate the data before getting inserted, as we do it for stardog database ?

If the above is not possible, is there a way that we can validate it at least after the data insertion into a virtual graph ? If so how, it's possible ?

Also requesting any document/samples/repo link to achieve this if there's any !!!

Any help from anybody, would be really grateful .

Thanks,  
Muthu

---

<div class="post-metadata">

**Author:** ![pavel](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/pavel/32/18_2.png) [@pavel](https://community.stardog.com/u/pavel)\
**Post date:** [September 3, 2021, 8:11am UTC](https://community.stardog.com/t/shacl-validation-for-virtual-graphs/3238/2 "2021-09-03T08:11:40Z")

</div>

Hi Muthu,

First of all, inserting data into a Virtual Graph (VG) does not typically go through Stardog. It only queries VGs, but doesn't update them. So if you want to validate the data _before_ it goes into a VG, you need to do it in the system which stores the data at that point.

Second, if the data is already stored in an upstream system which is registered as a VG in Stardog (say, under `virtual://data` IRI), you can run SHACL report on it without moving to Stardog. You don't need to add `shacl.ttl` to that VG. Just add it to your local Stardog database from which `virtual://data` is accessible and then run ["stardog icv report --named-graph="virtual://data" {database}"](https://docs.stardog.com/stardog-cli-reference/icv/icv-report)

If there's a lot of data in the VG, or your SHACL constraints are complex, you should consider setting up [a cache node](https://docs.stardog.com/cluster/operating-the-cluster/cache-management) for that VG. Then Stardog will automatically redirect SHACL validation to that node for better performance.

Best,  
Pavel

---

<div class="post-metadata">

**Author:** ![Sam](https://avatars.discourse-cdn.com/v4/letter/s/5f9b8f/32.png) [@Sam](https://community.stardog.com/u/Sam)\
**Post date:** [September 15, 2021, 1:14pm UTC](https://community.stardog.com/t/shacl-validation-for-virtual-graphs/3238/3 "2021-09-15T13:14:09Z")

</div>

Hi @pavel , Thanks for your input .  
Have tried it , but getting some error.

Inserted the shacl constraints into a stardog db "shaclvalid"

```auto
/opt/stardog/bin/stardog icv report --named-graph="virtual://graph1" shaclvalid

No driver was found which supports the connection string: '--named-graph=virtual://spokeBproduct', please double-check the URL and verify the protocol is correct and try again.

```

requesting your help on this ?

Thanks,  
Muthu

---

<div class="post-metadata">

**Author:** ![pavel](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/pavel/32/18_2.png) [@pavel](https://community.stardog.com/u/pavel)\
**Post date:** [September 15, 2021, 2:09pm UTC](https://community.stardog.com/t/shacl-validation-for-virtual-graphs/3238/4 "2021-09-15T14:09:14Z")

</div>

Perhaps I made a typo, try

```auto
/opt/stardog/bin/stardog icv report --named-graph virtual://graph1 shaclvalid

```

Sorry about that,  
Pavel

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/e/ed66b48a616f505106a4acde3c9cee7e6da9bc67.svg) [@system](https://community.stardog.com/u/system)\
**Post date:** [September 29, 2021, 2:09pm UTC](https://community.stardog.com/t/shacl-validation-for-virtual-graphs/3238/5 "2021-09-29T14:09:45Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
