Skip to content

TypeSchema/TS: Add choice type narrowing and validation for profiles#105

Merged
ryukzak merged 2 commits intomainfrom
choice-narrowing
Mar 16, 2026
Merged

TypeSchema/TS: Add choice type narrowing and validation for profiles#105
ryukzak merged 2 commits intomainfrom
choice-narrowing

Conversation

@ryukzak
Copy link
Copy Markdown
Collaborator

@ryukzak ryukzak commented Mar 16, 2026

  • Add narrowMergedChoiceDeclarations in flatProfile() to restrict ChoiceFieldDeclaration.choices to only the variants declared by the most derived constraint schema
  • Add choiceRestrictions method on TypeSchemaIndex returning Record<string, { permitted, prohibited }> per choice group
  • Emit validateExcluded for disallowed choice instances in profile validation

Before (body weight validate() allowed all 11 value[x] variants):

// no validation for valueString, valueBoolean, etc.

After (only valueQuantity permitted, 10 others excluded):

...validateExcluded(res, profileName, "valueCodeableConcept"),
...validateExcluded(res, profileName, "valueString"),
...validateExcluded(res, profileName, "valueBoolean"),
// ... 7 more

@ryukzak ryukzak changed the title Add choice type narrowing and validation for profiles TypeSchema/TS: Add choice type narrowing and validation for profiles Mar 16, 2026
Base automatically changed from remove-profile-interface to main March 16, 2026 12:16
ryukzak added 2 commits March 16, 2026 13:58
- Add narrowMergedChoiceDeclarations to restrict choice declarations to allowed variants
- Add choiceRestrictions method on TypeSchemaIndex returning permitted/prohibited lists
- Emit validateExcluded for disallowed choice instances in profile validation
- Remove buildAllowedChoiceMap helper in favor of choiceRestrictions
@ryukzak ryukzak merged commit 3b1c0ea into main Mar 16, 2026
31 checks passed
@ryukzak ryukzak deleted the choice-narrowing branch March 16, 2026 14:18
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.

1 participant