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
Roslyn scripts - add sample for code to validate ZIP Code field in the Address
KrzysztofPajakef2e9c5bdbc9
diff --git a/src/Web/Grand.Web/Roslyn/ZipCodeValidation.csx b/src/Web/Grand.Web/Roslyn/ZipCodeValidation.csxnew file mode 100644index 000000000..c6795a25e--- /dev/null+++ b/src/Web/Grand.Web/Roslyn/ZipCodeValidation.csx@@ -0,0 +1,21 @@+#! "net5.0"+#r "Grand.Infrastructure"+#r "Grand.Web"+#r "Grand.Web.Common"+++using FluentValidation;+using Grand.Infrastructure.Validators;+using Grand.Web.Models.Common;+using System.Threading.Tasks;+using System;++/* Sample code to validate ZIP Code field in the Address */+public class ZipCodeValidation : IValidatorConsumer<AddressModel>+{+ public void AddRules(BaseGrandValidator<AddressModel> validator)+ {+ validator.RuleFor(x => x.ZipPostalCode).Matches(@"^[0-9]{2}\-[0-9]{3}$")+ .WithMessage("Provided zip code is invalid");+ }+}