private void InitializeRules() { RuleFor(r => r.Username) .NotEmpty() .MaximumLength(UserConstants.MaxUsernameLength) .Must((field) => userPersistenceValidator.UserWithUsernameExists(field)); RuleFor(r => r.Password) .NotEmpty() .MinimumLength(UserConstants.MinPasswordLength) .MaximumLength(UserConstants.MaxPasswordLength); }
public AddNewUserCommandValidator(IUserPersistenceValidator userPersistenceValidator) { RuleFor(r => r.Username) .NotEmpty() .MaximumLength(UserConstants.MaxUsernameLength) .Must((u) => !userPersistenceValidator.UserWithUsernameExists(u)); RuleFor(r => r.Password) .NotEmpty() .MinimumLength(UserConstants.MinPasswordLength) .MaximumLength(UserConstants.MaxFirstNameLength); RuleFor(r => r.FirstName) .MaximumLength(UserConstants.MaxFirstNameLength); RuleFor(r => r.LastName) .NotEmpty() .MaximumLength(UserConstants.MaxLastNameLength); }