Template inputs
Define portable JSON schemas for nested email inputs and validate fixtures and recipient data without coercion or defaults.
The definition's schema owns the input contract. defineEmail accepts a Standard JSON Schema v1
converter, such as Schema.toStandardJSONSchemaV1 from Effect or a Zod 4 schema. A validator-only
Standard Schema is insufficient. TemplateInput<typeof template> extracts the inferred input type.
Nested objects, arrays, booleans, numbers and strings reach render(input) unchanged after
validation. Defaults are not inserted, values are not coerced and extra properties are not removed.
Render reads real values such as input.customer.name; strings are escaped as content, never
interpreted as markup or interpolation instructions.
The portable profile uses JSON Schema 2020-12 and local JSON Pointer references. Remote references,
format, unsupported keywords and nonportable transforms fail. Input and output validation
contracts from the converter must agree. Use annotations for descriptions and examples.
Named fixtures are actual inputs validated against the same schema before preview and build. Include empty, repeated and conditional cases. Send-time validation remains authoritative because fixtures cannot cover every input. See the complete authoring example.
Related
CSS and Tailwind
Style executable email templates with imported CSS and Tailwind, inspect compatibility findings, and use email primitives for layout.
Conditions and repetition
Use ordinary TypeScript conditions and array mapping against validated email inputs and preview each branch with named fixtures.