Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.
C# aspnet-corecsharpdockerdotnetecommerceecommerce-platformmongodbmulti-storemulti-vendornosqlonline-shopshoppingcart
using FluentValidation;
using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Domain.Common;
using Grand.Domain.Vendors;
using Grand.Infrastructure.Models;
using Grand.Infrastructure.Validators;
using Grand.SharedKernel.Captcha;
using Grand.Web.Common.Validators;
using Grand.Web.Models.Vendors;
namespace Grand.Web.Validators.Vendors;
public class ApplyVendorValidator : BaseGrandValidator<ApplyVendorModel>
{
public ApplyVendorValidator(
IEnumerable<IValidatorConsumer<ApplyVendorModel>> validators,
IEnumerable<IValidatorConsumer<ICaptchaValidModel>> validatorsCaptcha,
IEnumerable<IValidatorConsumer<VendorAddressModel>> addressvalidators,
ITranslationService translationService, ICountryService countryService,
CaptchaSettings captchaSettings,
IHttpContextAccessor contextAccessor, IGoogleReCaptchaValidator googleReCaptchaValidator,
VendorSettings addressSettings)
: base(validators)
{
RuleFor(x => x.Name).NotEmpty()
.WithMessage(translationService.GetResource("Vendors.ApplyAccount.Name.Required"));
RuleFor(x => x.Email).NotEmpty()
.WithMessage(translationService.GetResource("Vendors.ApplyAccount.Email.Required"));
RuleFor(x => x.Email).EmailAddress().WithMessage(translationService.GetResource("Common.WrongEmail"));
RuleFor(x => x.Address)
.SetValidator(new VendorAddressValidator(addressvalidators, translationService, countryService,
addressSettings));
if (captchaSettings.Enabled && captchaSettings.ShowOnApplyVendorPage)
{
RuleFor(x => x.Captcha).NotNull().WithMessage(translationService.GetResource("Account.Captcha.Required"));
RuleFor(x => x.Captcha)
.SetValidator(new CaptchaValidator(validatorsCaptcha, contextAccessor, googleReCaptchaValidator));
}
}
}