using FluentValidation; using Nop.Plugin.MultiFactorAuth.GoogleAuthenticator.Models; using Nop.Services.Localization; using Nop.Web.Framework.Validators; namespace Nop.Plugin.MultiFactorAuth.GoogleAuthenticator.Validators; /// /// Represents an validator. /// public class AuthModelValidator : BaseNopValidator { public AuthModelValidator(ILocalizationService localizationService) { RuleFor(model => model.Code).NotEmpty() .WithMessageAwait(localizationService.GetResourceAsync("Plugins.MultiFactorAuth.GoogleAuthenticator.Fields.Code.Required")); RuleFor(model => model.Code).Matches(@"^[0-9]{6,6}$") .WithMessageAwait(localizationService.GetResourceAsync("Plugins.MultiFactorAuth.GoogleAuthenticator.Fields.Code.Wrong")); } }