-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Description
Link to the documentation page or resource
Describe the bug
In the documentation it still says to use the old way of sanitizing content in custom controllers, even though this is no longer working.
import { sanitize, validate } from '@strapi/utils';
export default {
async findCustom(ctx) {
const contentType = strapi.contentType('api::test.test');
await validate.contentAPI.query(ctx.query, contentType, { auth: ctx.state.auth });
const sanitizedQueryParams = await sanitize.contentAPI.query(ctx.query, contentType, { auth: ctx.state.auth });
const documents = await strapi.documents(contentType.uid).findMany(sanitizedQueryParams);
return await sanitize.contentAPI.output(documents, contentType, { auth: ctx.state.auth });
}
}
Additional context
In the migration docs it is outline to use the new way:
https://docs.strapi.io/cms/migration/v4-to-v5/breaking-changes/strapi-utils-refactored#additional-notes
// Strapi v4
import { validate, sanitize } from '@strapi/utils';
validate.contentAPI.xxx();
sanitize.contentAPI.xxx();
// Strapi 5
// Those methods require the strapi app context
strapi.contentAPI.sanitize.xxx();
strapi.contentAPI.validate.xxx();
Suggested improvements or fixes
Add the new way to the docs so they are correct again
Related issue(s)/PR(s)
No response
Reactions are currently unavailable