Stop sending changes to users in the room

I need a way to verify the change in the document before sending it to the room. If the change passes the condition, then we proceed with the update of the change, if not, we do nothing. Any advice on how I can do that?