Signature
Type Inference
either() creates a union type from all provided decoders:
Basic Usage
How It Works
The decoders are tried on the input one by one, in the given order. The first one that accepts the input “wins”. If all decoders reject the input, the input gets rejected.Error Messages
When all decoders fail,either() collects all error messages:
Union Type Inference
either() correctly infers union types:
Nested Either
The error messages for nestedeither() calls are flattened for readability:
Multiple Decoders
either() accepts any number of decoders:
Performance Note
For tagged unions (objects with a discriminator field), consider usingtaggedUnion() instead for better performance and error messages:
