Skip to content

Commit b4cf29d

Browse files
committed
Null check on FallbackValidator
1 parent 4894685 commit b4cf29d

File tree

1 file changed

+38
-38
lines changed

1 file changed

+38
-38
lines changed
Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
1-
using FieldFallback.Data;
2-
using Sitecore.Data.Fields;
3-
using Sitecore.Data.Validators;
4-
5-
namespace FieldFallback.Validators
6-
{
7-
public class FallbackValidator : StandardValidator
8-
{
9-
protected override ValidatorResult Evaluate()
10-
{
11-
Field field = GetField();
12-
13-
if(field != null)
14-
{
15-
if (FallbackValuesManager.Provider.FieldContainsFallbackValue(field, ItemUri.Language))
16-
{
17-
Text = GetText("Field \"{0}\" contains a fallback value", new[] { GetFieldDisplayName() });
18-
return GetFailedResult(ValidatorResult.Warning);
19-
}
20-
}
21-
22-
return ValidatorResult.Valid;
23-
}
24-
25-
protected override ValidatorResult GetMaxValidatorResult()
26-
{
27-
return GetFailedResult(ValidatorResult.Warning);
28-
}
29-
30-
public override string Name
31-
{
32-
get
33-
{
34-
return "Fallback";
35-
}
36-
}
37-
}
38-
}
1+
using FieldFallback.Data;
2+
using Sitecore.Data.Fields;
3+
using Sitecore.Data.Validators;
4+
5+
namespace FieldFallback.Validators
6+
{
7+
public class FallbackValidator : StandardValidator
8+
{
9+
protected override ValidatorResult Evaluate()
10+
{
11+
Field field = GetField();
12+
13+
if (field != null && FallbackValuesManager.Provider != null)
14+
{
15+
if (FallbackValuesManager.Provider.FieldContainsFallbackValue(field, ItemUri.Language))
16+
{
17+
Text = GetText("Field \"{0}\" contains a fallback value", new[] { GetFieldDisplayName() });
18+
return GetFailedResult(ValidatorResult.Warning);
19+
}
20+
}
21+
22+
return ValidatorResult.Valid;
23+
}
24+
25+
protected override ValidatorResult GetMaxValidatorResult()
26+
{
27+
return GetFailedResult(ValidatorResult.Warning);
28+
}
29+
30+
public override string Name
31+
{
32+
get
33+
{
34+
return "Fallback";
35+
}
36+
}
37+
}
38+
}

0 commit comments

Comments
 (0)