mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-17 17:14:18 +02:00
@@ -1,22 +1,14 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
|
using FluentValidation.Results;
|
||||||
using NzbDrone.Core.Annotations;
|
using NzbDrone.Core.Annotations;
|
||||||
using NzbDrone.Core.Indexers.Settings;
|
using NzbDrone.Core.Indexers.Settings;
|
||||||
using NzbDrone.Core.Validation;
|
using NzbDrone.Core.Validation;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Indexers.Cardigann
|
namespace NzbDrone.Core.Indexers.Cardigann
|
||||||
{
|
{
|
||||||
public class CardigannSettingsValidator : AbstractValidator<CardigannSettings>
|
|
||||||
{
|
|
||||||
public CardigannSettingsValidator()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class CardigannSettings : NoAuthTorrentBaseSettings
|
public class CardigannSettings : NoAuthTorrentBaseSettings
|
||||||
{
|
{
|
||||||
private static readonly CardigannSettingsValidator Validator = new CardigannSettingsValidator();
|
|
||||||
|
|
||||||
public CardigannSettings()
|
public CardigannSettings()
|
||||||
{
|
{
|
||||||
ExtraFieldData = new Dictionary<string, object>();
|
ExtraFieldData = new Dictionary<string, object>();
|
||||||
@@ -26,10 +18,5 @@ namespace NzbDrone.Core.Indexers.Cardigann
|
|||||||
public string DefinitionFile { get; set; }
|
public string DefinitionFile { get; set; }
|
||||||
|
|
||||||
public Dictionary<string, object> ExtraFieldData { get; set; }
|
public Dictionary<string, object> ExtraFieldData { get; set; }
|
||||||
|
|
||||||
public override NzbDroneValidationResult Validate()
|
|
||||||
{
|
|
||||||
return new NzbDroneValidationResult(Validator.Validate(this));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,6 +10,7 @@ namespace NzbDrone.Core.Indexers.Headphones
|
|||||||
{
|
{
|
||||||
RuleFor(c => c.Username).NotEmpty();
|
RuleFor(c => c.Username).NotEmpty();
|
||||||
RuleFor(c => c.Password).NotEmpty();
|
RuleFor(c => c.Password).NotEmpty();
|
||||||
|
RuleFor(x => x.BaseSettings).SetValidator(new IndexerCommonSettingsValidator());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -35,6 +35,7 @@ namespace NzbDrone.Core.Indexers.Newznab
|
|||||||
|
|
||||||
public NewznabSettingsValidator()
|
public NewznabSettingsValidator()
|
||||||
{
|
{
|
||||||
|
RuleFor(x => x.BaseSettings).SetValidator(new IndexerCommonSettingsValidator());
|
||||||
RuleFor(c => c.BaseUrl).ValidRootUrl();
|
RuleFor(c => c.BaseUrl).ValidRootUrl();
|
||||||
RuleFor(c => c.ApiPath).ValidUrlBase("/api");
|
RuleFor(c => c.ApiPath).ValidUrlBase("/api");
|
||||||
RuleFor(c => c.ApiKey).NotEmpty().When(ShouldHaveApiKey);
|
RuleFor(c => c.ApiKey).NotEmpty().When(ShouldHaveApiKey);
|
||||||
|
@@ -29,6 +29,8 @@ namespace NzbDrone.Core.Indexers.Torznab
|
|||||||
|
|
||||||
public TorznabSettingsValidator()
|
public TorznabSettingsValidator()
|
||||||
{
|
{
|
||||||
|
RuleFor(x => x.BaseSettings).SetValidator(new IndexerCommonSettingsValidator());
|
||||||
|
RuleFor(x => x.TorrentBaseSettings).SetValidator(new IndexerTorrentSettingsValidator());
|
||||||
RuleFor(c => c.BaseUrl).ValidRootUrl();
|
RuleFor(c => c.BaseUrl).ValidRootUrl();
|
||||||
RuleFor(c => c.ApiPath).ValidUrlBase("/api");
|
RuleFor(c => c.ApiPath).ValidUrlBase("/api");
|
||||||
RuleFor(c => c.ApiKey).NotEmpty().When(ShouldHaveApiKey);
|
RuleFor(c => c.ApiKey).NotEmpty().When(ShouldHaveApiKey);
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
using NzbDrone.Core.Annotations;
|
using NzbDrone.Core.Annotations;
|
||||||
|
using NzbDrone.Core.ThingiProvider;
|
||||||
|
using NzbDrone.Core.Validation;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Indexers
|
namespace NzbDrone.Core.Indexers
|
||||||
{
|
{
|
||||||
@@ -7,6 +9,9 @@ namespace NzbDrone.Core.Indexers
|
|||||||
{
|
{
|
||||||
public IndexerCommonSettingsValidator()
|
public IndexerCommonSettingsValidator()
|
||||||
{
|
{
|
||||||
|
RuleFor(c => c.QueryLimit).GreaterThan(0).When(c => c.QueryLimit.HasValue).WithMessage("Should be greater than zero");
|
||||||
|
|
||||||
|
RuleFor(c => c.GrabLimit).GreaterThan(0).When(c => c.GrabLimit.HasValue).WithMessage("Should be greater than zero");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -11,6 +11,8 @@ namespace NzbDrone.Core.Indexers.Settings
|
|||||||
public CookieBaseSettingsValidator()
|
public CookieBaseSettingsValidator()
|
||||||
{
|
{
|
||||||
RuleFor(c => c.Cookie).NotEmpty();
|
RuleFor(c => c.Cookie).NotEmpty();
|
||||||
|
RuleFor(x => x.BaseSettings).SetValidator(new IndexerCommonSettingsValidator());
|
||||||
|
RuleFor(x => x.TorrentBaseSettings).SetValidator(new IndexerTorrentSettingsValidator());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -6,6 +6,11 @@ namespace NzbDrone.Core.Indexers.Settings
|
|||||||
{
|
{
|
||||||
public class NoAuthSettingsValidator : AbstractValidator<NoAuthTorrentBaseSettings>
|
public class NoAuthSettingsValidator : AbstractValidator<NoAuthTorrentBaseSettings>
|
||||||
{
|
{
|
||||||
|
public NoAuthSettingsValidator()
|
||||||
|
{
|
||||||
|
RuleFor(x => x.BaseSettings).SetValidator(new IndexerCommonSettingsValidator());
|
||||||
|
RuleFor(x => x.TorrentBaseSettings).SetValidator(new IndexerTorrentSettingsValidator());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class NoAuthTorrentBaseSettings : ITorrentIndexerSettings
|
public class NoAuthTorrentBaseSettings : ITorrentIndexerSettings
|
||||||
|
@@ -12,6 +12,8 @@ namespace NzbDrone.Core.Indexers.Settings
|
|||||||
{
|
{
|
||||||
RuleFor(c => c.Username).NotEmpty();
|
RuleFor(c => c.Username).NotEmpty();
|
||||||
RuleFor(c => c.Password).NotEmpty();
|
RuleFor(c => c.Password).NotEmpty();
|
||||||
|
RuleFor(x => x.BaseSettings).SetValidator(new IndexerCommonSettingsValidator());
|
||||||
|
RuleFor(x => x.TorrentBaseSettings).SetValidator(new IndexerTorrentSettingsValidator());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user