Skip to content

fix(schemas): add validation for child schemas in discriminated unions - #66

Closed
leoafarias wants to merge 1 commit into
mainfrom
claude/fix-discriminated-transforms-sHOui
Closed

fix(schemas): add validation for child schemas in discriminated unions#66
leoafarias wants to merge 1 commit into
mainfrom
claude/fix-discriminated-transforms-sHOui

Conversation

@leoafarias

Copy link
Copy Markdown
Member

Discriminated unions require child schemas to return Map types. This commit
adds proper runtime validation with a helpful error message when a child
schema returns a non-Map type (e.g., when using .transform() on a
child schema).

The error message guides users to the correct pattern: apply .transform()
to the discriminated union itself, not to individual child schemas.

Changes:

  • Added runtime type check after child schema validation
  • Added helpful error message explaining the correct transform pattern
  • Added documentation with code example showing correct usage
  • Added test verifying the error message and correct pattern

@docs-page

docs-page Bot commented Jan 19, 2026

Copy link
Copy Markdown

To view this pull requests documentation preview, visit the following URL:

docs.page/btwld/ack~66

Documentation is deployed and generated using docs.page.

Discriminated unions require child schemas to return Map types. This commit
adds proper runtime validation with a helpful error message when a child
schema returns a non-Map type (e.g., when using .transform<Cat>() on a
child schema).

The error message guides users to the correct pattern: apply .transform()
to the discriminated union itself, not to individual child schemas.

Changes:
- Added runtime type check after child schema validation
- Added helpful error message explaining the correct transform pattern
- Added documentation with code example showing correct usage
- Added test verifying the error message and correct pattern
@leoafarias
leoafarias force-pushed the claude/fix-discriminated-transforms-sHOui branch from d59e81c to 1e4adb9 Compare January 19, 2026 15:40
@leoafarias

Copy link
Copy Markdown
Member Author

Closing as superseded by the later discriminated-union contract. Current Ack intentionally supports object-backed transformed child branches and tests parse, safeParse, validation ordering, transform failures, and multi-layer transforms. This PR would restore an obsolete rejection of those branches.

@leoafarias leoafarias closed this Sep 1, 2026
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.

2 participants