Skip to content

Commit

Permalink
Merge pull request #2448 from AlessioGr/patch-4
Browse files Browse the repository at this point in the history
docs: explain lifecycle of validate & beforeValidate
  • Loading branch information
jmikrut authored Apr 11, 2023
2 parents ff89b8f + b76c25c commit 7eec16e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion docs/hooks/collections.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,13 @@ const beforeOperationHook: CollectionBeforeOperationHook = async ({

### beforeValidate

Runs before the `create` and `update` operations. This hook allows you to add or format data before the incoming data is validated.
Runs before the `create` and `update` operations. This hook allows you to add or format data before the incoming data is validated server-side.

Please do note that this does not run before the client-side validation. If you added a `validate` function, this would be the lifecycle:

1. `validate` runs on the client
2. if successful, `beforeValidate` runs on the server
3. `validate` runs on the server

```ts
import { CollectionBeforeOperationHook } from 'payload/types';
Expand Down

0 comments on commit 7eec16e

Please sign in to comment.