Skip to main content

ConstraintValidator

Trait ConstraintValidator 

Source
pub trait ConstraintValidator: Send + Sync {
    // Required methods
    fn validate_node_property(
        &self,
        labels: &[String],
        key: &str,
        value: &Value,
    ) -> Result<(), OperatorError>;
    fn validate_node_complete(
        &self,
        labels: &[String],
        properties: &[(String, Value)],
    ) -> Result<(), OperatorError>;
    fn check_unique_node_property(
        &self,
        labels: &[String],
        key: &str,
        value: &Value,
    ) -> Result<(), OperatorError>;
    fn validate_edge_property(
        &self,
        edge_type: &str,
        key: &str,
        value: &Value,
    ) -> Result<(), OperatorError>;
    fn validate_edge_complete(
        &self,
        edge_type: &str,
        properties: &[(String, Value)],
    ) -> Result<(), OperatorError>;

    // Provided methods
    fn validate_node_labels_allowed(
        &self,
        labels: &[String],
    ) -> Result<(), OperatorError> { ... }
    fn validate_edge_type_allowed(
        &self,
        edge_type: &str,
    ) -> Result<(), OperatorError> { ... }
    fn validate_edge_endpoints(
        &self,
        edge_type: &str,
        source_labels: &[String],
        target_labels: &[String],
    ) -> Result<(), OperatorError> { ... }
    fn inject_defaults(
        &self,
        labels: &[String],
        properties: &mut Vec<(String, Value)>,
    ) { ... }
}
Expand description

Trait for validating schema constraints during mutation operations.

Implementors check type definitions, NOT NULL, and UNIQUE constraints before data is written to the store.

Required Methods§

Source

fn validate_node_property( &self, labels: &[String], key: &str, value: &Value, ) -> Result<(), OperatorError>

Validates a single property value for a node with the given labels.

Checks type compatibility and NOT NULL constraints.

Source

fn validate_node_complete( &self, labels: &[String], properties: &[(String, Value)], ) -> Result<(), OperatorError>

Validates that all required properties are present after creating a node.

Checks NOT NULL constraints for properties that were not explicitly set.

Source

fn check_unique_node_property( &self, labels: &[String], key: &str, value: &Value, ) -> Result<(), OperatorError>

Checks UNIQUE constraint for a node property value.

Returns an error if a node with the same label already has this value.

Source

fn validate_edge_property( &self, edge_type: &str, key: &str, value: &Value, ) -> Result<(), OperatorError>

Validates a single property value for an edge of the given type.

Source

fn validate_edge_complete( &self, edge_type: &str, properties: &[(String, Value)], ) -> Result<(), OperatorError>

Validates that all required properties are present after creating an edge.

Provided Methods§

Source

fn validate_node_labels_allowed( &self, labels: &[String], ) -> Result<(), OperatorError>

Validates that the node labels are allowed by the bound graph type.

Source

fn validate_edge_type_allowed( &self, edge_type: &str, ) -> Result<(), OperatorError>

Validates that the edge type is allowed by the bound graph type.

Source

fn validate_edge_endpoints( &self, edge_type: &str, source_labels: &[String], target_labels: &[String], ) -> Result<(), OperatorError>

Validates that edge endpoints have the correct node type labels.

Source

fn inject_defaults( &self, labels: &[String], properties: &mut Vec<(String, Value)>, )

Injects default values for properties that are defined in a type but not explicitly provided.

Implementors§