added new validation rules, and messages and refactored the register function