You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Lidarr/src/NzbDrone.Core/Notifications/Prowl/ProwlSettings.cs

34 lines
1.1 KiB

using FluentValidation;
using NzbDrone.Core.Annotations;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation;
namespace NzbDrone.Core.Notifications.Prowl
{
public class ProwlSettingsValidator : AbstractValidator<ProwlSettings>
{
public ProwlSettingsValidator()
{
RuleFor(c => c.ApiKey).NotEmpty();
}
}
public class ProwlSettings : IProviderConfig
{
private static readonly ProwlSettingsValidator Validator = new ProwlSettingsValidator();
[FieldDefinition(0, Label = "API Key", Privacy = PrivacyLevel.ApiKey, HelpLink = "https://www.prowlapp.com/api_settings.php")]
public string ApiKey { get; set; }
[FieldDefinition(1, Label = "Priority", Type = FieldType.Select, SelectOptions = typeof(ProwlPriority))]
public int Priority { get; set; }
public bool IsValid => !string.IsNullOrWhiteSpace(ApiKey) && Priority >= -2 && Priority <= 2;
public NzbDroneValidationResult Validate()
{
return new NzbDroneValidationResult(Validator.Validate(this));
}
}
}