Zod validators for TC39 Temporal types with full JSON Schema support.
import * as z from "zod";import { zPlainDate, zInstant } from "temporal-zod";const schema = z.object({ date: zPlainDate, instant: zInstant,});// Parse strings into Temporal objectsconst result = schema.parse({ date: "2023-01-15", instant: "2023-01-15T13:45:30Z",});// Generate JSON Schema with proper Temporal type metadataconst jsonSchema = z.toJSONSchema(schema); Copy
import * as z from "zod";import { zPlainDate, zInstant } from "temporal-zod";const schema = z.object({ date: zPlainDate, instant: zInstant,});// Parse strings into Temporal objectsconst result = schema.parse({ date: "2023-01-15", instant: "2023-01-15T13:45:30Z",});// Generate JSON Schema with proper Temporal type metadataconst jsonSchema = z.toJSONSchema(schema);
temporal-zod on GitHub
Zod validators for TC39 Temporal types with full JSON Schema support.
Example
See
temporal-zod on GitHub