Skip to content

getFieldsInputSchema

getFieldsInputSchema(props): ZodObject<{[key: string]: ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>; }, $strip>

Defined in: packages/core/src/fields/utils.ts:216

Builds the Zod input schema for a field map — a collection’s or a global’s fields. Hidden fields are skipped.

Record<string, unknown>

The merged document being validated (prepareEdit passes transformedFields). When given, every field whose admin.condition evaluates false against (data, siblingData) — where a top-level field’s siblingData is data itself — is built as z.unknown() instead of its real schema: present (so a hidden field’s kept value still round-trips), but neither its required check nor any type/format validation runs. A nested group/array/blocks field threads data through to its own sub-fields/items so a condition anywhere in the tree is honored, not just at the top level. Omit to keep today’s behavior — every field validated regardless of admin.condition — unchanged, for every caller that doesn’t track live form values.

Record<string, AdminField>

The resource’s resolved field map.

boolean

When true, every field — at every nesting depth (group sub-fields, array items, blocks’ block fields, and any further recursion) — is built as if required: false (forwarded to adminFieldToInputSchema’s own ignoreRequired). A configured min/max still applies to a non-empty value exactly as it does for an optional field today; only the “must be present/non-empty” check required itself adds is skipped. saveDraft sets this — a draft may leave a required field empty at any depth; publish/create/update do not.

boolean

When true, every TOP-LEVEL field becomes optional (update/saveDraft’s lenient mode); omit for strict, full-schema validation (create, publish — decision 4).

ZodObject<{[key: string]: ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>; }, $strip>

The object schema.

const schema = getFieldsInputSchema({ fields: posts.fields, partial: true });