Refactored entity validation back into the controller.