I m trying to use xVal to validate the registration of a new user. I ve ran into a buzz saw when trying to implement the logic that checks to see if the user name that the new user is trying to register with is already taken. I can t seem to find a way to accomplish this without having my User entity have a dependence on my UsersRepository. Here s the method I need to find a way to implement in the my User Entity:
public IEnumerable<ErrorInfo> ValidateUniqueUserName(string username)
{
if(usersRepository.Users.Exists(m => (m.UserName == username)))
yield return new ErrorInfo("UserName", "User name already exists");
}
Any ideas on how I can continue to use xVal for this scenario and keep my User entity decoupled from my UsersRepository?