Skip to content

checkboxFieldToInputSchema

checkboxFieldToInputSchema(props): ZodType

Defined in: packages/core/src/fields/checkbox/inputSchema.ts:31

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

Checkbox fields are always boolean. Required fields attach { error: "This field is required." } to the base z.boolean() call and never receive .default() — previously an unconditional .default(field.defaultValue) meant true, false, and a missing value all passed a “required” checkbox (CORE-1). Optional fields keep .default(field.defaultValue).

Input props.

CheckboxField

The resolved checkbox field definition

ZodType

A Zod boolean schema with optionality and default applied

const field = checkbox({ required: true })
checkboxFieldToInputSchema({ field })
// → z.boolean({ error: "This field is required." })
const optionalField = checkbox()
checkboxFieldToInputSchema({ field: optionalField })
// → z.boolean().default(false)