How to throw a validation error from my plugin field

I’m maintaining a custom wysiwyg plugin using app.addFields({ type: 'wysiwyg', component: Wysiwyg }) , but I do not find in Strapi documentation how to throw an error from within my plugin field.

I want to prevent the user from saving content if there’s a validation error inside my plugin. Let’s say if the plugin field value contains the word “abc123”, I want to prevent the user from saving and display a custom error message:

“You can’t save it because your content has the value abc123”

This topic has been created from a Discord post (1260922602264854548) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord

would love to get some light on this

You need to do it from lifecycle methods