@ -1,4 +1,5 @@
using FluentValidation;
using NzbDrone.Api.Validation;
using NzbDrone.Core.Configuration;
namespace NzbDrone.Api.Config
@ -16,8 +17,7 @@ namespace NzbDrone.Api.Config
.GreaterThanOrEqualTo(0);
SharedValidator.RuleFor(c => c.RssSyncInterval)
.InclusiveBetween(10, 120)
.When(c => c.RssSyncInterval > 0);
.IsValidRssSyncInterval();
}
@ -238,6 +238,7 @@
<Compile Include="TinyIoCNancyBootstrapper.cs" />
<Compile Include="Update\UpdateModule.cs" />
<Compile Include="Update\UpdateResource.cs" />
<Compile Include="Validation\RssSyncIntervalValidator.cs" />
<Compile Include="Validation\EmptyCollectionValidator.cs" />
<Compile Include="Validation\RuleBuilderExtensions.cs" />
<Compile Include="Wanted\CutoffModule.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)
if (value >= 10 && value <= 120)
return false;
@ -31,5 +31,10 @@ namespace NzbDrone.Api.Validation
return ruleBuilder.SetValidator(new EmptyCollectionValidator<TProp>());
public static IRuleBuilderOptions<T, int> IsValidRssSyncInterval<T>(this IRuleBuilder<T, int> ruleBuilder)
return ruleBuilder.SetValidator(new RssSyncIntervalValidator());
@ -120,6 +120,11 @@ namespace NzbDrone.Core.Jobs
return 10;
if (interval < 0)
return 0;
return interval;
@ -34,7 +34,7 @@
</div>
<div class="col-sm-2 col-sm-pull-1">
<input type="number" name="rssSyncInterval" class="form-control"/>
<input type="number" name="rssSyncInterval" class="form-control" min="0" max="120"/>
</fieldset>