mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-29 21:39:34 +02:00
Fixed: Validation inheritance
This commit is contained in:
@@ -521,7 +521,7 @@ namespace NzbDrone.Core.Indexers.Definitions
|
||||
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 @@ namespace NzbDrone.Core.Indexers.Definitions
|
||||
|
||||
public class AnimeBytesSettings : NoAuthTorrentBaseSettings
|
||||
{
|
||||
private static readonly AnimeBytesSettingsValidator Validator = new AnimeBytesSettingsValidator();
|
||||
private static readonly AnimeBytesSettingsValidator Validator = new ();
|
||||
|
||||
public AnimeBytesSettings()
|
||||
{
|
||||
|
@@ -5,7 +5,7 @@ using NzbDrone.Core.Validation;
|
||||
|
||||
namespace NzbDrone.Core.Indexers.Definitions.Avistaz
|
||||
{
|
||||
public class AvistazSettingsValidator : AbstractValidator<AvistazSettings>
|
||||
public class AvistazSettingsValidator : NoAuthSettingsValidator<AvistazSettings>
|
||||
{
|
||||
public AvistazSettingsValidator()
|
||||
{
|
||||
@@ -17,7 +17,7 @@ namespace NzbDrone.Core.Indexers.Definitions.Avistaz
|
||||
|
||||
public class AvistazSettings : NoAuthTorrentBaseSettings
|
||||
{
|
||||
private static readonly AvistazSettingsValidator Validator = new AvistazSettingsValidator();
|
||||
private static readonly AvistazSettingsValidator Validator = new ();
|
||||
|
||||
public AvistazSettings()
|
||||
{
|
||||
|
@@ -246,7 +246,7 @@ namespace NzbDrone.Core.Indexers.Definitions
|
||||
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 @@ namespace NzbDrone.Core.Indexers.Definitions
|
||||
|
||||
public class BeyondHDSettings : NoAuthTorrentBaseSettings
|
||||
{
|
||||
private static readonly BeyondHDSettingsValidator Validator = new BeyondHDSettingsValidator();
|
||||
private static readonly BeyondHDSettingsValidator Validator = new ();
|
||||
|
||||
public BeyondHDSettings()
|
||||
{
|
||||
|
@@ -219,7 +219,7 @@ namespace NzbDrone.Core.Indexers.Definitions
|
||||
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 @@ using NzbDrone.Core.Validation;
|
||||
|
||||
namespace NzbDrone.Core.Indexers.BroadcastheNet
|
||||
{
|
||||
public class BroadcastheNetSettingsValidator : AbstractValidator<BroadcastheNetSettings>
|
||||
public class BroadcastheNetSettingsValidator : NoAuthSettingsValidator<BroadcastheNetSettings>
|
||||
{
|
||||
public BroadcastheNetSettingsValidator()
|
||||
{
|
||||
@@ -15,11 +15,7 @@ namespace NzbDrone.Core.Indexers.BroadcastheNet
|
||||
|
||||
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 @@ using NzbDrone.Core.Validation;
|
||||
|
||||
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 GazelleSettings : UserPassTorrentBaseSettings
|
||||
{
|
||||
public GazelleSettings()
|
||||
public class GazelleSettingsValidator : UserPassBaseSettingsValidator<GazelleSettings>
|
||||
{
|
||||
}
|
||||
|
||||
public class GazelleSettings : UserPassTorrentBaseSettings
|
||||
{
|
||||
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 @@ namespace NzbDrone.Core.Indexers.Definitions
|
||||
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 @@ namespace NzbDrone.Core.Indexers.Definitions
|
||||
|
||||
public class GazelleGamesSettings : NoAuthTorrentBaseSettings
|
||||
{
|
||||
private static readonly GazelleGamesSettingsValidator Validator = new GazelleGamesSettingsValidator();
|
||||
private static readonly GazelleGamesSettingsValidator Validator = new ();
|
||||
|
||||
public GazelleGamesSettings()
|
||||
{
|
||||
|
@@ -6,7 +6,7 @@ using NzbDrone.Core.Validation;
|
||||
|
||||
namespace NzbDrone.Core.Indexers.HDBits
|
||||
{
|
||||
public class HDBitsSettingsValidator : AbstractValidator<HDBitsSettings>
|
||||
public class HDBitsSettingsValidator : NoAuthSettingsValidator<HDBitsSettings>
|
||||
{
|
||||
public HDBitsSettingsValidator()
|
||||
{
|
||||
@@ -16,7 +16,7 @@ namespace NzbDrone.Core.Indexers.HDBits
|
||||
|
||||
public class HDBitsSettings : NoAuthTorrentBaseSettings
|
||||
{
|
||||
private static readonly HDBitsSettingsValidator Validator = new HDBitsSettingsValidator();
|
||||
private static readonly HDBitsSettingsValidator Validator = new ();
|
||||
|
||||
public HDBitsSettings()
|
||||
{
|
||||
|
@@ -16,7 +16,7 @@ namespace NzbDrone.Core.Indexers.Headphones
|
||||
|
||||
public class HeadphonesSettings : IIndexerSettings
|
||||
{
|
||||
private static readonly HeadphonesSettingsValidator Validator = new HeadphonesSettingsValidator();
|
||||
private static readonly HeadphonesSettingsValidator Validator = new ();
|
||||
|
||||
public HeadphonesSettings()
|
||||
{
|
||||
@@ -38,7 +38,7 @@ namespace NzbDrone.Core.Indexers.Headphones
|
||||
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 @@ namespace NzbDrone.Core.Indexers.Definitions
|
||||
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 @@ namespace NzbDrone.Core.Indexers.Definitions
|
||||
|
||||
public class MyAnonamouseSettings : NoAuthTorrentBaseSettings
|
||||
{
|
||||
private static readonly MyAnonamouseSettingsValidator Validator = new MyAnonamouseSettingsValidator();
|
||||
private static readonly MyAnonamouseSettingsValidator Validator = new ();
|
||||
|
||||
public MyAnonamouseSettings()
|
||||
{
|
||||
|
@@ -54,7 +54,7 @@ namespace NzbDrone.Core.Indexers.Newznab
|
||||
|
||||
public class NewznabSettings : IIndexerSettings
|
||||
{
|
||||
private static readonly NewznabSettingsValidator Validator = new NewznabSettingsValidator();
|
||||
private static readonly NewznabSettingsValidator Validator = new ();
|
||||
|
||||
public NewznabSettings()
|
||||
{
|
||||
@@ -78,7 +78,7 @@ namespace NzbDrone.Core.Indexers.Newznab
|
||||
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 @@ namespace NzbDrone.Core.Indexers.Definitions
|
||||
|
||||
public class NzbIndexSettings : IIndexerSettings
|
||||
{
|
||||
private static readonly NzbIndexSettingsValidator Validator = new NzbIndexSettingsValidator();
|
||||
private static readonly NzbIndexSettingsValidator Validator = new ();
|
||||
|
||||
public NzbIndexSettings()
|
||||
{
|
||||
@@ -1182,7 +1182,9 @@ namespace NzbDrone.Core.Indexers.Definitions
|
||||
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 @@ namespace NzbDrone.Core.Indexers.Definitions
|
||||
}
|
||||
}
|
||||
|
||||
public class OrpheusSettingsValidator : AbstractValidator<OrpheusSettings>
|
||||
public class OrpheusSettingsValidator : NoAuthSettingsValidator<OrpheusSettings>
|
||||
{
|
||||
public OrpheusSettingsValidator()
|
||||
{
|
||||
|
@@ -5,7 +5,7 @@ using NzbDrone.Core.Validation;
|
||||
|
||||
namespace NzbDrone.Core.Indexers.PassThePopcorn
|
||||
{
|
||||
public class PassThePopcornSettingsValidator : AbstractValidator<PassThePopcornSettings>
|
||||
public class PassThePopcornSettingsValidator : NoAuthSettingsValidator<PassThePopcornSettings>
|
||||
{
|
||||
public PassThePopcornSettingsValidator()
|
||||
{
|
||||
@@ -16,11 +16,7 @@ namespace NzbDrone.Core.Indexers.PassThePopcorn
|
||||
|
||||
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 @@ namespace NzbDrone.Core.Indexers.Definitions
|
||||
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 @@ namespace NzbDrone.Core.Indexers.Definitions
|
||||
|
||||
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 @@ namespace NzbDrone.Core.Indexers.Definitions
|
||||
}
|
||||
}
|
||||
|
||||
public class RedactedSettingsValidator : AbstractValidator<RedactedSettings>
|
||||
public class RedactedSettingsValidator : NoAuthSettingsValidator<RedactedSettings>
|
||||
{
|
||||
public RedactedSettingsValidator()
|
||||
{
|
||||
@@ -336,7 +336,7 @@ namespace NzbDrone.Core.Indexers.Definitions
|
||||
|
||||
public class RedactedSettings : NoAuthTorrentBaseSettings
|
||||
{
|
||||
private static readonly RedactedSettingsValidator Validator = new RedactedSettingsValidator();
|
||||
private static readonly RedactedSettingsValidator Validator = new ();
|
||||
|
||||
public RedactedSettings()
|
||||
{
|
||||
|
@@ -233,7 +233,7 @@ namespace NzbDrone.Core.Indexers.Definitions
|
||||
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 @@ namespace NzbDrone.Core.Indexers.Definitions
|
||||
|
||||
public class SceneHDSettings : NoAuthTorrentBaseSettings
|
||||
{
|
||||
private static readonly SceneHDSettingsValidator Validator = new SceneHDSettingsValidator();
|
||||
private static readonly SceneHDSettingsValidator Validator = new ();
|
||||
|
||||
public SceneHDSettings()
|
||||
{
|
||||
|
@@ -332,7 +332,7 @@ namespace NzbDrone.Core.Indexers.Definitions
|
||||
}
|
||||
}
|
||||
|
||||
public class SpeedAppSettingsValidator : AbstractValidator<SpeedAppSettings>
|
||||
public class SpeedAppSettingsValidator : NoAuthSettingsValidator<SpeedAppSettings>
|
||||
{
|
||||
public SpeedAppSettingsValidator()
|
||||
{
|
||||
|
@@ -5,16 +5,28 @@ using NzbDrone.Core.Validation;
|
||||
|
||||
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 @@ namespace NzbDrone.Core.Indexers.Definitions
|
||||
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 @@ namespace NzbDrone.Core.Indexers.Definitions
|
||||
|
||||
public class TorrentSyndikatSettings : NoAuthTorrentBaseSettings
|
||||
{
|
||||
private static readonly TorrentSyndikatSettingsValidator Validator = new TorrentSyndikatSettingsValidator();
|
||||
private static readonly TorrentSyndikatSettingsValidator Validator = new ();
|
||||
|
||||
public TorrentSyndikatSettings()
|
||||
{
|
||||
|
@@ -41,14 +41,10 @@ namespace NzbDrone.Core.Indexers.Torznab
|
||||
|
||||
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 @@ using NzbDrone.Core.Validation;
|
||||
|
||||
namespace NzbDrone.Core.Indexers.Definitions.UNIT3D
|
||||
{
|
||||
public class Unit3dSettingsValidator : AbstractValidator<Unit3dSettings>
|
||||
public class Unit3dSettingsValidator : NoAuthSettingsValidator<Unit3dSettings>
|
||||
{
|
||||
public Unit3dSettingsValidator()
|
||||
{
|
||||
@@ -15,11 +15,7 @@ namespace NzbDrone.Core.Indexers.Definitions.UNIT3D
|
||||
|
||||
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 @@ using NzbDrone.Core.Validation;
|
||||
|
||||
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 @@ namespace NzbDrone.Core.Indexers
|
||||
|
||||
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 @@ namespace NzbDrone.Core.Indexers
|
||||
{
|
||||
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 @@ namespace NzbDrone.Core.Indexers
|
||||
{
|
||||
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,8 +4,6 @@ using NzbDrone.Core.Validation;
|
||||
|
||||
namespace NzbDrone.Core.Indexers.Settings
|
||||
{
|
||||
public class CookieTorrentBaseSettings : ITorrentIndexerSettings
|
||||
{
|
||||
public class CookieBaseSettingsValidator : AbstractValidator<CookieTorrentBaseSettings>
|
||||
{
|
||||
public CookieBaseSettingsValidator()
|
||||
@@ -16,7 +14,9 @@ namespace NzbDrone.Core.Indexers.Settings
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly CookieBaseSettingsValidator Validator = new CookieBaseSettingsValidator();
|
||||
public class CookieTorrentBaseSettings : ITorrentIndexerSettings
|
||||
{
|
||||
private static readonly CookieBaseSettingsValidator Validator = new ();
|
||||
|
||||
public CookieTorrentBaseSettings()
|
||||
{
|
||||
@@ -30,10 +30,10 @@ namespace NzbDrone.Core.Indexers.Settings
|
||||
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 @@ using NzbDrone.Core.Validation;
|
||||
|
||||
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 @@ namespace NzbDrone.Core.Indexers.Settings
|
||||
|
||||
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,9 +4,8 @@ using NzbDrone.Core.Validation;
|
||||
|
||||
namespace NzbDrone.Core.Indexers.Settings
|
||||
{
|
||||
public class UserPassTorrentBaseSettings : ITorrentIndexerSettings
|
||||
{
|
||||
public class UserPassBaseSettingsValidator : AbstractValidator<UserPassTorrentBaseSettings>
|
||||
public class UserPassBaseSettingsValidator<T> : AbstractValidator<T>
|
||||
where T : UserPassTorrentBaseSettings
|
||||
{
|
||||
public UserPassBaseSettingsValidator()
|
||||
{
|
||||
@@ -17,7 +16,9 @@ namespace NzbDrone.Core.Indexers.Settings
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly UserPassBaseSettingsValidator Validator = new UserPassBaseSettingsValidator();
|
||||
public class UserPassTorrentBaseSettings : ITorrentIndexerSettings
|
||||
{
|
||||
private static readonly UserPassBaseSettingsValidator<UserPassTorrentBaseSettings> Validator = new ();
|
||||
|
||||
public UserPassTorrentBaseSettings()
|
||||
{
|
||||
@@ -35,12 +36,12 @@ namespace NzbDrone.Core.Indexers.Settings
|
||||
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));
|
||||
}
|
||||
|
Reference in New Issue
Block a user