Skip to content

Commit 533ae92

Browse files
authored
docs: fix beforeChange field hook documentation to reflect actual behaviour (#14798)
The current documentation is incorrect as `beforeChange` field hooks are called before field validation runs. This updates the documentation for the `beforeChange` field hook to match the documentation for the `beforeChange` collection hook. Related: #12651
1 parent 4dce061 commit 533ae92

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

docs/hooks/fields.mdx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,7 @@ stored in a consistent format in the database.
118118

119119
### beforeChange
120120

121-
Immediately following validation, `beforeChange` hooks will run within `create` and `update` operations. At this stage,
122-
you can be confident that the field data that will be saved to the document is valid in accordance to your field
123-
validations.
121+
Immediately before validation, beforeChange hooks will run during create and update operations. At this stage, the data should be treated as unvalidated user input. There is no guarantee that required fields exist or that fields are in the correct format. As such, using this data for side effects requires manual validation. You can optionally modify the shape of the data to be saved.
124122

125123
```ts
126124
import type { Field } from 'payload'

0 commit comments

Comments
 (0)