Skip to content

Commit

Permalink
docs: updating docs-field-api removing old doc and updating to new pr… (
Browse files Browse the repository at this point in the history
#423)

* docs: updating docs-field-api removing old doc and updating to new properties

* docs: field-api removing disclaimer about API shift
  • Loading branch information
enyelsequeira authored Aug 31, 2023
1 parent dc8d88b commit bd1bd3d
Showing 1 changed file with 39 additions and 15 deletions.
54 changes: 39 additions & 15 deletions docs/reference/fieldApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ title: Field API

### Creating a new FieldApi Instance

> 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.


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.

Expand All @@ -26,33 +26,57 @@ An object type representing the options for a field in a form.
```
- An optional default value for the field.
- ```tsx
form?: FormApi<TFormData>
defaultMeta?: Partial<FieldMeta>
```
- An optional reference to the form API instance.
- An optional object with default metadata for the field.

- ```tsx
validate?: (value: TData, fieldApi: FieldApi<TData, TFormData>) => ValidationError | Promise<ValidationError>
onMount?: (formApi: FieldApi<TData, TFormData>) => void
```
- An optional validation function for the field.
- An optional function that takes a param of `formApi` which is a generic type of `TData` and `TFormData`

- ```tsx
validatePristine?: boolean
onChange?: ValidateFn<TData, TFormData>
```
- An optional flag indicating whether to validate the field when it is pristine (untouched).
- An optional property that takes a `ValidateFn` which is a generic of `TData` and `TFormData`

- ```tsx
defaultMeta?: Partial<FieldMeta>
onChangeAsync?: ValidateAsyncFn<TData, TFormData>
```
- An optional object with default metadata for the field.
- An optional property similar to `onChange` but async validation


- ```tsx
validateOn?: ValidationCause
onChangeAsyncDebounceMs?: number
```
- An optional string indicating when to perform field validation.
- An optional number to represent how long the `onChangeAsync` should wait before running
- If set to a number larger than 0, will debounce the async validation event by this length of time in milliseconds

- ```tsx
validateAsyncOn?: ValidationCause
onBlur?: ValidateFn<TData, TFormData>
```
- An optional string indicating when to perform async field validation.
- An optional function, when that run when subscribing to blur event of input

- ```tsx
validateAsyncDebounceMs?: number
onBlurAsync?: ValidateAsyncFn<TData, TFormData>
```
- An optional function that takes a `ValidateFn` which is a generic of `TData` and `TFormData` happens async

```tsx
onBlurAsyncDebounceMs?: number
```
- An optional number to represent how long the `onBlurAsyncDebounceMs` should wait before running
- If set to a number larger than 0, will debounce the async validation event by this length of time in milliseconds

```tsx
onSubmitAsync?: number
```
- If set to a number larger than 0, will debounce the async validation event by this length of time in milliseconds.
- If set to a number larger than 0, will debounce the async validation event by this length of time in milliseconds






### `ValidationCause`

Expand Down

0 comments on commit bd1bd3d

Please sign in to comment.