Skip to content

Commit 6afcb67

Browse files
committed
* Updated FluentValidator (FV) to version 7.4
* Made FV inbuilt translations customizable > resource key pattern: Validation.{ValidatorName} * Added validator 'CreditCardCvvNumber'
1 parent 086e223 commit 6afcb67

24 files changed

+118
-98
lines changed

src/Libraries/SmartStore.Data/Migrations/MigrationsConfiguration.cs

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,35 @@ public void MigrateLocaleResources(LocaleResourcesBuilder builder)
5353

5454
builder.AddOrUpdate("Admin.Catalog.Customers.CustomerSearchType", "Search in:", "Suche in:");
5555

56+
// Fix some FluentValidation german translations
57+
builder.AddOrUpdate("Validation.LengthValidator")
58+
.Value("de", "'{PropertyName}' muss zwischen {MinLength} und {MaxLength} Zeichen lang sein. Sie haben {TotalLength} Zeichen eingegeben.");
59+
builder.AddOrUpdate("Validation.MinimumLengthValidator")
60+
.Value("de", "'{PropertyName}' muss mind. {MinLength} Zeichen lang sein. Sie haben {TotalLength} Zeichen eingegeben.");
61+
builder.AddOrUpdate("Validation.MaximumLengthValidator")
62+
.Value("de", "'{PropertyName}' darf max. {MaxLength} Zeichen lang sein. Sie haben {TotalLength} Zeichen eingegeben.");
63+
builder.AddOrUpdate("Validation.ExactLengthValidator")
64+
.Value("de", "'{PropertyName}' muss genau {MaxLength} lang sein. Sie haben {TotalLength} Zeichen eingegeben.");
65+
builder.AddOrUpdate("Validation.ExclusiveBetweenValidator")
66+
.Value("de", "'{PropertyName}' muss größer als {From} und kleiner als {To} sein. Sie haben '{Value}' eingegeben.");
67+
builder.AddOrUpdate("Validation.InclusiveBetweenValidator")
68+
.Value("de", "'{PropertyName}' muss zwischen {From} and {To} liegen. Sie haben '{Value}' eingegeben.");
69+
builder.AddOrUpdate("Validation.NotNullValidator")
70+
.Value("de", "'{PropertyName}' ist erforderlich.");
71+
builder.AddOrUpdate("Validation.NotEmptyValidator")
72+
.Value("de", "'{PropertyName}' ist erforderlich.");
73+
builder.AddOrUpdate("Validation.LessThanValidator")
74+
.Value("de", "'{PropertyName}' muss kleiner sein als '{ComparisonValue}'.");
75+
builder.AddOrUpdate("Validation.RegularExpressionValidator")
76+
.Value("de", "'{PropertyName}' entspricht nicht dem erforderlichen Muster.");
77+
builder.AddOrUpdate("Validation.ScalePrecisionValidator")
78+
.Value("de", "'{PropertyName}' darf insgesamt nicht mehr als {expectedPrecision} Ziffern enthalten, unter Berücksichtigung von {expectedScale} Dezimalstellen. {digits} Ziffern und {actualScale} Dezimalstellen wurden gefunden.");
79+
80+
// Some new resources for custom validators
81+
builder.AddOrUpdate("Validation.CreditCardCvvNumberValidator",
82+
"'{PropertyName}' is invalid.",
83+
"'{PropertyName}' ist ungültig.");
84+
5685
// Get rid of duplicate validator resource entries
5786
builder.Delete(
5887
"Admin.Catalog.Products.Fields.Name.Required",
@@ -153,8 +182,9 @@ public void MigrateLocaleResources(LocaleResourcesBuilder builder)
153182
"Admin.Validation.UsernamePassword",
154183
"Admin.DataExchange.Export.FileNamePattern.Validate",
155184
"Admin.DataExchange.Export.Partition.Validate",
156-
"Admin.Common.WrongEmail"
157-
);
185+
"Admin.Common.WrongEmail",
186+
"Payment.CardCode.Wrong"
187+
);
158188

159189
// Get rid of duplicate CreatedOn resources also
160190
builder.Delete(

src/Plugins/SmartStore.GoogleMerchantCenter/SmartStore.GoogleMerchantCenter.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,9 @@
9999
<HintPath>..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath>
100100
<Private>False</Private>
101101
</Reference>
102-
<Reference Include="FluentValidation, Version=6.4.1.0, Culture=neutral, processorArchitecture=MSIL">
103-
<HintPath>..\..\packages\FluentValidation.6.4.1\lib\Net45\FluentValidation.dll</HintPath>
102+
<Reference Include="FluentValidation, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7de548da2fbae0f0, processorArchitecture=MSIL">
103+
<HintPath>..\..\packages\FluentValidation.7.4.0\lib\net45\FluentValidation.dll</HintPath>
104+
<Private>True</Private>
104105
</Reference>
105106
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
106107
<HintPath>..\..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>

src/Plugins/SmartStore.GoogleMerchantCenter/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<package id="Autofac" version="4.5.0" targetFramework="net452" />
44
<package id="Autofac.Mvc5" version="4.0.2" targetFramework="net452" />
55
<package id="EntityFramework" version="6.2.0" targetFramework="net461" />
6-
<package id="FluentValidation" version="6.4.1" targetFramework="net452" />
6+
<package id="FluentValidation" version="7.4.0" targetFramework="net461" />
77
<package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net45" />
88
<package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net45" />
99
<package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net45" />

src/Plugins/SmartStore.OfflinePayment/SmartStore.OfflinePayment.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,9 @@
8686
<Reference Include="Autofac, Version=4.5.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
8787
<HintPath>..\..\packages\Autofac.4.5.0\lib\net45\Autofac.dll</HintPath>
8888
</Reference>
89-
<Reference Include="FluentValidation, Version=6.4.1.0, Culture=neutral, processorArchitecture=MSIL">
90-
<HintPath>..\..\packages\FluentValidation.6.4.1\lib\Net45\FluentValidation.dll</HintPath>
89+
<Reference Include="FluentValidation, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7de548da2fbae0f0, processorArchitecture=MSIL">
90+
<HintPath>..\..\packages\FluentValidation.7.4.0\lib\net45\FluentValidation.dll</HintPath>
91+
<Private>True</Private>
9192
</Reference>
9293
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
9394
<HintPath>..\..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>

src/Plugins/SmartStore.OfflinePayment/Validators/ManualPaymentInfoValidator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ public ManualPaymentInfoValidator(ILocalizationService localizationService)
1414
//http://benjii.me/2010/11/credit-card-validator-attribute-for-asp-net-mvc-3/
1515

1616
RuleFor(x => x.CardholderName).NotEmpty().WithMessage(localizationService.GetResource("Payment.CardholderName.Required"));
17-
RuleFor(x => x.CardNumber).IsCreditCard().WithMessage(localizationService.GetResource("Payment.CardNumber.Wrong"));
18-
RuleFor(x => x.CardCode).Matches(@"^[0-9]{3,4}$").WithMessage(localizationService.GetResource("Payment.CardCode.Wrong"));
17+
RuleFor(x => x.CardNumber).CreditCard().WithMessage(localizationService.GetResource("Payment.CardNumber.Wrong"));
18+
RuleFor(x => x.CardCode).CreditCardCvvNumber();
1919
}
2020
}
2121
}

src/Plugins/SmartStore.OfflinePayment/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
33
<package id="Autofac" version="4.5.0" targetFramework="net452" />
4-
<package id="FluentValidation" version="6.4.1" targetFramework="net452" />
4+
<package id="FluentValidation" version="7.4.0" targetFramework="net461" />
55
<package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net45" />
66
<package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net45" />
77
<package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net45" />

src/Plugins/SmartStore.PayPal/SmartStore.PayPal.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,9 @@
6666
<Reference Include="Autofac.Integration.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
6767
<HintPath>..\..\packages\Autofac.Mvc5.4.0.2\lib\net45\Autofac.Integration.Mvc.dll</HintPath>
6868
</Reference>
69-
<Reference Include="FluentValidation, Version=6.4.1.0, Culture=neutral, processorArchitecture=MSIL">
70-
<HintPath>..\..\packages\FluentValidation.6.4.1\lib\Net45\FluentValidation.dll</HintPath>
69+
<Reference Include="FluentValidation, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7de548da2fbae0f0, processorArchitecture=MSIL">
70+
<HintPath>..\..\packages\FluentValidation.7.4.0\lib\net45\FluentValidation.dll</HintPath>
71+
<Private>True</Private>
7172
</Reference>
7273
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
7374
<HintPath>..\..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>

src/Plugins/SmartStore.PayPal/Validators/PayPalDirectPaymentInfoValidator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ public PaymentInfoValidator(ILocalizationService localizationService) {
1313
//http://benjii.me/2010/11/credit-card-validator-attribute-for-asp-net-mvc-3/
1414

1515
RuleFor(x => x.CardholderName).NotEmpty().WithMessage(localizationService.GetResource("Payment.CardholderName.Required"));
16-
RuleFor(x => x.CardNumber).IsCreditCard().WithMessage(localizationService.GetResource("Payment.CardNumber.Wrong"));
17-
RuleFor(x => x.CardCode).Matches(@"^[0-9]{3,4}$").WithMessage(localizationService.GetResource("Payment.CardCode.Wrong"));
16+
RuleFor(x => x.CardNumber).CreditCard().WithMessage(localizationService.GetResource("Payment.CardNumber.Wrong"));
17+
RuleFor(x => x.CardCode).CreditCardCvvNumber();
1818
RuleFor(x => x.ExpireMonth).NotEmpty().WithMessage(localizationService.GetResource("Payment.ExpireMonth.Required"));
1919
RuleFor(x => x.ExpireYear).NotEmpty().WithMessage(localizationService.GetResource("Payment.ExpireYear.Required"));
2020
}

src/Plugins/SmartStore.PayPal/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<packages>
33
<package id="Autofac" version="4.5.0" targetFramework="net452" />
44
<package id="Autofac.Mvc5" version="4.0.2" targetFramework="net452" />
5-
<package id="FluentValidation" version="6.4.1" targetFramework="net452" />
5+
<package id="FluentValidation" version="7.4.0" targetFramework="net461" />
66
<package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net45" />
77
<package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net45" />
88
<package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net45" />

src/Presentation/SmartStore.Web.Framework/SmartStore.Web.Framework.csproj

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,8 @@
107107
<HintPath>..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath>
108108
<Private>True</Private>
109109
</Reference>
110-
<Reference Include="FluentValidation, Version=6.4.1.0, Culture=neutral, processorArchitecture=MSIL">
111-
<HintPath>..\..\packages\FluentValidation.6.4.1\lib\Net45\FluentValidation.dll</HintPath>
112-
<Private>True</Private>
110+
<Reference Include="FluentValidation, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7de548da2fbae0f0, processorArchitecture=MSIL">
111+
<HintPath>..\..\packages\FluentValidation.7.4.0\lib\net45\FluentValidation.dll</HintPath>
113112
</Reference>
114113
<Reference Include="JavaScriptEngineSwitcher.Core, Version=2.4.0.0, Culture=neutral, PublicKeyToken=c608b2a8cc9e4472, processorArchitecture=MSIL">
115114
<HintPath>..\..\packages\JavaScriptEngineSwitcher.Core.2.4.0\lib\net45\JavaScriptEngineSwitcher.Core.dll</HintPath>
@@ -392,6 +391,7 @@
392391
<Compile Include="UI\SiteMap\SiteMapBuiltEvent.cs" />
393392
<Compile Include="UI\SiteMap\SiteMapService.cs" />
394393
<Compile Include="UI\WidgetZoneModel.cs" />
394+
<Compile Include="Validators\FluentValidatorExtensions.cs" />
395395
<Compile Include="Validators\SmartBaseValidator.cs" />
396396
<Compile Include="Validators\SmartValidatorFactory.cs" />
397397
<Compile Include="Properties\AssemblyInfo.cs" />
@@ -443,8 +443,7 @@
443443
<Compile Include="UI\WidgetProvider.cs" />
444444
<Compile Include="UI\WidgetRouteInfo.cs" />
445445
<Compile Include="Extensions\UrlHelperExtensions.cs" />
446-
<Compile Include="Validators\ValidatorExtensions .cs" />
447-
<Compile Include="Validators\CreditCardPropertyValidator.cs" />
446+
<Compile Include="Validators\ValidatorLanguageManager.cs" />
448447
<Compile Include="WebApi\AutofacWebApiDependencyResolver.cs" />
449448
<Compile Include="WebApi\AutofacWebApiDependencyScope.cs" />
450449
<Compile Include="WebApi\Configuration\IWebApiConfigurationProvider.cs" />

0 commit comments

Comments
 (0)