mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-04 10:02:40 +01:00
Fixed: Better NetImport Validation (Don't Allow Bad ProfileIds)
This commit is contained in:
parent
aa6c8f493e
commit
9bf50d4493
@ -1,17 +1,19 @@
|
|||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
using NzbDrone.Core.NetImport;
|
using NzbDrone.Core.NetImport;
|
||||||
|
using NzbDrone.Core.Validation;
|
||||||
using NzbDrone.Core.Validation.Paths;
|
using NzbDrone.Core.Validation.Paths;
|
||||||
|
|
||||||
namespace NzbDrone.Api.NetImport
|
namespace NzbDrone.Api.NetImport
|
||||||
{
|
{
|
||||||
public class NetImportModule : ProviderModuleBase<NetImportResource, INetImport, NetImportDefinition>
|
public class NetImportModule : ProviderModuleBase<NetImportResource, INetImport, NetImportDefinition>
|
||||||
{
|
{
|
||||||
public NetImportModule(NetImportFactory netImportFactory)
|
public NetImportModule(NetImportFactory netImportFactory, ProfileExistsValidator profileExistsValidator)
|
||||||
: base(netImportFactory, "netimport")
|
: base(netImportFactory, "netimport")
|
||||||
{
|
{
|
||||||
PostValidator.RuleFor(c => c.RootFolderPath).IsValidPath();
|
PostValidator.RuleFor(c => c.RootFolderPath).IsValidPath();
|
||||||
PostValidator.RuleFor(c => c.MinimumAvailability).NotNull();
|
PostValidator.RuleFor(c => c.MinimumAvailability).NotNull();
|
||||||
PostValidator.RuleFor(c => c.ProfileId).NotNull();
|
SharedValidator.RuleFor(c => c.ProfileId).ValidId();
|
||||||
|
SharedValidator.RuleFor(c => c.ProfileId).SetValidator(profileExistsValidator);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void MapToResource(NetImportResource resource, NetImportDefinition definition)
|
protected override void MapToResource(NetImportResource resource, NetImportDefinition definition)
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
using NzbDrone.Core.NetImport;
|
using NzbDrone.Core.NetImport;
|
||||||
|
using NzbDrone.Core.Validation;
|
||||||
using NzbDrone.Core.Validation.Paths;
|
using NzbDrone.Core.Validation.Paths;
|
||||||
|
|
||||||
namespace Radarr.Api.V3.NetImport
|
namespace Radarr.Api.V3.NetImport
|
||||||
@ -8,12 +9,13 @@ public class NetImportModule : ProviderModuleBase<NetImportResource, INetImport,
|
|||||||
{
|
{
|
||||||
public static readonly NetImportResourceMapper ResourceMapper = new NetImportResourceMapper();
|
public static readonly NetImportResourceMapper ResourceMapper = new NetImportResourceMapper();
|
||||||
|
|
||||||
public NetImportModule(NetImportFactory netImportFactory)
|
public NetImportModule(NetImportFactory netImportFactory, ProfileExistsValidator profileExistsValidator)
|
||||||
: base(netImportFactory, "netimport", ResourceMapper)
|
: base(netImportFactory, "netimport", ResourceMapper)
|
||||||
{
|
{
|
||||||
SharedValidator.RuleFor(c => c.RootFolderPath).IsValidPath();
|
SharedValidator.RuleFor(c => c.RootFolderPath).IsValidPath();
|
||||||
SharedValidator.RuleFor(c => c.MinimumAvailability).NotNull();
|
SharedValidator.RuleFor(c => c.MinimumAvailability).NotNull();
|
||||||
SharedValidator.RuleFor(c => c.QualityProfileId).NotNull();
|
SharedValidator.RuleFor(c => c.QualityProfileId).ValidId();
|
||||||
|
SharedValidator.RuleFor(c => c.QualityProfileId).SetValidator(profileExistsValidator);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Validate(NetImportDefinition definition, bool includeWarnings)
|
protected override void Validate(NetImportDefinition definition, bool includeWarnings)
|
||||||
|
Loading…
Reference in New Issue
Block a user