Basic Usage
The.brand() modifier creates branded types, which add a compile-time distinction between values that are structurally identical but semantically different.
Brands are purely a compile-time feature. At runtime, branded values are identical to their base types.
Type Inference
By default, brands only affect the output type:Brand Direction
You can control whether brands apply to input, output, or both:Output Only (Default)
Input Only
Both Input and Output
Multiple Brands
You can apply multiple brands to create a hierarchy:Numeric and Symbol Brands
Brands can be strings, numbers, or symbols:Branded Record Keys
Use Cases
Preventing ID Mixups
Safe Numeric Types
Domain-Driven Design
Validated vs Unvalidated Data
Brand Type Helper
Zod exports theBrand type helper for type annotations: