title: UserValidator in Microsoft.AspNet.Identity vnext
body: <p>I have a problem where I cant use email addresses as usernames when using microsoft.aspnet.identity (Individual user accounts selected when creating new project - default mvc project template for asp.net 5). I have read in many places that this is the solution:</p>
  
  <pre><code>UserManager.UserValidator = new UserValidator&lt;ApplicationUser&gt;(UserManager) { AllowOnlyAlphanumericUserNames = false };
  </code></pre>
  
  <p>But in the new version of asp.net identity, UserManager doesnt seem to have a property called UserValidator. The "UserValidator" is recognised but I suppose its added to the UserManager in a different way now. I cant see any relevant property on UserManager.</p>
  
  <p>Edit:</p>
  
  <p>The unit tests in the github repo for "Identity" has a test for this case. Its currently the last one in this file:</p>
  
  <p><a href="https://github.com/aspnet/Identity/blob/dev/test/Microsoft.AspNet.Identity.Test/UserValidatorTest.cs" rel="nofollow">https://github.com/aspnet/Identity/blob/dev/test/Microsoft.AspNet.Identity.Test/UserValidatorTest.cs</a></p>
  
  <p>I guess this should give a clue as to the answer but I cant see where this would go in my code.</p>
  
  <pre><code>    [Theory]
      [InlineData("test_email@foo.com", true)]
      [InlineData("hao", true)]
      [InlineData("test123", true)]
      [InlineData("!noway", true)]
      [InlineData("foo@boz#.com", true)]
      public async Task CanAllowNonAlphaNumericUserName(string userName, bool expectSuccess)
      {
          // Setup
          var manager = MockHelpers.TestUserManager(new NoopUserStore());
          manager.Options.User.UserNameValidationRegex = null;
          var validator = new UserValidator&lt;TestUser&gt;();
          var user = new TestUser {UserName = userName};
  
          // Act
          var result = await validator.ValidateAsync(manager, user);
  
          // Assert
          if (expectSuccess)
          {
              IdentityResultAssert.IsSuccess(result);
          }
          else
          {
              IdentityResultAssert.IsFailure(result);
          }
      }
  </code></pre>