TanStack
Form creation

FormOptionsLooseSchemaFn

Type Alias: FormOptionsLooseSchemaFn

ts
type FormOptionsLooseSchemaFn = <TFormValidators, TFormData, TSubmitReturn>(options) => FormOptions<InferUnion<TFormData, FormValidatorData<TFormValidators>>, TFormValidators, TSubmitReturn>;

Defined in: utils.public.ts:150

Infers the form data shape from a Standard Schema validator while allowing editable defaults to contain null or undefined values.

Use this when the schema represents the final valid shape but the UI needs intermediate empty states, such as an unselected date. Raw form state remains available as value; read each validator's parsed output from the corresponding schemaOutputs entry during submission.

At runtime, this returns the original options object and does not run the schema.

Include the schema in validators to provide the type inference and perform validation.

Type Parameters

TFormValidators

TFormValidators extends FormValidators<any>

Library-managed. Do not specify explicitly.

TFormData

TFormData extends NullableSchemaData<TFormValidators>

Library-managed. Do not specify explicitly.

TSubmitReturn

TSubmitReturn

Library-managed. Do not specify explicitly.

Parameters

options

FormOptions<TFormData, TFormValidators, TSubmitReturn>

Returns

FormOptions<InferUnion<TFormData, FormValidatorData<TFormValidators>>, TFormValidators, TSubmitReturn>

The original options object, normalized to FormOptions with nullable and undefined editable states merged into the schema's input shape.

Remarks

Important: Although this returns the original object unchanged at runtime, its type is normalized to FormOptions. Optional properties such as validators therefore remain optional even when supplied. This tradeoff enables safer inference and reuse.

Example

ts
const bookingOptions = formOptions.looseSchema({
  defaultValues: { startDate: null },
  validators: [
    {
      triggers: ['blur'],
      run: z.object({ startDate: z.date() }),
    },
  ],
  onSubmit: ({ schemaOutputs }) => saveBooking(schemaOutputs[0]),
})