Skip to content

dateFieldToInputSchema

dateFieldToInputSchema(props): ZodType

Defined in: packages/core/src/fields/date/inputSchema.ts:30

Builds a Zod schema for validating a date field value in the admin form.

Date values are Unix timestamps in milliseconds, so the base schema is z.number(). Required fields attach { error: "This field is required." } to the base call so a missing value is rejected with a “required” message instead of Zod’s generic type-mismatch text, and never receive a .default() — matching applyBaseInputSchemaMeta’s .optional() gate, and unlike the previous .default(Date.now()) that made a missing value indistinguishable from “now” (CORE-1). field.min/field.max — Unix millisecond timestamps — are enforced via .min()/.max() when set (CORE-3); previously they were read nowhere in the schema.

Input props.

DateField

The resolved date field definition

ZodType

A Zod number schema with range constraints and optionality applied

const field = date({ required: true, min: 1700000000000 })
dateFieldToInputSchema({ field })
// → z.number({ error: "This field is required." }).min(1700000000000, "...")