public CreateUserValidator(IEmailAlreadyExistsCount emailAlreadyExistsCount) { _emailAlreadyExistsCount = emailAlreadyExistsCount; RuleFor(u => u.Email) .NotEmpty() .WithMessage(ValidationMessages.GetRequired(nameof(CreateUserRequest.Email))) .MaximumLength(User.EmailMaxLength) .WithMessage(ValidationMessages.GetTooLong(nameof(CreateUserRequest.Email))) .MustAsync(ValidEmail) .WithMessage(ValidationMessages.GetValidRequired(nameof(CreateUserRequest.Email))) .MustAsync(EmailNotAlreadyExists) .WithMessage(ValidationMessages.GetItsInUse(nameof(CreateUserRequest.Email))); RuleFor(u => u.Name) .NotEmpty() .WithMessage(ValidationMessages.GetRequired(nameof(CreateUserRequest.Name))) .MinimumLength(User.NameMinLength) .WithMessage(ValidationMessages.GetTooShort(nameof(CreateUserRequest.Name))) .MaximumLength(User.NameMaxLength) .WithMessage(ValidationMessages.GetTooLong(nameof(CreateUserRequest.Name))); RuleFor(u => u.Birthdate) .Must(BeAValidDate) .WithMessage(ValidationMessages.GetOutOfRange(nameof(CreateUserRequest.Birthdate))); RuleFor(u => u.GenderId) .NotEmpty(); }