Skip to main content

validate_reparent

Function validate_reparent 

Source
pub fn validate_reparent(
    conn: &Connection,
    item_id: &str,
    new_parent_id: &str,
) -> Result<(), HierarchyError>
Expand description

Validate that reparenting item_id under new_parent_id is allowed.

This checks:

  1. Both items exist.
  2. The new parent is of kind goal.
  3. The move would not create a cycle (i.e., new_parent_id is not a descendant of item_id).

On success returns Ok(()). On failure returns the appropriate HierarchyError variant.

ยงErrors

Returns HierarchyError::ItemNotFound if either item does not exist, HierarchyError::NotAGoal if the new parent is not a goal, or HierarchyError::CycleDetected if the move would create a cycle.