Learnings
- Type safety:
- Zod 4.x uses ‘invalid_value’ code and ‘.values’ property for enum/literal failures, which aren’t always reflected in standard types.
- Used a ‘Narrow Interface’ ({ values?: string[] }) and ‘as unknown as Narrow’ to safely probe for this metadata without using ‘any’.
- Decoupled Zod schemas from user-facing messages by centralizing error formatting in the Importer layer for dynamic decoration and path mapping.