2.3.4 Validation Rules
The graph data
must conform to the
schema
based on the certain validation rules.
The graph data
is validated against the schema
by verifying the following rules:
- MANDATORY_PROPS_IN_SCHEMA_MISSING_IN_GRAPH: This rule verifies
that all the properties that are marked as mandatory in the
schema
have values in the graphdata
.The following shows a sample error if this validation fails:
{ errorType: "MANDATORY_PROPS_IN_SCHEMA_MISSING_IN_GRAPH", entityType: "vertex", entityId: "0", entityDescriptor: ["Hermione"], property: "id", message: "Vertex 'Hermione' with id '0' doesn't have a property 'id' while it is marked as mandatory in the schema" }
- ENTITY_IN_SCHEMA_MISSING_IN_GRAPH: This rule verifies that when
entities (vertices or edges) are defined in the
schema
, the provided graphdata
also has those entities in it.The following shows a sample error if this validation fails:
{ errorType: "ENTITY_IN_SCHEMA_MISSING_IN_GRAPH", entityType: "edge", message: "The graph's data doesn't have Edges in it, but is specified in the schema" }
- ITEMS_IN_GRAPH_NOT_DEFINED_IN_SCHEMA: This rule verifies that
entities (vertices or edges, labels, or properties) that are present
in the graph, have definitions in the
schema
.The following shows a sample error if this validation fails due to edges being present in the graph
data
without having edges defined in the schema:``` { errorType: "ITEMS_IN_GRAPH_NOT_DEFINED_IN_SCHEMA", entityType: "edge", message: "Edge that is present in the graph is not defined in the schema." } ```
The following shows a sample error if this validation fails due to a label being present in the graph
data
without having that label defined in the schema:``` { errorType: "ITEMS_IN_GRAPH_NOT_DEFINED_IN_SCHEMA", entityType: "vertex", entityDescriptor: ["misc"], message: "Vertex with label 'misc' that is present in the graph is not defined in the schema." } ```
The following shows a sample error if this validation fails due to a property being present in the graph
data
without having that property defined in the schema:``` { errorType: "ITEMS_IN_GRAPH_NOT_DEFINED_IN_SCHEMA", entityType: "vertex", entityId: "0", entityDescriptor: ["Tom Jones"], property: "date", message: "Property 'date' of vertex 'Tom Jones' with id '0' that is present in the graph is not defined in the schema." } ```
- TYPE_MISMATCH_BETWEEN_SCHEMA_AND_GRAPH: This rule verifies that
the data type of properties in the graph
data
conforms with its definition in theschema
.The following shows a sample error if this validation fails:
{ errorType: "TYPE_MISMATCH_BETWEEN_SCHEMA_AND_GRAPH", entityType: "vertex", entityDescriptor: ["Mary"], property: "id", expectedType: "string", actualType: "number", message: "Vertex 'Mary' has an attribute 'id' of type 'number' while it is specified to be of type 'string' in the schema" }
- MISMATCH_BETWEEN_LABELS_IN_SCHEMA: This rule verifies that all
properties defined in the
schema
across multiple labels do not contradict, when those labels are used in a vertex or edge of the graphdata
.The following shows a sample error if this validation fails:
{ errorType: "MISMATCH_BETWEEN_LABELS_IN_SCHEMA", entityType: "edge", entityId: "0", entityDescriptor: ["default", "Label 1", "Label 2", "Label 3"], property: "id", message: "Edge 'default' with id '0' has mismatch in the schema definition of 'id' property among its labels 'Label 1', 'Label 2', and 'Label 3'" }
Parent topic: Schema View