|
|
|
@ -1,3 +1,4 @@
|
|
|
|
|
using FluentValidation;
|
|
|
|
|
using Lidarr.Http;
|
|
|
|
|
using NzbDrone.Core.ImportLists;
|
|
|
|
|
using NzbDrone.Core.Validation;
|
|
|
|
@ -12,16 +13,22 @@ namespace Lidarr.Api.V1.ImportLists
|
|
|
|
|
public static readonly ImportListBulkResourceMapper BulkResourceMapper = new ();
|
|
|
|
|
|
|
|
|
|
public ImportListController(IImportListFactory importListFactory,
|
|
|
|
|
RootFolderExistsValidator rootFolderExistsValidator,
|
|
|
|
|
QualityProfileExistsValidator qualityProfileExistsValidator,
|
|
|
|
|
MetadataProfileExistsValidator metadataProfileExistsValidator)
|
|
|
|
|
: base(importListFactory, "importlist", ResourceMapper, BulkResourceMapper)
|
|
|
|
|
{
|
|
|
|
|
Http.Validation.RuleBuilderExtensions.ValidId(SharedValidator.RuleFor(s => s.QualityProfileId));
|
|
|
|
|
Http.Validation.RuleBuilderExtensions.ValidId(SharedValidator.RuleFor(s => s.MetadataProfileId));
|
|
|
|
|
SharedValidator.RuleFor(c => c.RootFolderPath).Cascade(CascadeMode.Stop)
|
|
|
|
|
.IsValidPath()
|
|
|
|
|
.SetValidator(rootFolderExistsValidator);
|
|
|
|
|
|
|
|
|
|
SharedValidator.RuleFor(c => c.RootFolderPath).IsValidPath();
|
|
|
|
|
SharedValidator.RuleFor(c => c.QualityProfileId).SetValidator(qualityProfileExistsValidator);
|
|
|
|
|
SharedValidator.RuleFor(c => c.MetadataProfileId).SetValidator(metadataProfileExistsValidator);
|
|
|
|
|
SharedValidator.RuleFor(c => c.QualityProfileId).Cascade(CascadeMode.Stop)
|
|
|
|
|
.ValidId()
|
|
|
|
|
.SetValidator(qualityProfileExistsValidator);
|
|
|
|
|
|
|
|
|
|
SharedValidator.RuleFor(c => c.MetadataProfileId).Cascade(CascadeMode.Stop)
|
|
|
|
|
.ValidId()
|
|
|
|
|
.SetValidator(metadataProfileExistsValidator);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|