rudof pgschema-validate
rudof pgschema-validate validates a property graph with a PG-Schema. It needs three inputs:
- The property graph, in YARS-PG syntax.
- The PG-Schema (
--schema). - A type map (
--typemap) that assigns a node type or edge type to each node and edge.
The examples/property_graphs folder has graphs, schemas and type maps.
Example
The graph demo.pg:
(n1 {Person} [
name: "Alice",
birthdate: DATE "2010-07-22"
])
(n2 {Person, Student} [
id: 234,
name: "Robert Smith",
aliases: ["Bob", "Robbie"],
email: "bob@mail.com"
])
(n3 {Course} [
name: "Algebra",
credits: 6
])
(n1) - (e1 {knows} [since: 2020 ]) -> (n2)
(n2) - (e2 {EnrolledIn} [start: 2024, end: 2025 ]) -> (n3)
The type map demo.map:
n1:PersonType,
n2:StudentType,
n3:CourseType,
e1:KnowsType,
e2:EnrolledInType
Validate the graph with the schema of the pgschema page:
$ rudof pgschema-validate demo.pg --schema demo.pgs --typemap demo.map
Result - valid?: false:
n1:PersonType: true Details: Labels match Person and record: {birthdate: 2010-07-22, name: Alice} conforms to {birthdate: Date(1), name: String(1)}
n2:StudentType: true Details: Labels match Person, Student and record: ...
n3:CourseType: true Details: Labels match Course and record: {credits: 6, name: Algebra} conforms to {credits: (Integer(1) ∩ Condition((> 3))), name: String(1)}
e1:KnowsType: false Details: Labels do not match: record labels knows, type labels [{Knows}]
...
The edge e1 fails, because its label is knows and the edge type expects Knows.
The -r option selects the result format: compact (default), details, json or csv.
Options
$ rudof pgschema-validate --help
Validate Property Graph data using PGSchema
Usage: rudof pgschema-validate [OPTIONS] [DATA]...
Arguments:
[DATA]...
Options:
-s, --schema <INPUT> PGSchema file, URI or - (for stdin). If omitted, reuses the currently loaded PGSchema
-t, --data-format <FORMAT> Property Graph data format [default: pg] [possible values: turtle, ntriples, rdfxml, trig, n3, nquads, jsonld, pg, html]
-m, --typemap <INPUT> Type map used for validation, FILE, URI or - for stdin. If omitted, reuses the currently loaded type map
-r, --result-format <FORMAT> Output result format [default: compact] [possible values: compact, details, json, csv]
-o, --output-file <FILE> Output file name, default = terminal
--force-overwrite Force overwrite to output file if it already exists
-h, --help Print help