Skip to content

Commit 6a6c4f5

Browse files
committed
docs: improve fieldApi reference
1 parent d1b9a94 commit 6a6c4f5

File tree

1 file changed

+33
-10
lines changed

1 file changed

+33
-10
lines changed

docs/reference/fieldApi.md

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Normally, you will not need to create a new `FieldApi` instance directly. Instea
1111
const fieldApi: FieldApi<TData> = new FieldApi(formOptions: Field Options<TData>)
1212
```
1313

14-
### `FieldOptions<TParentData, TName, ValidatorType, FormValidator, TData>`
14+
### `FieldOptions<TParentData, TName, TFieldValidator, TFormValidator, TData>`
1515

1616
An object type representing the options for a field in a form.
1717

@@ -44,11 +44,25 @@ An object type representing the options for a field in a form.
4444
- If `true`, always run async validation, even if there are errors emitted during synchronous validation.
4545

4646
- ```typescript
47-
validator?: ValidatorType
47+
validatorAdapter?: ValidatorType
4848
```
4949

5050
- A validator provided by an extension, like `yupValidator` from `@tanstack/yup-form-adapter`
5151

52+
53+
- ```tsx
54+
validators?: FieldValidators<
55+
TParentData,
56+
TName,
57+
TFieldValidator,
58+
TFormValidator,
59+
TData
60+
>
61+
```
62+
- A list of validators to pass to the field
63+
64+
### `FieldValidators<TParentData, TName, TFieldValidator, TFormValidator, TData>`
65+
5266
- ```tsx
5367
onMount?: (formApi: FieldApi<TData, TParentData>) => void
5468
```
@@ -93,20 +107,29 @@ An object type representing the options for a field in a form.
93107
- An optional number to represent how long the `onBlurAsyncDebounceMs` should wait before running
94108
- If set to a number larger than 0, will debounce the async validation event by this length of time in milliseconds
95109

96-
```tsx
97-
onSubmitAsync?: number
110+
111+
- ```tsx
112+
onSubmit?: ValidateFn<TData, TParentData>
98113
```
99114

100-
- If set to a number larger than 0, will debounce the async validation event by this length of time in milliseconds. If `validator` is passed, this may also accept a property from the respective validator (IE: `z.string().refine(async (val) => val.length > 3, { message: 'Testing 123' })` if `zodAdapter` is passed)
115+
- An optional function, when that run when subscribing to submit event of input. If `validator` is passed, this may also accept a property from the respective validator (IE: `z.string().min(1)` if `zodAdapter` is passed)
101116

102-
### `ValidationCause`
117+
- ```tsx
118+
onSubmitAsync?: ValidateAsyncFn<TData, TParentData>
119+
```
103120

104-
A type representing the cause of a validation event.
121+
- An optional function that takes a `ValidateFn` which is a generic of `TData` and `TParentData` happens async. If `validator` is passed, this may also accept a property from the respective validator (IE: `z.string().refine(async (val) => val.length > 3, { message: 'Testing 123' })` if `zodAdapter` is passed)
105122

106-
- ```tsx
107-
'change' | 'blur' | 'submit' | 'mount'
123+
```tsx
124+
onSubmitAsyncDebounceMs?: number
108125
```
109126

127+
- An optional number to represent how long the `onSubmitAsyncDebounceMs` should wait before running
128+
- If set to a number larger than 0, will debounce the async validation event by this length of time in milliseconds
129+
130+
131+
132+
110133
### `FieldMeta`
111134

112135
An object type representing the metadata of a field in a form.
@@ -138,7 +161,7 @@ An object type representing the required options for the `FieldApi` class.
138161

139162
- Inherits from `FieldOptions<TData, TParentData>` with the `form` property set as required.
140163

141-
### `FieldApi<TData, TParentData>`
164+
### `FieldApi<TParentData, TName, TFieldValidator, TFormValidator, TData>`
142165

143166
A class representing the API for managing a form field.
144167

0 commit comments

Comments
 (0)