Webiant Logo Webiant Logo
  1. No results found.

    Try your search with a different keyword or use * as a wildcard.

ConfigurationValidator.cs

using FluentValidation;
using Nop.Plugin.Tax.Avalara.Models.Configuration;
using Nop.Services.Localization;
using Nop.Web.Framework.Validators;

namespace Nop.Plugin.Tax.Avalara.Validators;

/// 
/// Represents configuration model validator
/// 
public class ConfigurationValidator : BaseNopValidator
{
    #region Ctor

    public ConfigurationValidator(ILocalizationService localizationService)
    {
        RuleFor(model => model.AccountId)
            .NotEmpty()
            .WithMessageAwait(localizationService.GetResourceAsync("Plugins.Tax.Avalara.Fields.AccountId.Required"))
            .When(model => !model.UseSandbox);
        RuleFor(model => model.LicenseKey)
            .NotEmpty()
            .WithMessageAwait(localizationService.GetResourceAsync("Plugins.Tax.Avalara.Fields.LicenseKey.Required"))
            .When(model => !model.UseSandbox);
        RuleFor(model => model.SelectedCountryIds)
            .NotEmpty()
            .WithMessageAwait(localizationService.GetResourceAsync("Plugins.Tax.Avalara.Fields.Countries.Required"))
            .When(model => model.UseItemClassification);
    }

    #endregion
}