Cardinality Rules
Overview
Section titled “Overview”Cardinality rules validate that element cardinality constraints are valid and consistent.
correctness/invalid-cardinality
Section titled “correctness/invalid-cardinality”Severity: Error Fixable: Yes (safe)
Cardinality must be specified as min..max
where min <= max
.
Example:
// ✓ GoodProfile: PatientProfile* name 1..1* telecom 0..*
// ✗ BadProfile: PatientProfile* name 2..1 // min > max
correctness/cardinality-conflict
Section titled “correctness/cardinality-conflict”Severity: Error Fixable: No
Multiple cardinality rules on the same element must be compatible.
Example:
// ✗ Bad - Conflicting cardinalityProfile: PatientProfile* name 1..1* name 0..* // Conflicts with previous rule
suspicious/redundant-cardinality
Section titled “suspicious/redundant-cardinality”Severity: Info Fixable: Yes (safe)
Cardinality that matches the parent is redundant.
Example:
// ⚠ RedundantProfile: PatientProfileParent: Patient* identifier 0..* // Same as base Patient.identifier
Rationale
Section titled “Rationale”Valid cardinality ensures:
- FHIR validation works correctly
- Clear data requirements
- Prevents impossible constraints