Hello,
I’m using strapi 4.25.11
I’m trying to add a custom validation before create/update for the content manager in admin panel.
I’m working on lifecycles throwing an error , I always have “500 internal server error” instead of the message, for any kind of error I throw.
I suspect also that lifecycles are not meant to throw errors, does anybody know how to throw a custom validation exception and dislpay the desired message in ContentManager for a specific content type?
This topic has been created from a Discord post (1283780517199614040) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord
Hi. Do you have a repo or some sample code to look at ?
I’ve found the issue. The problem is that in strapi there is an abuse of instanceof conditions. Since strapi is a plungin based library and due to the way node traverses the class path resolution instanceof sould be totally avoided since a ValidationError for example could not return true in a if (err instanceof ValidationError)
because the ValidationError
the code is referring to belongs to different package.
This happens for example when you create a plugin inside your strapi project since you will have two different node_modules cp.
I’ve soplved moving out of strapi my plugin. Cleaning and tiding dependencies and usgin yalc
for local dependency management
Great news . Thanks for the aheads up !