diff --git a/src/Lidarr.Api.V1/Artist/ArtistModule.cs b/src/Lidarr.Api.V1/Artist/ArtistModule.cs
index 44d8fa173..3b9267d46 100644
--- a/src/Lidarr.Api.V1/Artist/ArtistModule.cs
+++ b/src/Lidarr.Api.V1/Artist/ArtistModule.cs
@@ -35,20 +35,19 @@ namespace Lidarr.Api.V1.Artist
private readonly IAddArtistService _addArtistService;
private readonly IArtistStatisticsService _artistStatisticsService;
private readonly IMapCoversToLocal _coverMapper;
- private readonly IAlbumService _albumService;
public ArtistModule(IBroadcastSignalRMessage signalRBroadcaster,
IArtistService artistService,
IAddArtistService addArtistService,
IArtistStatisticsService artistStatisticsService,
IMapCoversToLocal coverMapper,
- IAlbumService albumService,
RootFolderValidator rootFolderValidator,
ArtistPathValidator artistPathValidator,
ArtistExistsValidator artistExistsValidator,
ArtistAncestorValidator artistAncestorValidator,
ProfileExistsValidator profileExistsValidator,
- LanguageProfileExistsValidator languageProfileExistsValidator
+ LanguageProfileExistsValidator languageProfileExistsValidator,
+ MetadataProfileExistsValidator metadataProfileExistsValidator
)
: base(signalRBroadcaster)
{
@@ -57,7 +56,6 @@ namespace Lidarr.Api.V1.Artist
_artistStatisticsService = artistStatisticsService;
_coverMapper = coverMapper;
- _albumService = albumService;
GetResourceAll = AllArtists;
GetResourceById = GetArtist;
@@ -77,6 +75,7 @@ namespace Lidarr.Api.V1.Artist
SharedValidator.RuleFor(s => s.QualityProfileId).SetValidator(profileExistsValidator);
SharedValidator.RuleFor(s => s.LanguageProfileId).SetValidator(languageProfileExistsValidator);
+ SharedValidator.RuleFor(s => s.MetadataProfileId).SetValidator(metadataProfileExistsValidator);
PostValidator.RuleFor(s => s.Path).IsValidPath().When(s => s.RootFolderPath.IsNullOrWhiteSpace());
PostValidator.RuleFor(s => s.RootFolderPath).IsValidPath().When(s => s.Path.IsNullOrWhiteSpace());
diff --git a/src/NzbDrone.Core/NzbDrone.Core.csproj b/src/NzbDrone.Core/NzbDrone.Core.csproj
index f9ad93dc4..a1670af00 100644
--- a/src/NzbDrone.Core/NzbDrone.Core.csproj
+++ b/src/NzbDrone.Core/NzbDrone.Core.csproj
@@ -1069,6 +1069,7 @@
+
diff --git a/src/NzbDrone.Core/Validation/MetadataProfileExistsValidator.cs b/src/NzbDrone.Core/Validation/MetadataProfileExistsValidator.cs
new file mode 100644
index 000000000..82499a304
--- /dev/null
+++ b/src/NzbDrone.Core/Validation/MetadataProfileExistsValidator.cs
@@ -0,0 +1,23 @@
+using FluentValidation.Validators;
+using NzbDrone.Core.Profiles.Metadata;
+
+namespace NzbDrone.Core.Validation
+{
+ public class MetadataProfileExistsValidator : PropertyValidator
+ {
+ private readonly IMetadataProfileService _profileService;
+
+ public MetadataProfileExistsValidator(IMetadataProfileService profileService)
+ : base("Metadata profile does not exist")
+ {
+ _profileService = profileService;
+ }
+
+ protected override bool IsValid(PropertyValidatorContext context)
+ {
+ if (context.PropertyValue == null) return true;
+
+ return _profileService.Exists((int)context.PropertyValue);
+ }
+ }
+}