Radarr/src/Radarr.Http/Validation/RssSyncIntervalValidator.cs

27 lines
646 B
C#
Raw Permalink Normal View History

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
{
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;
}
return value is >= 10 and <= 120;
2015-12-20 02:02:38 +00:00
}
}
}