Skip to content

Commit

Permalink
[VET-3274] Add SHACL validation (#60)
Browse files Browse the repository at this point in the history
* [VET-3274] Add VALIDATE

* [VET-3274] Add tests from docs

* [VET-3274] Actually follow the docs w.r.t. expressions it supports + learn chevrotain

* [VET-3274] Update test snapshots

* [VET-3274] Add badDog failing cases; fix initial clause

* [VET-3274] Remove stray comment

* [VET-3274] Break up ValidateQuery into more clauses

* [VET-3274] Ensure all test files end with newlines
  • Loading branch information
alex-r-bigelow authored Oct 9, 2023
1 parent 4c19def commit 13d7a1f
Show file tree
Hide file tree
Showing 27 changed files with 1,602 additions and 1,457 deletions.
16 changes: 8 additions & 8 deletions src/__tests__/graphql/__snapshots__/parser.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -39781,9 +39781,9 @@ but found: '='",
"PATTERN": "=",
"isParent": false,
"tokenName": "Equals",
"tokenTypeIdx": 258,
"tokenTypeIdx": 262,
},
"tokenTypeIdx": 258,
"tokenTypeIdx": 262,
},
"resyncedTokens": Array [],
"token": Object {
Expand All @@ -39798,9 +39798,9 @@ but found: '='",
"PATTERN": "=",
"isParent": false,
"tokenName": "Equals",
"tokenTypeIdx": 258,
"tokenTypeIdx": 262,
},
"tokenTypeIdx": 258,
"tokenTypeIdx": 262,
},
},
Object {
Expand All @@ -39823,9 +39823,9 @@ but found: '='",
"PATTERN": ")",
"isParent": false,
"tokenName": "RParen",
"tokenTypeIdx": 240,
"tokenTypeIdx": 244,
},
"tokenTypeIdx": 240,
"tokenTypeIdx": 244,
},
},
Object {
Expand Down Expand Up @@ -39913,9 +39913,9 @@ but found: '='",
"PATTERN": ",",
"isParent": false,
"tokenName": "Comma",
"tokenTypeIdx": 250,
"tokenTypeIdx": 254,
},
"tokenTypeIdx": 250,
"tokenTypeIdx": 254,
},
},
],
Expand Down
2,720 changes: 1,360 additions & 1,360 deletions src/__tests__/shacl/__snapshots__/lexer.test.ts.snap

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PREFIX icv: <tag:stardog:api:icv:>
VALIDATE ALL something:else
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PREFIX icv: <tag:stardog:api:icv:>
VALIDATE LIMIT 10 ALL
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PREFIX icv: <tag:stardog:api:icv:>
VALIDATE ALL LIMIT 100 LIMIT PER SHAPE 1 LIMIT 10
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PREFIX icv: <tag:stardog:api:icv:>
VALIDATE ALL LIMIT PER 10
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
PREFIX icv: <tag:stardog:api:icv:>
PREFIX ex: <tag:stardog:example:>
VALIDATE ex:MyNode GRAPH ex:duplicateGraph GRAPH ex:graph1 ex:graph2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
PREFIX icv: <tag:stardog:api:icv:>
PREFIX ex: <tag:stardog:example:>
VALIDATE ex:MyNode GRAPH ex:graph1 ALL
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
PREFIX icv: <tag:stardog:api:icv:>
PREFIX : <tag:stardog:example:>
VALIDATE USING SHAPES :SongShape :AlbumShape
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
PREFIX icv: <tag:stardog:api:icv:>
PREFIX : <tag:stardog:example:>
VALIDATE ALL USING :SongShape :AlbumShape
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

PREFIX icv: <tag:stardog:api:icv:>
PREFIX sh: <http://www.w3.org/ns/shacl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX : <tag:stardog:example:>

VALIDATE ALL LIMIT 10 USING SHAPES {
:NameShape a sh:NodeShape ;
sh:property [
sh:path :name ;
sh:minCount 1 ;
sh:datatype xsd:string
] .
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
PREFIX icv: <tag:stardog:api:icv:>
PREFIX ex: <tag:stardog:example:>
VALIDATE ALL USING SHAPES GRAPH ex:constraintGraph {
:NameShape a sh:NodeShape ;
sh:property [
sh:path :name ;
sh:minCount 1 ;
sh:datatype xsd:string
] .
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# taken from Stardog docs: https://docs.stardog.com/data-quality-constraints#validate-sparql-service
PREFIX icv: <tag:stardog:api:icv:>
VALIDATE ALL
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# taken from Stardog docs: https://docs.stardog.com/data-quality-constraints#validate-sparql-service
PREFIX icv: <tag:stardog:api:icv:>
PREFIX ex: <tag:stardog:example:>
VALIDATE GRAPH ex:graph1 ex:graph2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# taken from Stardog docs: https://docs.stardog.com/data-quality-constraints#validate-sparql-service
PREFIX icv: <tag:stardog:api:icv:>
VALIDATE ALL LIMIT 10
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# taken from Stardog docs: https://docs.stardog.com/data-quality-constraints#validate-sparql-service
PREFIX icv: <tag:stardog:api:icv:>
VALIDATE ALL LIMIT 100 LIMIT PER SHAPE 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# taken from Stardog docs: https://docs.stardog.com/data-quality-constraints#validate-sparql-service
PREFIX icv: <tag:stardog:api:icv:>
VALIDATE ALL LIMIT PER SHAPE 10
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# taken from Stardog docs: https://docs.stardog.com/data-quality-constraints#validate-sparql-service
PREFIX icv: <tag:stardog:api:icv:>
PREFIX ex: <tag:stardog:example:>
VALIDATE ex:MyNode
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# taken from Stardog docs: https://docs.stardog.com/data-quality-constraints#validate-sparql-service
PREFIX icv: <tag:stardog:api:icv:>
PREFIX ex: <tag:stardog:example:>
VALIDATE ex:MyNode GRAPH ex:graph1
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# taken from Stardog docs: https://docs.stardog.com/data-quality-constraints#validate-sparql-service
PREFIX icv: <tag:stardog:api:icv:>
PREFIX : <tag:stardog:example:>
VALIDATE ALL USING SHAPES :SongShape :AlbumShape
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# taken from Stardog docs: https://docs.stardog.com/data-quality-constraints#validate-sparql-service
PREFIX icv: <tag:stardog:api:icv:>
PREFIX sh: <http://www.w3.org/ns/shacl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX : <tag:stardog:example:>

VALIDATE ALL USING SHAPES {
:NameShape a sh:NodeShape ;
sh:property [
sh:path :name ;
sh:minCount 1 ;
sh:datatype xsd:string
] .
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# taken from Stardog docs: https://docs.stardog.com/data-quality-constraints#validate-sparql-service
PREFIX icv: <tag:stardog:api:icv:>
PREFIX ex: <tag:stardog:example:>
VALIDATE ALL USING SHAPES GRAPH ex:constraintGraph
48 changes: 24 additions & 24 deletions src/__tests__/srs/__snapshots__/lexer.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ Array [
"categoryMatchesMap": Object {},
"isParent": false,
"tokenName": "TTL_PREFIX",
"tokenTypeIdx": 184,
"tokenTypeIdx": 188,
},
"tokenTypeIdx": 184,
"tokenTypeIdx": 188,
},
Object {
"endColumn": 19,
Expand Down Expand Up @@ -65,9 +65,9 @@ Array [
"categoryMatchesMap": Object {},
"isParent": false,
"tokenName": "IRIREF",
"tokenTypeIdx": 197,
"tokenTypeIdx": 201,
},
"tokenTypeIdx": 197,
"tokenTypeIdx": 201,
},
Object {
"endColumn": 44,
Expand All @@ -84,9 +84,9 @@ Array [
"categoryMatchesMap": Object {},
"isParent": false,
"tokenName": "Period",
"tokenTypeIdx": 157,
"tokenTypeIdx": 161,
},
"tokenTypeIdx": 157,
"tokenTypeIdx": 161,
},
Object {
"endColumn": 15,
Expand Down Expand Up @@ -169,9 +169,9 @@ Array [
"categoryMatchesMap": Object {},
"isParent": false,
"tokenName": "Period",
"tokenTypeIdx": 157,
"tokenTypeIdx": 161,
},
"tokenTypeIdx": 157,
"tokenTypeIdx": 161,
},
Object {
"endColumn": 10,
Expand All @@ -188,9 +188,9 @@ Array [
"categoryMatchesMap": Object {},
"isParent": false,
"tokenName": "Rule",
"tokenTypeIdx": 204,
"tokenTypeIdx": 208,
},
"tokenTypeIdx": 204,
"tokenTypeIdx": 208,
},
Object {
"endColumn": 18,
Expand Down Expand Up @@ -227,9 +227,9 @@ Array [
"categoryMatchesMap": Object {},
"isParent": false,
"tokenName": "If",
"tokenTypeIdx": 205,
"tokenTypeIdx": 209,
},
"tokenTypeIdx": 205,
"tokenTypeIdx": 209,
},
Object {
"endColumn": 7,
Expand All @@ -250,9 +250,9 @@ Array [
"categoryMatchesMap": Object {},
"isParent": false,
"tokenName": "GroupGraphPattern",
"tokenTypeIdx": 208,
"tokenTypeIdx": 212,
},
"tokenTypeIdx": 208,
"tokenTypeIdx": 212,
},
Object {
"endColumn": 10,
Expand All @@ -270,9 +270,9 @@ Array [
"categoryMatchesMap": Object {},
"isParent": false,
"tokenName": "Then",
"tokenTypeIdx": 206,
"tokenTypeIdx": 210,
},
"tokenTypeIdx": 206,
"tokenTypeIdx": 210,
},
Object {
"endColumn": 12,
Expand All @@ -289,9 +289,9 @@ Array [
"categoryMatchesMap": Object {},
"isParent": false,
"tokenName": "LCurly",
"tokenTypeIdx": 151,
"tokenTypeIdx": 155,
},
"tokenTypeIdx": 151,
"tokenTypeIdx": 155,
},
Object {
"endColumn": 6,
Expand All @@ -310,9 +310,9 @@ Array [
"categoryMatchesMap": Object {},
"isParent": false,
"tokenName": "TriplesBlock",
"tokenTypeIdx": 209,
"tokenTypeIdx": 213,
},
"tokenTypeIdx": 209,
"tokenTypeIdx": 213,
},
Object {
"endColumn": 7,
Expand All @@ -330,9 +330,9 @@ Array [
"categoryMatchesMap": Object {},
"isParent": false,
"tokenName": "EndThen",
"tokenTypeIdx": 207,
"tokenTypeIdx": 211,
},
"tokenTypeIdx": 207,
"tokenTypeIdx": 211,
},
Object {
"endColumn": 16,
Expand Down Expand Up @@ -406,9 +406,9 @@ Array [
"categoryMatchesMap": Object {},
"isParent": false,
"tokenName": "Period",
"tokenTypeIdx": 157,
"tokenTypeIdx": 161,
},
"tokenTypeIdx": 157,
"tokenTypeIdx": 161,
},
]
`;
Loading

0 comments on commit 13d7a1f

Please sign in to comment.