- Strapi Version: 4
- Operating System: Mac
- Database: mysql
- Node Version: 18.15.0
- NPM Version: 9.5.0
I’m trying to validate the category data using a custom policy, but it seems the execution is not reaching the policy since I’m unable to see the log In validation policy.
being printed.
Here’s the code I’m using:
// src/api/category/policies/validation.ts
export default (policyContext, config, { strapi }) => {
strapi.log.info('In validation policy.');
const canDoSomething = true;
if (canDoSomething) {
return true;
}
return false;
};
I’ve added the policy to the update
route in the router configuration like this:
//src/api/category/routes/category.ts
import { factories } from "@strapi/strapi";
export default factories.createCoreRouter("api::category.category", {
config: {
update: { policies: ["validation"] },
},
});
However, the policy doesn’t seem to be invoked, and I’m not seeing the log output. Any ideas on why this might be happening or how to ensure the policy gets executed?