Skip to content

Commit 66b9ca7

Browse files
validate settings if no prebound settings
1 parent ac8f8f4 commit 66b9ca7

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/Microsoft.FeatureManagement/FeatureFilters/TimeWindowFilter.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ public Task<bool> EvaluateAsync(FeatureFilterEvaluationContext context)
6969
// Check if prebound settings available, otherwise bind from parameters.
7070
TimeWindowFilterSettings settings = (TimeWindowFilterSettings)context.Settings ?? (TimeWindowFilterSettings)BindParameters(context.Parameters);
7171

72+
//
73+
// If prebound settings is not available, which means BindParameters method is not called, we need to validate the feature filter settings.
74+
if (context.Settings == null && !RecurrenceValidator.TryValidateSettings(settings, out string paramName, out string reason))
75+
{
76+
throw new ArgumentException(reason, paramName);
77+
}
78+
7279
DateTimeOffset now = SystemClock?.UtcNow ?? DateTimeOffset.UtcNow;
7380

7481
if (!settings.Start.HasValue && !settings.End.HasValue)

0 commit comments

Comments
 (0)