Skip to content

textFieldToInputSchema

textFieldToInputSchema(props): ZodType

Defined in: packages/core/src/fields/text/inputSchema.ts:23

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

Applies min/max character-length constraints when configured, then wraps in .optional() for non-required fields via applyBaseInputSchemaMeta.

Input props.

TextField

The resolved text field definition

ZodType

A Zod string schema with length constraints, a baked-in .default(field.defaultValue), and optionality applied

const field = text({ required: true, min: { value: 3 }, max: { value: 100 } })
textFieldToInputSchema({ field })
// → z.string().min(3).max(100).default("")
// (a configured `min` supersedes the bare `.min(1)` required check)