Skip to content

Commit

Permalink
Fix invalid URL message, and add tests for multiple invariants
Browse files Browse the repository at this point in the history
  • Loading branch information
Grahame Grieve committed Dec 19, 2024
1 parent 6f78aab commit c3b72d7
Show file tree
Hide file tree
Showing 2 changed files with 125 additions and 1 deletion.
48 changes: 47 additions & 1 deletion validator/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -17185,7 +17185,7 @@
"severity": "error",
"code": "invalid",
"details": {
"text": "The URL is not valid because '(URL contains 2 Invalid Characters ([{, }]))': http://example.com/{[-}]/link.html"
"text": "The URL is not valid because '(URL contains 2 Invalid Characters: '{','}')': http://example.com/{[-}]/link.html"
},
"diagnostics": "[5,47]",
"expression": [
Expand Down Expand Up @@ -50434,6 +50434,52 @@
}
}
},
{
"name": "profile-multiple-inv-same-key",
"file": "profile-multiple-inv-same-key.xml",
"version": "5.0.0",
"description": "variants of invariant reuse/redefinition that are or aren't valid",
"java": {
"outcome": {
"resourceType": "OperationOutcome",
"issue": [
{
"severity": "error",
"code": "invalid",
"details": {
"text": "The constraint key 'dom-3' already exists at the location 'http://hl7.org/fhir/StructureDefinition/Patient|5.0.0' with a different expression ('contained.where((('#'+id in (%resource.descendants().reference | %resource.descendants().ofType(canonical) | %resource.descendants().ofType(uri) | %resource.descendants().ofType(url))) or descendants().where(reference = '#').exists() or descendants().where(ofType(canonical) = '#').exists() or descendants().where(ofType(canonical) = '#').exists()).not()).trace('unmatched', id).empty()')"
},
"diagnostics": "[23,19]",
"expression": [
"StructureDefinition.differential.element[0].constraint[1]"
]
},
{
"severity": "error",
"code": "invalid",
"details": {
"text": "The constraint key 'ident-1' already exists at the location 'http://hl7.org/fhir/StructureDefinition/Identifier|5.0.0' with a different expression ('value.exists()')"
},
"diagnostics": "[39,19]",
"expression": [
"StructureDefinition.differential.element[1].constraint[1]"
]
},
{
"severity": "error",
"code": "invalid",
"details": {
"text": "The constraint key 'e-1' already exists at the location 'Patient.name' with a different expression ('family.exists() and family.hasValue()')"
},
"diagnostics": "[64,19]",
"expression": [
"StructureDefinition.differential.element[3].constraint[0]"
]
}
]
}
}
},
{
"name": "zzz",
"file": "zzz.json",
Expand Down
78 changes: 78 additions & 0 deletions validator/profile-multiple-inv-same-key.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<StructureDefinition xmlns="http://hl7.org/fhir">
<id value="profile-multiple-inv-same-key"/>
<url value="http://hl7.org/fhir/test/StructureDefinition/profile-multiple-inv-same-key"/>
<name value="ProfileMultipleInv"/>
<title value="ProfileMultipleInv"/>
<status value="draft"/>
<date value="2017-09-06T06:30:54+00:00"/>
<fhirVersion value="5.0.0"/>
<kind value="resource"/>
<abstract value="false"/>
<type value="Patient"/>
<baseDefinition value="http://hl7.org/fhir/StructureDefinition/Patient"/>
<derivation value="constraint"/>
<differential>
<element id="Patient">
<path value="Patient"/>
<constraint>
<key value="dom-2"/>
<severity value="error"/>
<human value="this is copied from parent, so no validation error"/>
<expression value="contained.contained.empty()"/>
</constraint>
<constraint>
<key value="dom-3"/>
<severity value="error"/>
<human value="this is changed from parent, so there's an error"/>
<expression value="contained.something()"/>
</constraint>
</element>
<element id="Patient.identifier">
<path value="Patient.identifier"/>
<constraint>
<key value="ele-1"/>
<severity value="error"/>
<human value="this is copied from parent, so no validation error (checking the source doesn't make a difference)"/>
<expression value="hasValue() or (children().count() &gt; id.count())"/>
<source value="http://hl7.org/fhir/test/StructureDefinition/profile-multiple-inv-same-key"/>
</constraint>
<constraint>
<key value="ident-1"/>
<severity value="warning"/>
<human value="this is changed from parent, so there's an error (checking the source doesn't make a difference)"/>
<expression value="value.exists() and value.hasValue()"/>
<source value="http://hl7.org/fhir/test/StructureDefinition/profile-multiple-inv-same-key"/>
</constraint>
</element>
<element id="Patient.name">
<path value="Patient.name"/>
<constraint>
<key value="e-1"/>
<severity value="warning"/>
<human value="first definition"/>
<expression value="family.exists() and family.hasValue()"/>
</constraint>
<constraint>
<key value="e-2"/>
<severity value="warning"/>
<human value="first definition"/>
<expression value="text.exists() and text.hasValue()"/>
</constraint>
</element>
<element id="Patient.address">
<path value="Patient.address"/>
<constraint>
<key value="e-1"/>
<severity value="warning"/>
<human value="second use - changed (error)"/>
<expression value="country.exists() and country.hasValue()"/>
</constraint>
<constraint>
<key value="e-2"/>
<severity value="warning"/>
<human value="second use, not changed"/>
<expression value="text.exists() and text.hasValue()"/>
</constraint>
</element>
</differential>
</StructureDefinition>

0 comments on commit c3b72d7

Please sign in to comment.