/// <inheritdoc />
        public CreateUserValidator(
            IUnitOfWork ufw,
            IValidationLocalizer localizer,
            IIdentityAppSettings settings,
            IConfiguration?configuration)
        {
            _ufw = ufw;

            RuleFor(_ => _.Description)
            .Length(0, 250)
            .WithMessage(localizer.Message(ValidationConstants.Max250LengthMessageTemplate))
            .WithName(localizer.Name(FieldNameConstants.Description));

            RuleFor(_ => _.UserName)
            .Length(0, 50)
            .WithMessage(localizer.Message(ValidationConstants.Max50LengthMessageTemplate))
            .NotEmpty()
            .WithMessage(localizer.Message(ValidationConstants.NotEmptyMessageTemplate))
            .Must(Validation.UserNameIsValid)
            .WithMessage(localizer.Message(ValidationConstants.OnlyLatinAndSpecSymbolsTemplate))
            .WithName(localizer.Name(FieldNameConstants.UserName));

            RuleFor(_ => _.UserName)
            .Must(UniqueName)
            .WithMessage(localizer.Message(ValidationConstants.EntityMustBeUniqueTemplate))
            .WithName(localizer.Name(FieldNameConstants.UserName));

            RuleFor(_ => _.RoleId)
            .NotEmpty()
            .WithMessage(localizer.Message(ValidationConstants.NotEmptyMessageTemplate))
            .Must(RoleExists)
            .WithMessage(localizer.Message(ValidationConstants.RoleNotFoundTemplate))
            .WithName(localizer.Name(FieldNameConstants.Role));

            RuleFor(_ => _.Password)
            .NotEmpty()
            .WithMessage(localizer.Message(ValidationConstants.NotEmptyMessageTemplate))
            .WithName(localizer.Name(FieldNameConstants.Password));

            PasswordRulesHelper.PasswordBaseRules(
                this,
                settings.PasswordPolicy,
                _ => _.Password,
                localizer,
                configuration,
                FieldNameConstants.Password);

            RuleFor(_ => _.Password)
            .Length(settings.PasswordPolicy.MinimumLength, settings.PasswordPolicy.MaximumLength)
            .WithMessage(
                localizer.Message(ValidationConstants.PasswordRequiredLength, settings.PasswordPolicy.MinimumLength, settings.PasswordPolicy.MaximumLength))
            .When(_ => !string.IsNullOrWhiteSpace(_.Password))
            .WithName(localizer.Name(FieldNameConstants.Password));
        }
        /// <inheritdoc />
        public ChangePasswordValidator(
            IValidationLocalizer localizer,
            IHttpContextAccessor accessor,
            UserManager <User> userManager,
            IIdentityAppSettings settings,
            IConfiguration configuration)
        {
            _userManager = userManager;

            RuleFor(_ => _.NewPassword)
            .NotEmpty()
            .WithMessage(localizer.Message(ValidationConstants.NotEmptyMessageTemplate))
            .WithName(localizer.Name(FieldNameConstants.NewPassword));

            RuleFor(_ => _.NewPassword)
            .MustAsync((_, x, y) => CheckNewPassword(accessor.HttpContext !.User !.Identity !.Name !, _))
            .WithMessage(localizer.Message(ValidationConstants.OldAndNewPassMatch))
            .WithName(localizer.Name(FieldNameConstants.NewPassword));

            RuleFor(_ => _.ConfirmNewPassword)
            .Must((x, y) => x.ConfirmNewPassword == x.NewPassword)
            .WithMessage(localizer.Message(ValidationConstants.NewPassAndConfirmMustBeEqual))
            .WhenAsync((_, x) => CheckOldPass(accessor.HttpContext !.User.Identity !.Name !, _.OldPassword));

            RuleFor(_ => _.OldPassword)
            .MustAsync((_, x) => CheckOldPass(accessor.HttpContext !.User.Identity !.Name !, _))
            .WithMessage(localizer.Message(ValidationConstants.CurrentPasswordIncorrectTemplate));

            PasswordRulesHelper.PasswordBaseRules(
                this,
                settings.PasswordPolicy,
                _ => _.NewPassword,
                localizer,
                configuration,
                FieldNameConstants.NewPassword);

            RuleFor(_ => _.NewPassword)
            .Length(settings.PasswordPolicy.MinimumLength, settings.PasswordPolicy.MaximumLength)
            .WithMessage(
                localizer.Message(ValidationConstants.PasswordRequiredLength, settings.PasswordPolicy.MinimumLength, settings.PasswordPolicy.MaximumLength))
            .When(_ => !string.IsNullOrWhiteSpace(_.NewPassword))
            .WithName(localizer.Name(FieldNameConstants.NewPassword));
        }
        /// <inheritdoc />
        public ChangePasswordForUserValidator(
            IValidationLocalizer localizer,
            IIdentityAppSettings settings,
            IUnitOfWork ufw,
            IConfiguration?configuration)
        {
            _ufw = ufw;
            RuleFor(_ => _.UserId)
            .NotEmpty()
            .WithMessage(localizer.Message(ValidationConstants.NotEmptyMessageTemplate))
            .WithName(localizer.Name(FieldNameConstants.User));

            RuleFor(_ => _.UserId)
            .Must(UserExists)
            .WithMessage(localizer.Message(ValidationConstants.UserNotFound));

            RuleFor(_ => _.NewPassword)
            .NotEmpty()
            .WithMessage(localizer.Message(ValidationConstants.NotEmptyMessageTemplate))
            .WithName(localizer.Name(FieldNameConstants.Password));

            PasswordRulesHelper.PasswordBaseRules(
                this,
                settings.PasswordPolicy,
                _ => _.NewPassword,
                localizer,
                configuration,
                FieldNameConstants.Password);

            RuleFor(_ => _.NewPassword)
            .Length(settings.PasswordPolicy.MinimumLength, settings.PasswordPolicy.MaximumLength)
            .WithMessage(
                localizer.Message(ValidationConstants.PasswordRequiredLength, settings.PasswordPolicy.MinimumLength, settings.PasswordPolicy.MaximumLength))
            .When(_ => !string.IsNullOrWhiteSpace(_.NewPassword))
            .WithName(localizer.Name(FieldNameConstants.NewPassword));
        }