diff --git a/src/Sonarr.Api.V3/ImportLists/ImportListExclusionController.cs b/src/Sonarr.Api.V3/ImportLists/ImportListExclusionController.cs index 58742ad79..43f55a259 100644 --- a/src/Sonarr.Api.V3/ImportLists/ImportListExclusionController.cs +++ b/src/Sonarr.Api.V3/ImportLists/ImportListExclusionController.cs @@ -20,7 +20,10 @@ namespace Sonarr.Api.V3.ImportLists { _importListExclusionService = importListExclusionService; - SharedValidator.RuleFor(c => c.TvdbId).NotEmpty().SetValidator(importListExclusionExistsValidator); + SharedValidator.RuleFor(c => c.TvdbId).Cascade(CascadeMode.Stop) + .NotEmpty() + .SetValidator(importListExclusionExistsValidator); + SharedValidator.RuleFor(c => c.Title).NotEmpty(); } diff --git a/src/NzbDrone.Core/ImportLists/Exclusions/ImportListExclusionExistsValidator.cs b/src/Sonarr.Api.V3/ImportLists/ImportListExclusionExistsValidator.cs similarity index 65% rename from src/NzbDrone.Core/ImportLists/Exclusions/ImportListExclusionExistsValidator.cs rename to src/Sonarr.Api.V3/ImportLists/ImportListExclusionExistsValidator.cs index 88b4c0026..0196f169b 100644 --- a/src/NzbDrone.Core/ImportLists/Exclusions/ImportListExclusionExistsValidator.cs +++ b/src/Sonarr.Api.V3/ImportLists/ImportListExclusionExistsValidator.cs @@ -1,6 +1,7 @@ using FluentValidation.Validators; +using NzbDrone.Core.ImportLists.Exclusions; -namespace NzbDrone.Core.ImportLists.Exclusions +namespace Sonarr.Api.V3.ImportLists { public class ImportListExclusionExistsValidator : PropertyValidator { @@ -20,7 +21,12 @@ namespace NzbDrone.Core.ImportLists.Exclusions return true; } - return !_importListExclusionService.All().Exists(s => s.TvdbId == (int)context.PropertyValue); + if (context.InstanceToValidate is not ImportListExclusionResource listExclusionResource) + { + return true; + } + + return !_importListExclusionService.All().Exists(v => v.TvdbId == (int)context.PropertyValue && v.Id != listExclusionResource.Id); } } }