The validation system ensures data integrity and proper functionality by checking layout data against business rules and structural requirements.
Layout passes all validation checks and is ready for use.
Layout has errors that prevent proper functionality:
- Missing required references
- Invalid data structures
- Business rule violations
- Data integrity issues
- Unique IDs: Device IDs must be unique across all devices
- Valid Position: Position must be within canvas bounds
- Valid Size: Size must be positive (width and height > 0)
- Port IDs: Port IDs must be unique within each device
- Port Position: Port positions must be non-negative
- Unique IDs: Connection IDs must be unique
- Device References: Source and target devices must exist
- Port References: Source and target ports must exist on their devices
- Self-Connection: Source and target devices must be different
- Port Direction: Port direction combinations must be valid
Rule: Each port can be used by at most one connection.
Validation: Checks that no port is referenced by multiple connections. This ensures clear connection topology and prevents routing conflicts.
Valid Combinations:
- OUTPUT → INPUT
- OUTPUT → BIDIRECTIONAL
- BIDIRECTIONAL → INPUT
- BIDIRECTIONAL → BIDIRECTIONAL
Invalid Combinations:
- INPUT → INPUT (both are inputs)
- OUTPUT → OUTPUT (both are outputs)
Connections must reference existing devices:
- Source device must exist
- Target device must exist
- References validated during data loading
Connections must reference existing ports:
- Source port must exist on source device
- Target port must exist on target device
- Port IDs validated against device port lists
- Positions must be within canvas bounds
- Sizes must be positive
- Coordinates validated against canvas size
- Port positions must be non-negative
- Positions clamped to device bounds at runtime
- Validation ensures basic constraints
Validation occurs when layout data is loaded:
- Parse JSON data
- Validate structure
- Validate references
- Validate business rules
- Return result (Success or Error)
Validation errors are reported with:
- Error message describing the issue
- Context about what failed
- Information to help fix the issue
- DATA_MODEL.md - Data structure being validated
- ROUTING_SYSTEM.md - Routing compatibility validation