Why Annotate Schemas?
Annotation Types
| Annotation | Purpose | Example |
|---|---|---|
identifier | Unique ID for the schema | "Address.Hex" |
title | Human-readable name for UI/forms | "Ethereum Address" |
description | Explains what the type represents | "A 20-byte Ethereum address..." |
examples | Valid example values | ["0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"] |
message | Custom error message function | () => "Invalid address format" |
default | Default value | "0x0000000000000000000000000000000000000000" |
documentation | Extended documentation | "See EIP-55 for checksum details..." |
Benefits
Better Error Messages
Without annotations, parse errors show raw type information:message annotation:
JSON Schema Generation
Generate OpenAPI-compatible schemas withJSONSchema.make():
Form Integration
Usetitle and description for form labels and help text:
IDE Autocomplete
Annotations surface in IDE hover information, making types self-documenting.Annotation Patterns by Type
Address Types
Hash Types
Numeric Types
Sensitive Types
Accessing Annotations
Custom Error Formatting
UseTreeFormatter with annotated schemas:
See Also
- Branded Types - Type-safe primitives
- Error Handling - Parse error handling patterns
- Effect Schema - Official Effect Schema docs

