Skip to content

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.

1.5 KB
Raw Blame
using FluentValidation;
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Infrastructure.Validators;
using Shipping.ShippingPoint.Models;

namespace Shipping.ShippingPoint.Validators;

public class ShippingPointValidator : BaseGrandValidator<ShippingPointModel>
{
    public ShippingPointValidator(
        IEnumerable<IValidatorConsumer<ShippingPointModel>> validators,
        ITranslationService translationService)
        : base(validators)
    {
        RuleFor(x => x.ShippingPointName).NotEmpty()
            .WithMessage(translationService.GetResource("Shipping.ShippingPoint.RequiredShippingPointName"));
        RuleFor(x => x.Description).NotEmpty()
            .WithMessage(translationService.GetResource("Shipping.ShippingPoint.RequiredDescription"));
        RuleFor(x => x.OpeningHours).NotEmpty()
            .WithMessage(translationService.GetResource("Shipping.ShippingPoint.RequiredOpeningHours"));
        RuleFor(x => x.CountryId).NotNull()
            .WithMessage(translationService.GetResource("Admin.Address.Fields.Country.Required"));
        RuleFor(x => x.City).NotEmpty()
            .WithMessage(translationService.GetResource("Admin.Address.Fields.City.Required"));
        RuleFor(x => x.Address1).NotEmpty()
            .WithMessage(translationService.GetResource("Admin.Address.Fields.Address1.Required"));
        RuleFor(x => x.ZipPostalCode).NotEmpty()
            .WithMessage(translationService.GetResource("Admin.Address.Fields.ZipPostalCode.Required"));
    }
}