Stop The Creation of Data in BeforeCreate Lifecycle Callback Hook

Just to improve this answer a bit:

module.exports = {
      lifecycles: {
        beforeCreate(data) {
        	if (isNaughtyLink(data.link)) {
        		//throw error here, it will prevent the entry creation
        		throw strapi.errors.badRequest('Some message you want to show in the admin UI');
        	}
        },
      },
    };
3 Likes