diff --git a/docs/fields/overview.mdx b/docs/fields/overview.mdx index e96b14192..a006c64d0 100644 --- a/docs/fields/overview.mdx +++ b/docs/fields/overview.mdx @@ -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' diff --git a/docs/fields/relationship.mdx b/docs/fields/relationship.mdx index d7bd48e42..0a07fe0c1 100644 --- a/docs/fields/relationship.mdx +++ b/docs/fields/relationship.mdx @@ -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 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 | +| Property | Description | +|---------------|--------------------------------------------------------------------------------------------------------------| +| `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 diff --git a/docs/fields/upload.mdx b/docs/fields/upload.mdx index 8149ae159..7db96525a 100644 --- a/docs/fields/upload.mdx +++ b/docs/fields/upload.mdx @@ -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 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 | +| Property | Description | +|---------------|--------------------------------------------------------------------------------------------------------------| +| `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 = { diff --git a/packages/payload/src/fields/config/types.ts b/packages/payload/src/fields/config/types.ts index 72c91cb77..0e0b1653a 100644 --- a/packages/payload/src/fields/config/types.ts +++ b/packages/payload/src/fields/config/types.ts @@ -80,10 +80,25 @@ export type Condition = ( ) => boolean export type FilterOptionsProps = { + /** + * 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 }