Is there a way to stop deleting / updating a record in lifecycle with an error message in backend?

I would rather use a middleware or policy for this.