mirror of
https://github.com/Prowlarr/Prowlarr
synced 2026-01-16 20:51:58 +01:00
Fixed: Validation inheritance
This commit is contained in:
parent
27094ccf62
commit
d6b379df64
31 changed files with 120 additions and 111 deletions
|
|
@ -521,7 +521,7 @@ public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
|
|||
public Action<IDictionary<string, string>, DateTime?> CookiesUpdater { get; set; }
|
||||
}
|
||||
|
||||
public class AnimeBytesSettingsValidator : AbstractValidator<AnimeBytesSettings>
|
||||
public class AnimeBytesSettingsValidator : NoAuthSettingsValidator<AnimeBytesSettings>
|
||||
{
|
||||
public AnimeBytesSettingsValidator()
|
||||
{
|
||||
|
|
@ -535,7 +535,7 @@ public AnimeBytesSettingsValidator()
|
|||
|
||||
public class AnimeBytesSettings : NoAuthTorrentBaseSettings
|
||||
{
|
||||
private static readonly AnimeBytesSettingsValidator Validator = new AnimeBytesSettingsValidator();
|
||||
private static readonly AnimeBytesSettingsValidator Validator = new ();
|
||||
|
||||
public AnimeBytesSettings()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
namespace NzbDrone.Core.Indexers.Definitions.Avistaz
|
||||
{
|
||||
public class AvistazSettingsValidator : AbstractValidator<AvistazSettings>
|
||||
public class AvistazSettingsValidator : NoAuthSettingsValidator<AvistazSettings>
|
||||
{
|
||||
public AvistazSettingsValidator()
|
||||
{
|
||||
|
|
@ -17,7 +17,7 @@ public AvistazSettingsValidator()
|
|||
|
||||
public class AvistazSettings : NoAuthTorrentBaseSettings
|
||||
{
|
||||
private static readonly AvistazSettingsValidator Validator = new AvistazSettingsValidator();
|
||||
private static readonly AvistazSettingsValidator Validator = new ();
|
||||
|
||||
public AvistazSettings()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -246,7 +246,7 @@ public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
|
|||
public Action<IDictionary<string, string>, DateTime?> CookiesUpdater { get; set; }
|
||||
}
|
||||
|
||||
public class BeyondHDSettingsValidator : AbstractValidator<BeyondHDSettings>
|
||||
public class BeyondHDSettingsValidator : NoAuthSettingsValidator<BeyondHDSettings>
|
||||
{
|
||||
public BeyondHDSettingsValidator()
|
||||
{
|
||||
|
|
@ -257,7 +257,7 @@ public BeyondHDSettingsValidator()
|
|||
|
||||
public class BeyondHDSettings : NoAuthTorrentBaseSettings
|
||||
{
|
||||
private static readonly BeyondHDSettingsValidator Validator = new BeyondHDSettingsValidator();
|
||||
private static readonly BeyondHDSettingsValidator Validator = new ();
|
||||
|
||||
public BeyondHDSettings()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -219,7 +219,7 @@ public class BinSearchSettings : IIndexerSettings
|
|||
public string BaseUrl { get; set; }
|
||||
|
||||
[FieldDefinition(2)]
|
||||
public IndexerBaseSettings BaseSettings { get; set; } = new IndexerBaseSettings();
|
||||
public IndexerBaseSettings BaseSettings { get; set; } = new ();
|
||||
|
||||
public NzbDroneValidationResult Validate()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
namespace NzbDrone.Core.Indexers.BroadcastheNet
|
||||
{
|
||||
public class BroadcastheNetSettingsValidator : AbstractValidator<BroadcastheNetSettings>
|
||||
public class BroadcastheNetSettingsValidator : NoAuthSettingsValidator<BroadcastheNetSettings>
|
||||
{
|
||||
public BroadcastheNetSettingsValidator()
|
||||
{
|
||||
|
|
@ -15,11 +15,7 @@ public BroadcastheNetSettingsValidator()
|
|||
|
||||
public class BroadcastheNetSettings : NoAuthTorrentBaseSettings
|
||||
{
|
||||
private static readonly BroadcastheNetSettingsValidator Validator = new BroadcastheNetSettingsValidator();
|
||||
|
||||
public BroadcastheNetSettings()
|
||||
{
|
||||
}
|
||||
private static readonly BroadcastheNetSettingsValidator Validator = new ();
|
||||
|
||||
[FieldDefinition(2, Label = "API Key", Privacy = PrivacyLevel.ApiKey)]
|
||||
public string ApiKey { get; set; }
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
namespace NzbDrone.Core.Indexers.FileList
|
||||
{
|
||||
public class FileListSettingsValidator : AbstractValidator<FileListSettings>
|
||||
public class FileListSettingsValidator : NoAuthSettingsValidator<FileListSettings>
|
||||
{
|
||||
public FileListSettingsValidator()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,20 +1,26 @@
|
|||
using FluentValidation;
|
||||
using NzbDrone.Core.Annotations;
|
||||
using NzbDrone.Core.Indexers.Settings;
|
||||
using NzbDrone.Core.Validation;
|
||||
|
||||
namespace NzbDrone.Core.Indexers.Gazelle
|
||||
{
|
||||
public class GazelleSettingsValidator : UserPassBaseSettingsValidator<GazelleSettings>
|
||||
{
|
||||
}
|
||||
|
||||
public class GazelleSettings : UserPassTorrentBaseSettings
|
||||
{
|
||||
public GazelleSettings()
|
||||
{
|
||||
}
|
||||
private static readonly GazelleSettingsValidator Validator = new ();
|
||||
|
||||
public string AuthKey;
|
||||
public string PassKey;
|
||||
|
||||
[FieldDefinition(4, Type = FieldType.Checkbox, Label = "Use Freeleech Token", HelpText = "Use freeleech tokens when available")]
|
||||
public bool UseFreeleechToken { get; set; }
|
||||
|
||||
public override NzbDroneValidationResult Validate()
|
||||
{
|
||||
return new NzbDroneValidationResult(Validator.Validate(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -431,7 +431,7 @@ private string GetInfoUrl(string groupId, int torrentId)
|
|||
public Action<IDictionary<string, string>, DateTime?> CookiesUpdater { get; set; }
|
||||
}
|
||||
|
||||
public class GazelleGamesSettingsValidator : AbstractValidator<GazelleGamesSettings>
|
||||
public class GazelleGamesSettingsValidator : NoAuthSettingsValidator<GazelleGamesSettings>
|
||||
{
|
||||
public GazelleGamesSettingsValidator()
|
||||
{
|
||||
|
|
@ -441,7 +441,7 @@ public GazelleGamesSettingsValidator()
|
|||
|
||||
public class GazelleGamesSettings : NoAuthTorrentBaseSettings
|
||||
{
|
||||
private static readonly GazelleGamesSettingsValidator Validator = new GazelleGamesSettingsValidator();
|
||||
private static readonly GazelleGamesSettingsValidator Validator = new ();
|
||||
|
||||
public GazelleGamesSettings()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
namespace NzbDrone.Core.Indexers.HDBits
|
||||
{
|
||||
public class HDBitsSettingsValidator : AbstractValidator<HDBitsSettings>
|
||||
public class HDBitsSettingsValidator : NoAuthSettingsValidator<HDBitsSettings>
|
||||
{
|
||||
public HDBitsSettingsValidator()
|
||||
{
|
||||
|
|
@ -16,7 +16,7 @@ public HDBitsSettingsValidator()
|
|||
|
||||
public class HDBitsSettings : NoAuthTorrentBaseSettings
|
||||
{
|
||||
private static readonly HDBitsSettingsValidator Validator = new HDBitsSettingsValidator();
|
||||
private static readonly HDBitsSettingsValidator Validator = new ();
|
||||
|
||||
public HDBitsSettings()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ public HeadphonesSettingsValidator()
|
|||
|
||||
public class HeadphonesSettings : IIndexerSettings
|
||||
{
|
||||
private static readonly HeadphonesSettingsValidator Validator = new HeadphonesSettingsValidator();
|
||||
private static readonly HeadphonesSettingsValidator Validator = new ();
|
||||
|
||||
public HeadphonesSettings()
|
||||
{
|
||||
|
|
@ -38,7 +38,7 @@ public HeadphonesSettings()
|
|||
public string Password { get; set; }
|
||||
|
||||
[FieldDefinition(4)]
|
||||
public IndexerBaseSettings BaseSettings { get; set; } = new IndexerBaseSettings();
|
||||
public IndexerBaseSettings BaseSettings { get; set; } = new ();
|
||||
|
||||
public virtual NzbDroneValidationResult Validate()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -480,7 +480,7 @@ private bool HasUserVip()
|
|||
public Action<IDictionary<string, string>, DateTime?> CookiesUpdater { get; set; }
|
||||
}
|
||||
|
||||
public class MyAnonamouseSettingsValidator : AbstractValidator<MyAnonamouseSettings>
|
||||
public class MyAnonamouseSettingsValidator : NoAuthSettingsValidator<MyAnonamouseSettings>
|
||||
{
|
||||
public MyAnonamouseSettingsValidator()
|
||||
{
|
||||
|
|
@ -490,7 +490,7 @@ public MyAnonamouseSettingsValidator()
|
|||
|
||||
public class MyAnonamouseSettings : NoAuthTorrentBaseSettings
|
||||
{
|
||||
private static readonly MyAnonamouseSettingsValidator Validator = new MyAnonamouseSettingsValidator();
|
||||
private static readonly MyAnonamouseSettingsValidator Validator = new ();
|
||||
|
||||
public MyAnonamouseSettings()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ public NewznabSettingsValidator()
|
|||
|
||||
public class NewznabSettings : IIndexerSettings
|
||||
{
|
||||
private static readonly NewznabSettingsValidator Validator = new NewznabSettingsValidator();
|
||||
private static readonly NewznabSettingsValidator Validator = new ();
|
||||
|
||||
public NewznabSettings()
|
||||
{
|
||||
|
|
@ -78,7 +78,7 @@ public NewznabSettings()
|
|||
public string VipExpiration { get; set; }
|
||||
|
||||
[FieldDefinition(7)]
|
||||
public IndexerBaseSettings BaseSettings { get; set; } = new IndexerBaseSettings();
|
||||
public IndexerBaseSettings BaseSettings { get; set; } = new ();
|
||||
|
||||
public List<IndexerCategory> Categories { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -1168,7 +1168,7 @@ public NzbIndexSettingsValidator()
|
|||
|
||||
public class NzbIndexSettings : IIndexerSettings
|
||||
{
|
||||
private static readonly NzbIndexSettingsValidator Validator = new NzbIndexSettingsValidator();
|
||||
private static readonly NzbIndexSettingsValidator Validator = new ();
|
||||
|
||||
public NzbIndexSettings()
|
||||
{
|
||||
|
|
@ -1182,7 +1182,9 @@ public NzbIndexSettings()
|
|||
public string ApiKey { get; set; }
|
||||
|
||||
[FieldDefinition(3)]
|
||||
public IndexerBaseSettings BaseSettings { get; set; } = new IndexerBaseSettings(); public NzbDroneValidationResult Validate()
|
||||
public IndexerBaseSettings BaseSettings { get; set; } = new ();
|
||||
|
||||
public NzbDroneValidationResult Validate()
|
||||
{
|
||||
return new NzbDroneValidationResult(Validator.Validate(this));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -385,7 +385,7 @@ private string GetInfoUrl(string groupId, int torrentId)
|
|||
}
|
||||
}
|
||||
|
||||
public class OrpheusSettingsValidator : AbstractValidator<OrpheusSettings>
|
||||
public class OrpheusSettingsValidator : NoAuthSettingsValidator<OrpheusSettings>
|
||||
{
|
||||
public OrpheusSettingsValidator()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
namespace NzbDrone.Core.Indexers.PassThePopcorn
|
||||
{
|
||||
public class PassThePopcornSettingsValidator : AbstractValidator<PassThePopcornSettings>
|
||||
public class PassThePopcornSettingsValidator : NoAuthSettingsValidator<PassThePopcornSettings>
|
||||
{
|
||||
public PassThePopcornSettingsValidator()
|
||||
{
|
||||
|
|
@ -16,11 +16,7 @@ public PassThePopcornSettingsValidator()
|
|||
|
||||
public class PassThePopcornSettings : NoAuthTorrentBaseSettings
|
||||
{
|
||||
private static readonly PassThePopcornSettingsValidator Validator = new PassThePopcornSettingsValidator();
|
||||
|
||||
public PassThePopcornSettings()
|
||||
{
|
||||
}
|
||||
private static readonly PassThePopcornSettingsValidator Validator = new ();
|
||||
|
||||
[FieldDefinition(2, Label = "API User", HelpText = "These settings are found in your PassThePopcorn security settings (Edit Profile > Security).", Privacy = PrivacyLevel.UserName)]
|
||||
public string APIUser { get; set; }
|
||||
|
|
|
|||
|
|
@ -380,7 +380,7 @@ public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
|
|||
public Action<IDictionary<string, string>, DateTime?> CookiesUpdater { get; set; }
|
||||
}
|
||||
|
||||
public class PreToMeSettingsValidator : AbstractValidator<PreToMeSettings>
|
||||
public class PreToMeSettingsValidator : NoAuthSettingsValidator<PreToMeSettings>
|
||||
{
|
||||
public PreToMeSettingsValidator()
|
||||
{
|
||||
|
|
@ -392,7 +392,7 @@ public PreToMeSettingsValidator()
|
|||
|
||||
public class PreToMeSettings : NoAuthTorrentBaseSettings
|
||||
{
|
||||
private static readonly PreToMeSettingsValidator Validator = new PreToMeSettingsValidator();
|
||||
private static readonly PreToMeSettingsValidator Validator = new ();
|
||||
|
||||
public PreToMeSettings()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
using FluentValidation;
|
||||
using NzbDrone.Core.Annotations;
|
||||
using NzbDrone.Core.Indexers.Settings;
|
||||
using NzbDrone.Core.Validation;
|
||||
|
||||
namespace NzbDrone.Core.Indexers.Rarbg
|
||||
{
|
||||
|
|
|
|||
|
|
@ -326,7 +326,7 @@ private string GetInfoUrl(string groupId, int torrentId)
|
|||
}
|
||||
}
|
||||
|
||||
public class RedactedSettingsValidator : AbstractValidator<RedactedSettings>
|
||||
public class RedactedSettingsValidator : NoAuthSettingsValidator<RedactedSettings>
|
||||
{
|
||||
public RedactedSettingsValidator()
|
||||
{
|
||||
|
|
@ -336,7 +336,7 @@ public RedactedSettingsValidator()
|
|||
|
||||
public class RedactedSettings : NoAuthTorrentBaseSettings
|
||||
{
|
||||
private static readonly RedactedSettingsValidator Validator = new RedactedSettingsValidator();
|
||||
private static readonly RedactedSettingsValidator Validator = new ();
|
||||
|
||||
public RedactedSettings()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -233,7 +233,7 @@ public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
|
|||
public Action<IDictionary<string, string>, DateTime?> CookiesUpdater { get; set; }
|
||||
}
|
||||
|
||||
public class SceneHDSettingsValidator : AbstractValidator<SceneHDSettings>
|
||||
public class SceneHDSettingsValidator : NoAuthSettingsValidator<SceneHDSettings>
|
||||
{
|
||||
public SceneHDSettingsValidator()
|
||||
{
|
||||
|
|
@ -243,7 +243,7 @@ public SceneHDSettingsValidator()
|
|||
|
||||
public class SceneHDSettings : NoAuthTorrentBaseSettings
|
||||
{
|
||||
private static readonly SceneHDSettingsValidator Validator = new SceneHDSettingsValidator();
|
||||
private static readonly SceneHDSettingsValidator Validator = new ();
|
||||
|
||||
public SceneHDSettings()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -332,7 +332,7 @@ private static string CleanTitle(string title)
|
|||
}
|
||||
}
|
||||
|
||||
public class SpeedAppSettingsValidator : AbstractValidator<SpeedAppSettings>
|
||||
public class SpeedAppSettingsValidator : NoAuthSettingsValidator<SpeedAppSettings>
|
||||
{
|
||||
public SpeedAppSettingsValidator()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,16 +5,28 @@
|
|||
|
||||
namespace NzbDrone.Core.Indexers.TorrentPotato
|
||||
{
|
||||
public class TorrentPotatoSettingsValidator : NoAuthSettingsValidator<TorrentPotatoSettings>
|
||||
{
|
||||
public TorrentPotatoSettingsValidator()
|
||||
{
|
||||
RuleFor(c => c.User).NotEmpty();
|
||||
RuleFor(c => c.Passkey).NotEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
public class TorrentPotatoSettings : NoAuthTorrentBaseSettings
|
||||
{
|
||||
public TorrentPotatoSettings()
|
||||
{
|
||||
}
|
||||
private static readonly TorrentPotatoSettingsValidator Validator = new ();
|
||||
|
||||
[FieldDefinition(2, Label = "Username", HelpText = "Indexer Username", Privacy = PrivacyLevel.UserName)]
|
||||
public string User { get; set; }
|
||||
|
||||
[FieldDefinition(3, Label = "Passkey", HelpText = "Indexer Password", Privacy = PrivacyLevel.Password, Type = FieldType.Password)]
|
||||
public string Passkey { get; set; }
|
||||
|
||||
public override NzbDroneValidationResult Validate()
|
||||
{
|
||||
return new NzbDroneValidationResult(Validator.Validate(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -323,7 +323,7 @@ public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
|
|||
public Action<IDictionary<string, string>, DateTime?> CookiesUpdater { get; set; }
|
||||
}
|
||||
|
||||
public class TorrentSyndikatSettingsValidator : AbstractValidator<TorrentSyndikatSettings>
|
||||
public class TorrentSyndikatSettingsValidator : NoAuthSettingsValidator<TorrentSyndikatSettings>
|
||||
{
|
||||
public TorrentSyndikatSettingsValidator()
|
||||
{
|
||||
|
|
@ -333,7 +333,7 @@ public TorrentSyndikatSettingsValidator()
|
|||
|
||||
public class TorrentSyndikatSettings : NoAuthTorrentBaseSettings
|
||||
{
|
||||
private static readonly TorrentSyndikatSettingsValidator Validator = new TorrentSyndikatSettingsValidator();
|
||||
private static readonly TorrentSyndikatSettingsValidator Validator = new ();
|
||||
|
||||
public TorrentSyndikatSettings()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -41,14 +41,10 @@ public TorznabSettingsValidator()
|
|||
|
||||
public class TorznabSettings : NewznabSettings, ITorrentIndexerSettings
|
||||
{
|
||||
private static readonly TorznabSettingsValidator Validator = new TorznabSettingsValidator();
|
||||
|
||||
public TorznabSettings()
|
||||
{
|
||||
}
|
||||
private static readonly TorznabSettingsValidator Validator = new ();
|
||||
|
||||
[FieldDefinition(3)]
|
||||
public IndexerTorrentBaseSettings TorrentBaseSettings { get; set; } = new IndexerTorrentBaseSettings();
|
||||
public IndexerTorrentBaseSettings TorrentBaseSettings { get; set; } = new ();
|
||||
|
||||
public override NzbDroneValidationResult Validate()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
namespace NzbDrone.Core.Indexers.Definitions.UNIT3D
|
||||
{
|
||||
public class Unit3dSettingsValidator : AbstractValidator<Unit3dSettings>
|
||||
public class Unit3dSettingsValidator : NoAuthSettingsValidator<Unit3dSettings>
|
||||
{
|
||||
public Unit3dSettingsValidator()
|
||||
{
|
||||
|
|
@ -15,11 +15,7 @@ public Unit3dSettingsValidator()
|
|||
|
||||
public class Unit3dSettings : NoAuthTorrentBaseSettings
|
||||
{
|
||||
private static readonly Unit3dSettingsValidator Validator = new Unit3dSettingsValidator();
|
||||
|
||||
public Unit3dSettings()
|
||||
{
|
||||
}
|
||||
private static readonly Unit3dSettingsValidator Validator = new ();
|
||||
|
||||
[FieldDefinition(2, Label = "API Key", HelpText = "Site API Key generated in My Security", Privacy = PrivacyLevel.ApiKey)]
|
||||
public string ApiKey { get; set; }
|
||||
|
|
|
|||
|
|
@ -4,9 +4,13 @@
|
|||
|
||||
namespace NzbDrone.Core.Indexers.Definitions.Xthor
|
||||
{
|
||||
public class XthorSettingsValidator : NoAuthSettingsValidator<XthorSettings>
|
||||
{
|
||||
}
|
||||
|
||||
public class XthorSettings : NoAuthTorrentBaseSettings
|
||||
{
|
||||
private static readonly XthorSettingsValidator Validator = new XthorSettingsValidator();
|
||||
private static readonly XthorSettingsValidator Validator = new ();
|
||||
|
||||
public XthorSettings()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
using FluentValidation;
|
||||
|
||||
namespace NzbDrone.Core.Indexers.Definitions.Xthor
|
||||
{
|
||||
public class XthorSettingsValidator : AbstractValidator<XthorSettings>
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -17,7 +17,7 @@ public IndexerCommonSettingsValidator()
|
|||
|
||||
public class IndexerBaseSettings
|
||||
{
|
||||
private static readonly IndexerCommonSettingsValidator Validator = new IndexerCommonSettingsValidator();
|
||||
private static readonly IndexerCommonSettingsValidator Validator = new ();
|
||||
|
||||
[FieldDefinition(1, Type = FieldType.Number, Label = "Query Limit", HelpText = "The number of queries within a rolling 24 hour period Prowlarr will allow to the site", Advanced = true)]
|
||||
public int? QueryLimit { get; set; }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
using FluentValidation;
|
||||
using NzbDrone.Core.Annotations;
|
||||
using NzbDrone.Core.Validation;
|
||||
|
||||
namespace NzbDrone.Core.Indexers
|
||||
{
|
||||
|
|
@ -10,17 +10,20 @@ public IndexerTorrentSettingsValidator(double seedRatioMinimum = 0.0, int seedTi
|
|||
{
|
||||
RuleFor(c => c.SeedRatio).GreaterThan(0.0)
|
||||
.When(c => c.SeedRatio.HasValue)
|
||||
.AsWarning().WithMessage("Should be greater than zero");
|
||||
.WithMessage("Should be greater than zero");
|
||||
|
||||
RuleFor(c => c.SeedTime).GreaterThan(0)
|
||||
.When(c => c.SeedTime.HasValue)
|
||||
.AsWarning().WithMessage("Should be greater than zero");
|
||||
.WithMessage("Should be greater than zero");
|
||||
|
||||
RuleFor(c => c.PackSeedTime).GreaterThan(0)
|
||||
.When(c => c.PackSeedTime.HasValue)
|
||||
.WithMessage("Should be greater than zero");
|
||||
|
||||
if (seedRatioMinimum != 0.0)
|
||||
{
|
||||
RuleFor(c => c.SeedRatio).GreaterThanOrEqualTo(seedRatioMinimum)
|
||||
.When(c => c.SeedRatio > 0.0)
|
||||
.AsWarning()
|
||||
.WithMessage($"Under {seedRatioMinimum} leads to H&R");
|
||||
}
|
||||
|
||||
|
|
@ -28,15 +31,21 @@ public IndexerTorrentSettingsValidator(double seedRatioMinimum = 0.0, int seedTi
|
|||
{
|
||||
RuleFor(c => c.SeedTime).GreaterThanOrEqualTo(seedTimeMinimum)
|
||||
.When(c => c.SeedTime > 0)
|
||||
.AsWarning()
|
||||
.WithMessage($"Under {seedTimeMinimum} leads to H&R");
|
||||
}
|
||||
|
||||
if (seasonPackSeedTimeMinimum != 0)
|
||||
{
|
||||
RuleFor(c => c.PackSeedTime).GreaterThanOrEqualTo(seasonPackSeedTimeMinimum)
|
||||
.When(c => c.PackSeedTime > 0)
|
||||
.WithMessage($"Under {seasonPackSeedTimeMinimum} leads to H&R");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class IndexerTorrentBaseSettings
|
||||
{
|
||||
private static readonly IndexerTorrentSettingsValidator Validator = new IndexerTorrentSettingsValidator();
|
||||
private static readonly IndexerTorrentSettingsValidator Validator = new ();
|
||||
|
||||
[FieldDefinition(1, Type = FieldType.Textbox, Label = "Seed Ratio", HelpText = "The ratio a torrent should reach before stopping, empty is app's default", Advanced = true)]
|
||||
public double? SeedRatio { get; set; }
|
||||
|
|
|
|||
|
|
@ -4,19 +4,19 @@
|
|||
|
||||
namespace NzbDrone.Core.Indexers.Settings
|
||||
{
|
||||
public class CookieBaseSettingsValidator : AbstractValidator<CookieTorrentBaseSettings>
|
||||
{
|
||||
public CookieBaseSettingsValidator()
|
||||
{
|
||||
RuleFor(c => c.Cookie).NotEmpty();
|
||||
RuleFor(x => x.BaseSettings).SetValidator(new IndexerCommonSettingsValidator());
|
||||
RuleFor(x => x.TorrentBaseSettings).SetValidator(new IndexerTorrentSettingsValidator());
|
||||
}
|
||||
}
|
||||
|
||||
public class CookieTorrentBaseSettings : ITorrentIndexerSettings
|
||||
{
|
||||
public class CookieBaseSettingsValidator : AbstractValidator<CookieTorrentBaseSettings>
|
||||
{
|
||||
public CookieBaseSettingsValidator()
|
||||
{
|
||||
RuleFor(c => c.Cookie).NotEmpty();
|
||||
RuleFor(x => x.BaseSettings).SetValidator(new IndexerCommonSettingsValidator());
|
||||
RuleFor(x => x.TorrentBaseSettings).SetValidator(new IndexerTorrentSettingsValidator());
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly CookieBaseSettingsValidator Validator = new CookieBaseSettingsValidator();
|
||||
private static readonly CookieBaseSettingsValidator Validator = new ();
|
||||
|
||||
public CookieTorrentBaseSettings()
|
||||
{
|
||||
|
|
@ -30,10 +30,10 @@ public CookieTorrentBaseSettings()
|
|||
public string Cookie { get; set; }
|
||||
|
||||
[FieldDefinition(10)]
|
||||
public IndexerBaseSettings BaseSettings { get; set; } = new IndexerBaseSettings();
|
||||
public IndexerBaseSettings BaseSettings { get; set; } = new ();
|
||||
|
||||
[FieldDefinition(11)]
|
||||
public IndexerTorrentBaseSettings TorrentBaseSettings { get; set; } = new IndexerTorrentBaseSettings();
|
||||
public IndexerTorrentBaseSettings TorrentBaseSettings { get; set; } = new ();
|
||||
|
||||
public virtual NzbDroneValidationResult Validate()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@
|
|||
|
||||
namespace NzbDrone.Core.Indexers.Settings
|
||||
{
|
||||
public class NoAuthSettingsValidator : AbstractValidator<NoAuthTorrentBaseSettings>
|
||||
public class NoAuthSettingsValidator<T> : AbstractValidator<T>
|
||||
where T : NoAuthTorrentBaseSettings
|
||||
{
|
||||
public NoAuthSettingsValidator()
|
||||
{
|
||||
|
|
@ -15,16 +16,16 @@ public NoAuthSettingsValidator()
|
|||
|
||||
public class NoAuthTorrentBaseSettings : ITorrentIndexerSettings
|
||||
{
|
||||
private static readonly NoAuthSettingsValidator Validator = new NoAuthSettingsValidator();
|
||||
private static readonly NoAuthSettingsValidator<NoAuthTorrentBaseSettings> Validator = new ();
|
||||
|
||||
[FieldDefinition(1, Label = "Base Url", Type = FieldType.Select, SelectOptionsProviderAction = "getUrls", HelpText = "Select which baseurl Prowlarr will use for requests to the site")]
|
||||
public string BaseUrl { get; set; }
|
||||
|
||||
[FieldDefinition(10)]
|
||||
public IndexerBaseSettings BaseSettings { get; set; } = new IndexerBaseSettings();
|
||||
public IndexerBaseSettings BaseSettings { get; set; } = new ();
|
||||
|
||||
[FieldDefinition(11)]
|
||||
public IndexerTorrentBaseSettings TorrentBaseSettings { get; set; } = new IndexerTorrentBaseSettings();
|
||||
public IndexerTorrentBaseSettings TorrentBaseSettings { get; set; } = new ();
|
||||
|
||||
public virtual NzbDroneValidationResult Validate()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,20 +4,21 @@
|
|||
|
||||
namespace NzbDrone.Core.Indexers.Settings
|
||||
{
|
||||
public class UserPassBaseSettingsValidator<T> : AbstractValidator<T>
|
||||
where T : UserPassTorrentBaseSettings
|
||||
{
|
||||
public UserPassBaseSettingsValidator()
|
||||
{
|
||||
RuleFor(c => c.Username).NotEmpty();
|
||||
RuleFor(c => c.Password).NotEmpty();
|
||||
RuleFor(x => x.BaseSettings).SetValidator(new IndexerCommonSettingsValidator());
|
||||
RuleFor(x => x.TorrentBaseSettings).SetValidator(new IndexerTorrentSettingsValidator());
|
||||
}
|
||||
}
|
||||
|
||||
public class UserPassTorrentBaseSettings : ITorrentIndexerSettings
|
||||
{
|
||||
public class UserPassBaseSettingsValidator : AbstractValidator<UserPassTorrentBaseSettings>
|
||||
{
|
||||
public UserPassBaseSettingsValidator()
|
||||
{
|
||||
RuleFor(c => c.Username).NotEmpty();
|
||||
RuleFor(c => c.Password).NotEmpty();
|
||||
RuleFor(x => x.BaseSettings).SetValidator(new IndexerCommonSettingsValidator());
|
||||
RuleFor(x => x.TorrentBaseSettings).SetValidator(new IndexerTorrentSettingsValidator());
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly UserPassBaseSettingsValidator Validator = new UserPassBaseSettingsValidator();
|
||||
private static readonly UserPassBaseSettingsValidator<UserPassTorrentBaseSettings> Validator = new ();
|
||||
|
||||
public UserPassTorrentBaseSettings()
|
||||
{
|
||||
|
|
@ -35,12 +36,12 @@ public UserPassTorrentBaseSettings()
|
|||
public string Password { get; set; }
|
||||
|
||||
[FieldDefinition(10)]
|
||||
public IndexerBaseSettings BaseSettings { get; set; } = new IndexerBaseSettings();
|
||||
public IndexerBaseSettings BaseSettings { get; set; } = new ();
|
||||
|
||||
[FieldDefinition(11)]
|
||||
public IndexerTorrentBaseSettings TorrentBaseSettings { get; set; } = new IndexerTorrentBaseSettings();
|
||||
public IndexerTorrentBaseSettings TorrentBaseSettings { get; set; } = new ();
|
||||
|
||||
public NzbDroneValidationResult Validate()
|
||||
public virtual NzbDroneValidationResult Validate()
|
||||
{
|
||||
return new NzbDroneValidationResult(Validator.Validate(this));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue