Open History to see the last commit
1---
2id: FormOptionsApi
3title: FormOptionsApi
4---
5β
6Defined in: [utils.public.ts:205](https://github.com/TanStack/form/blob/main/packages/form-core/src/utils.public.ts#L205)
7β
8The callable API exposed by `formOptions`, including its schema-driven
9inference modes.
10β
11Use `formOptions` directly instead of naming this interface in application
12code.
13β
14## Type Parameters
15β
16### TComponents
17β
18`TComponents`
19β
20Library-managed. Do not specify explicitly.
21β
22```ts
23FormOptionsApi<TFormData, TFormValidators, TSubmitReturn>(options): FormOptions<TFormData, TFormValidators, TSubmitReturn, TComponents>;
24```
25β
26Defined in: [utils.public.ts:226](https://github.com/TanStack/form/blob/main/packages/form-core/src/utils.public.ts#L226)
27β
28Keeps types inferred from `defaultValues`, validators, and submission
29callbacks when form options are declared separately.
30β
31`defaultValues` determine the form data shape in this mode. At runtime,
32this returns the original options object and does not create a form or run
33validation.
34β
35## Type Parameters
36β
37### TFormData
38β
39`TFormData`
40β
41Library-managed. Do not specify explicitly.
42β
43### TFormValidators
44β
45`TFormValidators` *extends* [`FormValidators`](../type-aliases/FormValidators.md)\<`TFormData`\>
46β
47Library-managed. Do not specify explicitly.
48β
49### TSubmitReturn
50β
51`TSubmitReturn`
52β
53Library-managed. Do not specify explicitly.
54β
55## Parameters
56β
57### options
58β
59[`FormOptions`](FormOptions.md)\<`TFormData`, `TFormValidators`, `TSubmitReturn`, `unknown`\>
60β
61## Returns
62β
63[`FormOptions`](FormOptions.md)\<`TFormData`, `TFormValidators`, `TSubmitReturn`, `TComponents`\>
64β
65The original options object, normalized to `FormOptions` with its
66inferred form data, validator, and submission types.
67β
68## Remarks
69β
70**Important:** Although this returns the original object unchanged at
71runtime, its type is normalized to `FormOptions`. Optional properties such
72as `validators` therefore remain optional even when supplied. This
73tradeoff enables safer inference and reuse.
74β
75## Properties
76β
77### looseSchema
78β
79```ts
80looseSchema: FormOptionsLooseSchemaFn<TComponents>;
81```
82β
83Defined in: [utils.public.ts:332](https://github.com/TanStack/form/blob/main/packages/form-core/src/utils.public.ts#L332)
84β
85Infers the form data shape from a Standard Schema validator while allowing
86editable defaults to omit properties or contain `null` or `undefined`
87values.
88β
89Use this when the schema represents the final valid shape but the UI needs
90intermediate empty states, such as an unselected date. Raw form state
91remains available as `value`; read each validator's parsed output from the
92corresponding `validatorOutputs` entry during submission.
93β
94Pass the schema as the first argument and the options as the second.
95`defaultValues` infer an editable form shape constrained by the schema
96input, and callbacks receive that shape merged with the schema input. The
97first argument is ignored at runtime; include the schema in `validators`
98when it should run.
99β
100#### Remarks
101β
102**Important:** Although this returns the original object unchanged at
103runtime, its type is normalized to `FormOptions`. Optional properties such
104as `validators` therefore remain optional even when supplied. This
105tradeoff enables safer inference and reuse.
106β
107#### Example
108β
109```ts
110const bookingSchema = z.object({ startDate: z.date() })
111const bookingOptions = formOptions.looseSchema(bookingSchema, {
112 defaultValues: { startDate: null },
113 validators: [
114 {
115 triggers: ['blur'],
116 run: bookingSchema,
117 },
118 {
119 triggers: ['change'],
120 run: ({ value }) =>
121 value.startDate === null ? 'Choose a date' : undefined,
122 },
123 ],
124 onSubmit: ({ validatorOutputs }) => saveBooking(validatorOutputs[0]),
125})
126```
127β
128#### Returns
129β
130The original options object, normalized to `FormOptions` with
131omitted, nullable, and undefined editable states merged into the schema's
132input shape.
133β
134#### Type Param
135β
136**TSchema**
137β
138Library-managed. Do not specify explicitly.
139β
140#### Type Param
141β
142**TFormValidators**
143β
144Library-managed. Do not specify explicitly.
145β
146#### Type Param
147β
148**TFormData**
149β
150Library-managed. Do not specify explicitly.
151β
152#### Type Param
153β
154**TSubmitReturn**
155β
156Library-managed. Do not specify explicitly.
157β
158***
159β
160### strictSchema
161β
162```ts
163strictSchema: FormOptionsStrictSchemaFn<TComponents>;
164```
165β
166Defined in: [utils.public.ts:280](https://github.com/TanStack/form/blob/main/packages/form-core/src/utils.public.ts#L280)
167β
168Infers the form data type from a Standard Schema validator and requires
169`defaultValues` to match the schema input.
170β
171Use this when the schema represents an input-to-output pipeline. Raw form
172state remains available as `value`; read each validator's parsed output
173from the corresponding `validatorOutputs` entry during submission.
174β
175Pass the schema as the first argument and the options as the second. This
176fixes the form data to the schema input before the options are inferred, so
177each callback receives a typed `value`. The first argument is ignored at
178runtime; include the schema in `validators` when it should run.
179β
180#### Remarks
181β
182**Important:** Although this returns the original object unchanged at
183runtime, its type is normalized to `FormOptions`. Optional properties such
184as `validators` therefore remain optional even when supplied. This
185tradeoff enables safer inference and reuse.
186β
187#### Example
188β
189```ts
190const profileSchema = z.object({ name: z.string().min(1) })
191const profileOptions = formOptions.strictSchema(profileSchema, {
192 defaultValues: { name: '' },
193 validators: [
194 {
195 triggers: ['change'],
196 run: profileSchema,
197 },
198 {
199 triggers: ['change'],
200 run: ({ value }) =>
201 value.name.length === 0 ? 'Name is required' : undefined,
202 },
203 ],
204 onSubmit: ({ validatorOutputs }) => saveProfile(validatorOutputs[0]),
205})
206```
207β
208#### Returns
209β
210The original options object, normalized to `FormOptions` with the
211schema's input shape.
212β
213#### Type Param
214β
215**TSchema**
216β
217Library-managed. Do not specify explicitly.
218β
219#### Type Param
220β
221**TFormValidators**
222β
223Library-managed. Do not specify explicitly.
224β
225#### Type Param
226β
227**TFormData**
228β
229Library-managed. Do not specify explicitly.
230β
231#### Type Param
232β
233**TSubmitReturn**
234β
235Library-managed. Do not specify explicitly.