Skip to main content

validate_rel_shape

Function validate_rel_shape 

Source
pub fn validate_rel_shape(
    rel_type: &str,
    from_type: &str,
    to_type: Option<&str>,
    schema: &Schema,
) -> Result<(), ValidationError>
Expand description

Reject an edge whose (from_type, to_type) pair violates the schema’s declared source_types / target_types for this relationship. No-op when both constraint lists are empty (shape-free edges) or when the relationship name is unknown (callers run this only after validate_rel_type succeeds, so this branch is defensive). The target-type check is skipped when to_type is None — happens for auto-stubbed targets that have no type yet; once the stub is authored as a real entity, future edges land under the strict check.

Suggestion: nearest-match edge in the schema whose declared shape would admit (from_type, to_type). Tiebreaker is declaration order in the YAML (deterministic).