public static User Create( string email, string name, decimal monthlySalary, decimal monthlyExpense, IUserUniqueValidation userUniqueChecker) { if (string.IsNullOrEmpty(email)) { throw new DomainValidationException("email can not be empty"); } Validate(new UserExpenseMustBeZeroRule(monthlyExpense)); Validate(new UserSalaryMustBeZeroRule(monthlyExpense)); Validate(new UserEmailMustBeUniqueRule(userUniqueChecker, email)); return(new User(email, name, monthlySalary, monthlyExpense)); }
public UserEmailMustBeUniqueRule(IUserUniqueValidation userUniquenessChecker, string email) { _userUniquenessChecker = userUniquenessChecker; _email = email; }