add validate to register function