Skip to content

Commit 2dfbbf9

Browse files
Getting rid of duplicate validator resource entries (part three)
1 parent 8b7a894 commit 2dfbbf9

21 files changed

+124
-217
lines changed

src/Plugins/SmartStore.GoogleMerchantCenter/Localization/resources.de-de.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,6 @@
177177
<LocaleResource Name="ExpirationDays.Hint">
178178
<Value>Anzahl der Tage, nach dem die Artikel verfallen bzw. nicht mehr angezeigt werden sollen. Der Wert 0 bewirkt, dass kein Verfallsdatum exportiert wird.</Value>
179179
</LocaleResource>
180-
<LocaleResource Name="ExpirationDays.Validate">
181-
<Value>Der Wert muss zwischen 0 und 29 Tagen liegen.</Value>
182-
</LocaleResource>
183180
<LocaleResource Name="ExportShipping">
184181
<Value>Versanddaten exportieren</Value>
185182
</LocaleResource>

src/Plugins/SmartStore.GoogleMerchantCenter/Localization/resources.en-us.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,6 @@
176176
<LocaleResource Name="ExpirationDays.Hint">
177177
<Value>Number of days after products should expire or no longer appear. A value of 0 causes that no expiry date will be exported.</Value>
178178
</LocaleResource>
179-
<LocaleResource Name="ExpirationDays.Validate">
180-
<Value>The value must be between 0 and 29 days.</Value>
181-
</LocaleResource>
182179
<LocaleResource Name="ExportShipping">
183180
<Value>Export shipping data</Value>
184181
</LocaleResource>

src/Plugins/SmartStore.GoogleMerchantCenter/Models/ProfileConfigurationModel.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
using System;
1+
using FluentValidation;
2+
using FluentValidation.Attributes;
3+
using SmartStore.Web.Framework;
4+
using System;
25
using System.Collections.Generic;
36
using System.Web.Mvc;
47
using System.Xml.Serialization;
5-
using FluentValidation.Attributes;
6-
using SmartStore.GoogleMerchantCenter.Validators;
7-
using SmartStore.Web.Framework;
88

99
namespace SmartStore.GoogleMerchantCenter.Models
1010
{
11-
[Serializable]
11+
[Serializable]
1212
[Validator(typeof(ProfileConfigurationValidator))]
1313
public class ProfileConfigurationModel
1414
{
@@ -67,4 +67,12 @@ public ProfileConfigurationModel()
6767
[SmartResourceDisplayName("Plugins.Feed.Froogle.ExportBasePrice")]
6868
public bool ExportBasePrice { get; set; }
6969
}
70+
71+
public class ProfileConfigurationValidator : AbstractValidator<ProfileConfigurationModel>
72+
{
73+
public ProfileConfigurationValidator()
74+
{
75+
RuleFor(x => x.ExpirationDays).InclusiveBetween(0, 29);
76+
}
77+
}
7078
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@
193193
<Compile Include="RouteProvider.cs" />
194194
<Compile Include="Services\IGoogleFeedService.cs" />
195195
<Compile Include="Services\GoogleFeedService.cs" />
196-
<Compile Include="Validators\ProfileConfigurationValidator.cs" />
197196
</ItemGroup>
198197
<ItemGroup>
199198
<ProjectReference Include="..\..\Libraries\SmartStore.Core\SmartStore.Core.csproj">

src/Plugins/SmartStore.GoogleMerchantCenter/Validators/ProfileConfigurationValidator.cs

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/Plugins/SmartStore.OfflinePayment/Controllers/OfflinePaymentController.cs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Web;
5-
using System.Web.Mvc;
6-
using Autofac;
1+
using Autofac;
72
using FluentValidation;
83
using FluentValidation.Results;
94
using SmartStore.OfflinePayment.Models;
105
using SmartStore.OfflinePayment.Settings;
11-
using SmartStore.OfflinePayment.Validators;
126
using SmartStore.Services;
7+
using SmartStore.Services.Media;
138
using SmartStore.Services.Payments;
149
using SmartStore.Web.Framework.Controllers;
1510
using SmartStore.Web.Framework.Security;
1611
using SmartStore.Web.Framework.Settings;
17-
using SmartStore.Services.Media;
1812
using SmartStore.Web.Framework.Theming;
13+
using System;
14+
using System.Collections.Generic;
15+
using System.Linq;
16+
using System.Web;
17+
using System.Web.Mvc;
1918

2019
namespace SmartStore.OfflinePayment.Controllers
2120
{
2221

23-
public class OfflinePaymentController : PaymentControllerBase
22+
public class OfflinePaymentController : PaymentControllerBase
2423
{
2524
private readonly IComponentContext _ctx;
2625
private readonly HttpContextBase _httpContext;
@@ -150,7 +149,7 @@ public override IList<string> ValidatePaymentForm(FormCollection form)
150149
{
151150
if (type == "Manual")
152151
{
153-
validator = new ManualPaymentInfoValidator(Services.Localization);
152+
validator = new ManualPaymentInfoValidator(T);
154153
var model = new ManualPaymentInfoModel
155154
{
156155
CardholderName = form["CardholderName"],
@@ -161,7 +160,7 @@ public override IList<string> ValidatePaymentForm(FormCollection form)
161160
}
162161
else if (type == "DirectDebit")
163162
{
164-
validator = new DirectDebitPaymentInfoValidator(Services.Localization);
163+
validator = new DirectDebitPaymentInfoValidator();
165164
var model = new DirectDebitPaymentInfoModel
166165
{
167166
EnterIBAN = form["EnterIBAN"],

src/Plugins/SmartStore.OfflinePayment/Localization/resources.de-de.xml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -200,21 +200,6 @@
200200
<LocaleResource Name="YesEnterIBAN">
201201
<Value>Ja</Value>
202202
</LocaleResource>
203-
<LocaleResource Name="DirectDebitAccountHolderRequired">
204-
<Value>Geben Sie bitte den Namen des Kontoinhabers ein.</Value>
205-
</LocaleResource>
206-
<LocaleResource Name="DirectDebitAccountNumberRequired">
207-
<Value>Geben Sie bitte Ihre Kontonummer ein.</Value>
208-
</LocaleResource>
209-
<LocaleResource Name="DirectDebitBankCodeRequired">
210-
<Value>Geben Sie bitte die Bankleitzahl (BLZ) ein.</Value>
211-
</LocaleResource>
212-
<LocaleResource Name="DirectDebitIbanRequired">
213-
<Value>Geben Sie bitte die IBAN (International Bank Account Number) ein.</Value>
214-
</LocaleResource>
215-
<LocaleResource Name="DirectDebitBicRequired">
216-
<Value>Geben Sie bitte die BIC (Bank Interchange Code) ein.</Value>
217-
</LocaleResource>
218203
</Children>
219204
</LocaleResource>
220205

src/Plugins/SmartStore.OfflinePayment/Localization/resources.en-us.xml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -203,21 +203,6 @@
203203
<LocaleResource Name="YesEnterIban">
204204
<Value>Yes</Value>
205205
</LocaleResource>
206-
<LocaleResource Name="DirectDebitAccountHolderRequired">
207-
<Value>Please enter the name of the account holder.</Value>
208-
</LocaleResource>
209-
<LocaleResource Name="DirectDebitAccountNumberRequired">
210-
<Value>Please enter your account number.</Value>
211-
</LocaleResource>
212-
<LocaleResource Name="DirectDebitBankCodeRequired">
213-
<Value>Please enter the bank code.</Value>
214-
</LocaleResource>
215-
<LocaleResource Name="DirectDebitIBANRequired">
216-
<Value>Please enter the IBAN (International Bank Account Number).</Value>
217-
</LocaleResource>
218-
<LocaleResource Name="DirectDebitBICRequired">
219-
<Value>Please enter the BIC (Bank Interchange Code).</Value>
220-
</LocaleResource>
221206
</Children>
222207
</LocaleResource>
223208

src/Plugins/SmartStore.OfflinePayment/Models/PaymentInfoModel.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
using System.Web.Mvc;
33
using SmartStore.Web.Framework;
44
using SmartStore.Web.Framework.Modelling;
5+
using FluentValidation;
6+
using SmartStore.Core.Localization;
7+
using SmartStore.Web.Framework.Validators;
58

69
namespace SmartStore.OfflinePayment.Models
710
{
@@ -104,4 +107,30 @@ public class PurchaseOrderNumberPaymentInfoModel : PaymentInfoModelBase
104107
[AllowHtml]
105108
public string PurchaseOrderNumber { get; set; }
106109
}
110+
111+
#region validators
112+
113+
public class DirectDebitPaymentInfoValidator : AbstractValidator<DirectDebitPaymentInfoModel>
114+
{
115+
public DirectDebitPaymentInfoValidator()
116+
{
117+
RuleFor(x => x.DirectDebitAccountHolder).NotEmpty();
118+
RuleFor(x => x.DirectDebitAccountNumber).NotEmpty().When(x => x.EnterIBAN == "no-iban");
119+
RuleFor(x => x.DirectDebitBankCode).NotEmpty().When(x => x.EnterIBAN == "no-iban");
120+
RuleFor(x => x.DirectDebitIban).Matches(RegularExpressions.IsIban).When(x => x.EnterIBAN == "iban");
121+
RuleFor(x => x.DirectDebitBic).Matches(RegularExpressions.IsBic).When(x => x.EnterIBAN == "iban");
122+
}
123+
}
124+
125+
public class ManualPaymentInfoValidator : AbstractValidator<ManualPaymentInfoModel>
126+
{
127+
public ManualPaymentInfoValidator(Localizer T)
128+
{
129+
RuleFor(x => x.CardholderName).NotEmpty();
130+
RuleFor(x => x.CardNumber).CreditCard().WithMessage(T("Payment.CardNumber.Wrong"));
131+
RuleFor(x => x.CardCode).CreditCardCvvNumber();
132+
}
133+
}
134+
135+
#endregion
107136
}

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,6 @@
154154
<Compile Include="Providers\CashOnDeliveryProvider.cs" />
155155
<Compile Include="RouteProvider.cs" />
156156
<Compile Include="Settings\OfflinePaymentSettings.cs" />
157-
<Compile Include="Validators\DirectDebitPaymentInfoValidator.cs" />
158-
<Compile Include="Validators\ManualPaymentInfoValidator.cs" />
159157
</ItemGroup>
160158
<ItemGroup>
161159
<ProjectReference Include="..\..\Libraries\SmartStore.Core\SmartStore.Core.csproj">

0 commit comments

Comments
 (0)