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 |
| ------------- | ------------------------------------------------------------------------------------------------------------------------ |
| `data` | An object of the full collection or global document. |
| `siblingData` | An object of the document data limited to fields within the same parent to the field. |
| `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. |
| `t` | The function for translating text, [more](/docs/configuration/i18n). |
| `user` | The currently authenticated user object. |
| `data` | An object containing the full collection or global document currently being edited |
| `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 |
| `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) |
| `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. |
Example:
### Example
```ts
import { CollectionConfig } from 'payload/types'

View File

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

View File

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

View File

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