-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(content-releases): add missing endpoints to backend docs (#19302)
* docs(content-releases): add missing endpoints to backend docs * Update docs/docs/docs/01-core/content-releases/01-backend.md Co-authored-by: markkaylor <mark.kaylor@strapi.io> * Update docs/docs/docs/01-core/content-releases/01-backend.md Co-authored-by: markkaylor <mark.kaylor@strapi.io> * Update docs/docs/docs/01-core/content-releases/01-backend.md Co-authored-by: markkaylor <mark.kaylor@strapi.io> * apply marks feedback --------- Co-authored-by: markkaylor <mark.kaylor@strapi.io>
- Loading branch information
1 parent
3844395
commit 1df99d4
Showing
2 changed files
with
95 additions
and
1 deletion.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
docs/docs/docs/01-core/admin/05-features/hooks/use-document.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--- | ||
title: unstable_useDocument | ||
description: API reference for the useDocument hook | ||
tags: | ||
- admin | ||
- hooks | ||
- document | ||
- validations | ||
--- | ||
|
||
:::caution | ||
This hook is not stable and **likely to change**. Use at your own risk. | ||
::: | ||
|
||
A hook that returns utilities to work with documents. | ||
|
||
## Usage | ||
|
||
``` | ||
function Component() { | ||
const { validate } = unstable_useDocument(); | ||
} | ||
``` | ||
|
||
At the moment, useDocument only returns a validate function. | ||
|
||
### `validate()` | ||
|
||
```ts | ||
const validate( | ||
entry: Entity, | ||
{ | ||
contentType: Schema.ContentType, | ||
components: { | ||
[key: Schema.Component['uid']]: Schema.Component; | ||
}, | ||
isCreatingEntry?: boolean; | ||
} | ||
): { | ||
errors: { [key: string]: TranslationMessage } | ||
} | ||
``` | ||
|
||
With this function, you can apply the same validations we use in the admin. Please be aware that for this function to work, you need to ensure the following: | ||
|
||
1. If you are validating an entry with relations/components/dynamic zones then it **MUST** be populated. Otherwise, the validations will pass even if there is an error on one populated field. | ||
2. The correct schema for the contentType and the schemas for any components related to that content type are mandatory for this hook to function correctly. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters