Added validation for messagesController.js