diff --git a/src/NzbDrone.Api/Config/IndexerConfigModule.cs b/src/NzbDrone.Api/Config/IndexerConfigModule.cs
index 1f7ff674c..02f03f958 100644
--- a/src/NzbDrone.Api/Config/IndexerConfigModule.cs
+++ b/src/NzbDrone.Api/Config/IndexerConfigModule.cs
@@ -1,4 +1,5 @@
using FluentValidation;
+using NzbDrone.Api.Validation;
using NzbDrone.Core.Configuration;
namespace NzbDrone.Api.Config
@@ -16,8 +17,7 @@ public IndexerConfigModule(IConfigService configService)
.GreaterThanOrEqualTo(0);
SharedValidator.RuleFor(c => c.RssSyncInterval)
- .InclusiveBetween(10, 120)
- .When(c => c.RssSyncInterval > 0);
+ .IsValidRssSyncInterval();
}
}
}
\ No newline at end of file
diff --git a/src/NzbDrone.Api/NzbDrone.Api.csproj b/src/NzbDrone.Api/NzbDrone.Api.csproj
index 1b1c0b95e..9689ddf41 100644
--- a/src/NzbDrone.Api/NzbDrone.Api.csproj
+++ b/src/NzbDrone.Api/NzbDrone.Api.csproj
@@ -238,6 +238,7 @@
+
diff --git a/src/NzbDrone.Api/Validation/RssSyncIntervalValidator.cs b/src/NzbDrone.Api/Validation/RssSyncIntervalValidator.cs
new file mode 100644
index 000000000..8a3f2d54c
--- /dev/null
+++ b/src/NzbDrone.Api/Validation/RssSyncIntervalValidator.cs
@@ -0,0 +1,34 @@
+using FluentValidation.Validators;
+
+namespace NzbDrone.Api.Validation
+{
+ public class RssSyncIntervalValidator : PropertyValidator
+ {
+ public RssSyncIntervalValidator()
+ : base("Must be between 10 and 120 or 0 to disable")
+ {
+ }
+
+ protected override bool IsValid(PropertyValidatorContext context)
+ {
+ if (context.PropertyValue == null)
+ {
+ return true;
+ }
+
+ var value = (int)context.PropertyValue;
+
+ if (value == 0)
+ {
+ return true;
+ }
+
+ if (value >= 10 && value <= 120)
+ {
+ return true;
+ }
+
+ return false;
+ }
+ }
+}
diff --git a/src/NzbDrone.Api/Validation/RuleBuilderExtensions.cs b/src/NzbDrone.Api/Validation/RuleBuilderExtensions.cs
index 45cd0e1c6..01a3a4f75 100644
--- a/src/NzbDrone.Api/Validation/RuleBuilderExtensions.cs
+++ b/src/NzbDrone.Api/Validation/RuleBuilderExtensions.cs
@@ -31,5 +31,10 @@ public static IRuleBuilderOptions> EmptyCollection());
}
+
+ public static IRuleBuilderOptions IsValidRssSyncInterval(this IRuleBuilder ruleBuilder)
+ {
+ return ruleBuilder.SetValidator(new RssSyncIntervalValidator());
+ }
}
}
diff --git a/src/NzbDrone.Core/Jobs/TaskManager.cs b/src/NzbDrone.Core/Jobs/TaskManager.cs
index 0a7d71870..3ad7b909a 100644
--- a/src/NzbDrone.Core/Jobs/TaskManager.cs
+++ b/src/NzbDrone.Core/Jobs/TaskManager.cs
@@ -120,6 +120,11 @@ private int GetRssSyncInterval()
return 10;
}
+ if (interval < 0)
+ {
+ return 0;
+ }
+
return interval;
}
diff --git a/src/UI/Settings/Indexers/Options/IndexerOptionsViewTemplate.hbs b/src/UI/Settings/Indexers/Options/IndexerOptionsViewTemplate.hbs
index c1321d574..056d12648 100644
--- a/src/UI/Settings/Indexers/Options/IndexerOptionsViewTemplate.hbs
+++ b/src/UI/Settings/Indexers/Options/IndexerOptionsViewTemplate.hbs
@@ -34,7 +34,7 @@
-
+