refactor validation for register