Skip to content

Expose invariant IDs as an extension on IssueComponent#672

Open
andrzejskowronski wants to merge 2 commits into
developfrom
feature/VONK-9810-expose-invariant-ids
Open

Expose invariant IDs as an extension on IssueComponent#672
andrzejskowronski wants to merge 2 commits into
developfrom
feature/VONK-9810-expose-invariant-ids

Conversation

@andrzejskowronski

@andrzejskowronski andrzejskowronski commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Closes #615

This pull request introduces a consistent enhancement across the Firely FHIR Validator codebase by updating the way validation results are constructed. Specifically, it ensures that when an IssueAssertion is converted into a ResultReport, the originating assertion object is included as context. This change improves traceability and debugging of validation issues by allowing consumers to identify the exact assertion that led to each validation result, and to annotate the results with the information contained by the specific assertions.

The most important changes are:

Enhancements to Assertion Context Propagation:

  • Updated all calls to AsResult in various validators (e.g., BindingValidator, CanonicalValidator, CardinalityValidator, ChildrenValidator, ExtensionContextValidator, FhirPathValidator, FhirStringValidator, FhirTxt1Validator, FhirTypeLabelValidator, FhirUriValidator, FixedValidator, InvariantValidator, ExtensionSchema) to pass the current assertion object (this or relevant instance) as an additional argument, ensuring the assertion context is preserved in validation results.

Core Assertion and ResultReport Infrastructure:

  • Added an Assertion property to the IssueAssertion class and updated its constructor to accept and store an IAssertion instance, so that each assertion can be traced back from the result. [1] [2] [3]
  • Modified the Validate method and AsResult overloads in IssueAssertion to ensure the assertion context is always included in the resulting ResultReport. [1] [2]

Minor Refactoring and Consistency Improvements:

  • Introduced a constant CONTEXT_INVARIANT_KEY in ExtensionContextValidator to avoid magic strings and improve maintainability. [1] [2] [3]
  • Cleaned up unused using statements in IssueAssertion.cs.

These changes collectively enhance the reliability and maintainability of the validation framework by providing better introspection into validation failures and their origins.

…` generation

- Introduced `IssueComponentConfigurator` property in `IssueAssertion` for enriching `IssueComponent` without tight coupling.
- Updated methods to pass configuration callbacks for adding extensions.
- Enhanced unit tests to verify invariant ID exposure on `OperationOutcome`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose invariant ids in operationoutcome-message-id extension for failed invariants

1 participant