Skip to content

Commit bd1bd3d

Browse files
docs: updating docs-field-api removing old doc and updating to new pr… (#423)
* docs: updating docs-field-api removing old doc and updating to new properties * docs: field-api removing disclaimer about API shift
1 parent dc8d88b commit bd1bd3d

File tree

1 file changed

+39
-15
lines changed

1 file changed

+39
-15
lines changed

docs/reference/fieldApi.md

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ title: Field API
55

66
### Creating a new FieldApi Instance
77

8-
> Some of these docs may be inaccurate due to an API shift in `0.11.0`. If you're interested in helping us fix these issues, please [join our Discord](https://tlinz.com/discord) and reach out in the `#form` channel.
8+
99

1010
Normally, you will not need to create a new `FieldApi` instance directly. Instead, you will use a framework hook/function like `useField` or `createField` to create a new instance for you that utilizes your frameworks reactivity model. However, if you need to create a new instance manually, you can do so by calling the `new FieldApi` constructor.
1111

@@ -26,33 +26,57 @@ An object type representing the options for a field in a form.
2626
```
2727
- An optional default value for the field.
2828
- ```tsx
29-
form?: FormApi<TFormData>
29+
defaultMeta?: Partial<FieldMeta>
3030
```
31-
- An optional reference to the form API instance.
31+
- An optional object with default metadata for the field.
32+
3233
- ```tsx
33-
validate?: (value: TData, fieldApi: FieldApi<TData, TFormData>) => ValidationError | Promise<ValidationError>
34+
onMount?: (formApi: FieldApi<TData, TFormData>) => void
3435
```
35-
- An optional validation function for the field.
36+
- An optional function that takes a param of `formApi` which is a generic type of `TData` and `TFormData`
37+
3638
- ```tsx
37-
validatePristine?: boolean
39+
onChange?: ValidateFn<TData, TFormData>
3840
```
39-
- An optional flag indicating whether to validate the field when it is pristine (untouched).
41+
- An optional property that takes a `ValidateFn` which is a generic of `TData` and `TFormData`
42+
4043
- ```tsx
41-
defaultMeta?: Partial<FieldMeta>
44+
onChangeAsync?: ValidateAsyncFn<TData, TFormData>
4245
```
43-
- An optional object with default metadata for the field.
46+
- An optional property similar to `onChange` but async validation
47+
48+
4449
- ```tsx
45-
validateOn?: ValidationCause
50+
onChangeAsyncDebounceMs?: number
4651
```
47-
- An optional string indicating when to perform field validation.
52+
- An optional number to represent how long the `onChangeAsync` should wait before running
53+
- If set to a number larger than 0, will debounce the async validation event by this length of time in milliseconds
54+
4855
- ```tsx
49-
validateAsyncOn?: ValidationCause
56+
onBlur?: ValidateFn<TData, TFormData>
5057
```
51-
- An optional string indicating when to perform async field validation.
58+
- An optional function, when that run when subscribing to blur event of input
59+
5260
- ```tsx
53-
validateAsyncDebounceMs?: number
61+
onBlurAsync?: ValidateAsyncFn<TData, TFormData>
62+
```
63+
- An optional function that takes a `ValidateFn` which is a generic of `TData` and `TFormData` happens async
64+
65+
```tsx
66+
onBlurAsyncDebounceMs?: number
67+
```
68+
- An optional number to represent how long the `onBlurAsyncDebounceMs` should wait before running
69+
- If set to a number larger than 0, will debounce the async validation event by this length of time in milliseconds
70+
71+
```tsx
72+
onSubmitAsync?: number
5473
```
55-
- If set to a number larger than 0, will debounce the async validation event by this length of time in milliseconds.
74+
- If set to a number larger than 0, will debounce the async validation event by this length of time in milliseconds
75+
76+
77+
78+
79+
5680

5781
### `ValidationCause`
5882

0 commit comments

Comments
 (0)