2.3.4 検証ルール
特定の検証ルールに基づいて、グラフのdataがschemaに準拠している必要があります。
次のルールを検証して、グラフのdataがschemaに対して検証されます:
- MANDATORY_PROPS_IN_SCHEMA_MISSING_IN_GRAPH: このルールでは、
schemaでmandatoryとマークされたすべてのプロパティに、グラフのdataの値が設定されていることが検証されます。この検証が失敗した場合のエラーの例を次に示します:
{ 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: このルールでは、エンティティ(頂点またはエッジ)が
schemaに定義されている場合に、指定されたグラフのdataにもそれらのエンティティが設定されていることが検証されます。この検証が失敗した場合のエラーの例を次に示します:
{ 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: このルールでは、グラフに存在するエンティティ(頂点またはエッジ、ラベルまたはプロパティ)が、
schemaに定義されていることが検証されます。次に、スキーマにエッジが定義されていないのに、グラフの
dataにエッジが存在するために、この検証が失敗した場合のサンプル・エラーを示します:``` { errorType: "ITEMS_IN_GRAPH_NOT_DEFINED_IN_SCHEMA", entityType: "edge", message: "Edge that is present in the graph is not defined in the schema." } ```次に、スキーマにラベルが定義されていないのに、グラフの
dataにラベルが存在するために、この検証が失敗した場合のサンプル・エラーを示します:``` { 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." } ```次に、スキーマにプロパティが定義されていないのに、グラフの
dataにプロパティが存在するために、この検証が失敗した場合のサンプル・エラーを示します:``` { 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: このルールでは、グラフの
dataのプロパティのデータ型がschemaのその定義に準拠していることが検証されます。この検証が失敗した場合のエラーの例を次に示します:
{ 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: このルールでは、グラフの
dataの頂点またはエッジで複数のラベルが使用される際に、それら複数のラベルのschemaに定義されているすべてのプロパティに矛盾がないことが検証されます。この検証が失敗した場合のエラーの例を次に示します:
{ 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'" }
親トピック: スキーマ・ビュー