Add message validation on encode and documentation.