check if messages are valid before trying to save them