2.3.2 Schema Validation

In addition to rendering the schema of a graph, the Graph Visualization library automatically validates the provided graph data against the schema if one is available.

If the graph data conforms to the schema based on the defined validation rules (see Validation Rules), then the Graph Visualization library initializes without any problems. Also, in the absence of a schema, the Schema view will not be displayed, and the schema validations will not be executed.

If the schema validation fails, then the errors will be displayed in the following JSON format:

[{
    errorType : string              // Used by consuming application to summarize or detail the error
    entityType: 'vertex' | 'edge'   // Can be used to format the error message to specify the context
    entityId?: string               // Used to identify the entity in the message
    entityDescriptor?: string[]     // Used to represent name or labels of the entity in the message
    property?: string               // Name of the property that failed validation
    expectedType?: string           // Expected type of the property
    actualType?: string             // Actual type of the property
    message?: string                // Ready to use message if no further customization is needed at the consuming side
}]

The consuming applications can then use the message property to obtain the complete message for display on its interface. They can also derive their own custom message, summarize errors, or categorize errors using errorType and other properties provided in the error message.