Hierarchy Structure Validator
Component Detail
Infrastructure
medium complexity
backendshared
1
Dependencies
0
Dependents
1
Entities
0
Integrations
Description
Utility service that validates the structural integrity of the organization hierarchy before and after mutations. Checks for orphaned nodes, cycle introduction, depth limit violations, and missing level assignments. Used by the hierarchy service and admin portal to surface validation errors to the operator.
hierarchy-validator
Responsibilities
- Detect circular parent-child references before insert
- Enforce maximum hierarchy depth per organization type
- Check for orphaned nodes after delete operations
- Validate level type ordering matches organization configuration
Interfaces
validateNoCircle(unitId, newParentId, existingTree)
validateDepth(unitId, maxDepth)
validateOrphanFree(deletedUnitId, tree)
validateLevelOrder(units, levelConfig)
runFullValidation(organizationId)