2015-12-20 02:02:38 +00:00
|
|
|
|
using FluentValidation.Validators;
|
|
|
|
|
|
2018-11-23 07:03:32 +00:00
|
|
|
|
namespace Radarr.Http.Validation
|
2015-12-20 02:02:38 +00:00
|
|
|
|
{
|
|
|
|
|
public class RssSyncIntervalValidator : PropertyValidator
|
|
|
|
|
{
|
2023-04-01 13:03:53 +00:00
|
|
|
|
protected override string GetDefaultMessageTemplate() => "Must be between 10 and 120 or 0 to disable";
|
2015-12-20 02:02:38 +00:00
|
|
|
|
|
|
|
|
|
protected override bool IsValid(PropertyValidatorContext context)
|
|
|
|
|
{
|
|
|
|
|
if (context.PropertyValue == null)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var value = (int)context.PropertyValue;
|
|
|
|
|
|
|
|
|
|
if (value == 0)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-01 13:03:53 +00:00
|
|
|
|
return value is >= 10 and <= 120;
|
2015-12-20 02:02:38 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|