Refactor validation in register()