Skip to content

Conversation

@leoafarias
Copy link
Collaborator

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
Copy link

docs-page bot commented Jan 19, 2026

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
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.

3 participants