Skip to content

TS: example demo for inherited base-required field validation#171

Merged
ryukzak merged 1 commit into
mainfrom
test/example-inherited-required-validation
Jun 1, 2026
Merged

TS: example demo for inherited base-required field validation#171
ryukzak merged 1 commit into
mainfrom
test/example-inherited-required-validation

Conversation

@ryukzak
Copy link
Copy Markdown
Collaborator

@ryukzak ryukzak commented Jun 1, 2026

Follow-up to #166. Adds a behaviour-level demo that runs the generated profile (not codegen internals) to lock in inherited base-required field validation.

Bundle.type is required by base R4 Bundle (1..1). The ExampleTypedBundle profile differential only slices entry — it never re-states type. The test builds a valid bundle, drops type, and asserts validate() reports it as missing, then clears once set:

const bundle = ExampleTypedBundleProfile.create({ type: "collection" }).setPatientEntry({ resource: patient });
expect(bundle.validate().errors).toEqual([]);

delete (bundle.toResource() as { type?: unknown }).type;
expect(bundle.validate().errors).toEqual(["ExampleTypedBundle: required field 'type' is missing"]);

bundle.setType("collection");
expect(bundle.validate().errors).toEqual([]);

Verified via make test-local-package-folder-example: regenerate ✅, typecheck ✅, 15/15 tests pass.

Runs the generated ExampleTypedBundle profile and asserts validate() flags a
missing Bundle.type — base-R4 required, inherited, not re-stated in the profile
differential — and clears once set. Behaviour-level (runs target code), so it
survives the per-type validator redesign (#169).
@ryukzak ryukzak merged commit 53b4de1 into main Jun 1, 2026
37 checks passed
@ryukzak ryukzak deleted the test/example-inherited-required-validation branch June 1, 2026 15:04
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