Skip to content

Commit 838a680

Browse files
Refactor CultureInfo validation logic in validators
1 parent e76e632 commit 838a680

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/Web/Grand.Web.Admin/Validators/Directory/CurrencyValidator.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,9 @@ public CurrencyValidator(
3737
{
3838
if (string.IsNullOrEmpty(x))
3939
return true;
40-
//create a CultureInfo object
41-
//if "DisplayLocale" is wrong, then exception will be thrown
42-
new CultureInfo(x);
43-
return true;
40+
41+
var culture = new CultureInfo(x);
42+
return culture != null;
4443
}
4544
catch
4645
{

src/Web/Grand.Web.Admin/Validators/Localization/LanguageValidator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ public LanguageValidator(
2121
try
2222
{
2323
//create a CultureInfo object
24-
new CultureInfo(x);
25-
return true;
24+
var culture = new CultureInfo(x);
25+
return culture != null;
2626
}
2727
catch
2828
{

0 commit comments

Comments
 (0)