docs: explain lifecycle of validate & beforeValida
Caused confusion here: https://discord.com/channels/967097582721572934/1091785894136139808/1092821186959921193 The initial expectation is that beforeValidate runs before any validation happens. However, it seems that client-side validation happens first nonetheless. Please do check if this is 100% correct before merging.
This commit is contained in:
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user