docs: adds jsdocs for filterOptions and syncs docs

This commit is contained in:
Jacob Fletcher
2024-03-14 15:00:03 -04:00
parent 6a43065316
commit cbfc7c8b43
4 changed files with 37 additions and 22 deletions

View File

@@ -83,15 +83,15 @@ There are two arguments available to custom validation functions.
| Property | Description | | Property | Description |
| ------------- | ------------------------------------------------------------------------------------------------------------------------ | | ------------- | ------------------------------------------------------------------------------------------------------------------------ |
| `data` | An object of the full collection or global document. | | `data` | An object containing the full collection or global document currently being edited |
| `siblingData` | An object of the document data limited to fields within the same parent to the field. | | `siblingData` | An object containing document data that is scoped to only fields within the same parent of this field |
| `operation` | Will be "create" or "update" depending on the UI action or API call. | | `operation` | Will be `create` or `update` depending on the UI action or API call |
| `id` | The value of the collection `id`, will be `undefined` on create request. | | `id` | The `id` of the current document being edited. `id` is `undefined` during the `create` operation |
| `t` | The function for translating text, [more](/docs/configuration/i18n). | | `t` | The function for translating text, [more](/docs/configuration/i18n) |
| `user` | The currently authenticated user object. | | `user` | An object containing the currently authenticated user |
| `payload` | If the `validate` function is being executed on the server, Payload will be exposed for easily running local operations. | | `payload` | If the `validate` function is being executed on the server, Payload will be exposed for easily running local operations. |
Example: ### Example
```ts ```ts
import { CollectionConfig } from 'payload/types' import { CollectionConfig } from 'payload/types'

View File

@@ -131,13 +131,13 @@ The `filterOptions` property can either be a `Where` query, or a function return
prevent all, or a `Where` query. When using a function, it will be prevent all, or a `Where` query. When using a function, it will be
called with an argument object with the following properties: called with an argument object with the following properties:
| Property | Description | | Property | Description |
|---------------|--------------------------------------------------------------------------------------| |---------------|--------------------------------------------------------------------------------------------------------------|
| `relationTo` | The `relationTo` to filter against (as defined on the field) | | `relationTo` | The collection `slug` to filter against, limited to this field's `relationTo` property |
| `data` | An object of the full collection or global document currently being edited | | `data` | An object containing the full collection or global document currently being edited |
| `siblingData` | An object of the document data limited to fields within the same parent to the field | | `siblingData` | An object containing document data that is scoped to only fields within the same parent of this field |
| `id` | The value of the collection `id`, will be `undefined` on create request | | `id` | The `id` of the current document being edited. `id` is `undefined` during the `create` operation |
| `user` | The currently authenticated user object | | `user` | An object containing the currently authenticated user |
### Example ### Example

View File

@@ -85,15 +85,15 @@ The `filterOptions` property can either be a `Where` query, or a function return
prevent all, or a `Where` query. When using a function, it will be prevent all, or a `Where` query. When using a function, it will be
called with an argument object with the following properties: called with an argument object with the following properties:
| Property | Description | | Property | Description |
|---------------|--------------------------------------------------------------------------------------| |---------------|--------------------------------------------------------------------------------------------------------------|
| `relationTo` | The `relationTo` to filter against (as defined on the field) | | `relationTo` | The collection `slug` to filter against, limited to this field's `relationTo` property |
| `data` | An object of the full collection or global document currently being edited | | `data` | An object containing the full collection or global document currently being edited |
| `siblingData` | An object of the document data limited to fields within the same parent to the field | | `siblingData` | An object containing document data that is scoped to only fields within the same parent of this field |
| `id` | The value of the collection `id`, will be `undefined` on create request | | `id` | The `id` of the current document being edited. `id` is `undefined` during the `create` operation |
| `user` | The currently authenticated user object | | `user` | An object containing the currently authenticated user |
**Example:** ### Example
```ts ```ts
const uploadField = { const uploadField = {

View File

@@ -80,10 +80,25 @@ export type Condition<T extends TypeWithID = any, P = any> = (
) => boolean ) => boolean
export type FilterOptionsProps<T = any> = { export type FilterOptionsProps<T = any> = {
/**
* An object containing the full collection or global document currently being edited.
*/
data: T data: T
/**
* The `id` of the current document being edited. `id` is undefined during the `create` operation.
*/
id: number | string id: number | string
/**
* The collection `slug` to filter against, limited to this field's `relationTo` property.
*/
relationTo: string relationTo: string
/**
* An object containing document data that is scoped to only fields within the same parent of this field.
*/
siblingData: unknown siblingData: unknown
/**
* An object containing the currently authenticated user.
*/
user: Partial<User> user: Partial<User>
} }