diff --git a/src/Lidarr.Api.V1/ImportLists/ImportListExclusionController.cs b/src/Lidarr.Api.V1/ImportLists/ImportListExclusionController.cs index b5b30f1cd..c78bbc1ad 100644 --- a/src/Lidarr.Api.V1/ImportLists/ImportListExclusionController.cs +++ b/src/Lidarr.Api.V1/ImportLists/ImportListExclusionController.cs @@ -20,7 +20,11 @@ public ImportListExclusionController(IImportListExclusionService importListExclu { _importListExclusionService = importListExclusionService; - SharedValidator.RuleFor(c => c.ForeignId).NotEmpty().SetValidator(guidValidator).SetValidator(importListExclusionExistsValidator); + SharedValidator.RuleFor(c => c.ForeignId).Cascade(CascadeMode.Stop) + .NotEmpty() + .SetValidator(guidValidator) + .SetValidator(importListExclusionExistsValidator); + SharedValidator.RuleFor(c => c.ArtistName).NotEmpty(); } diff --git a/src/NzbDrone.Core/ImportLists/Exclusions/ImportListExclusionExistsValidator.cs b/src/Lidarr.Api.V1/ImportLists/ImportListExclusionExistsValidator.cs similarity index 64% rename from src/NzbDrone.Core/ImportLists/Exclusions/ImportListExclusionExistsValidator.cs rename to src/Lidarr.Api.V1/ImportLists/ImportListExclusionExistsValidator.cs index 2883f473a..101e83397 100644 --- a/src/NzbDrone.Core/ImportLists/Exclusions/ImportListExclusionExistsValidator.cs +++ b/src/Lidarr.Api.V1/ImportLists/ImportListExclusionExistsValidator.cs @@ -1,6 +1,7 @@ using FluentValidation.Validators; +using NzbDrone.Core.ImportLists.Exclusions; -namespace NzbDrone.Core.ImportLists.Exclusions +namespace Lidarr.Api.V1.ImportLists { public class ImportListExclusionExistsValidator : PropertyValidator { @@ -20,7 +21,12 @@ protected override bool IsValid(PropertyValidatorContext context) return true; } - return !_importListExclusionService.All().Exists(s => s.ForeignId == context.PropertyValue.ToString()); + if (context.InstanceToValidate is not ImportListExclusionResource listExclusionResource) + { + return true; + } + + return !_importListExclusionService.All().Exists(v => v.ForeignId == context.PropertyValue.ToString() && v.Id != listExclusionResource.Id); } } } diff --git a/src/NzbDrone.Core/Validation/GuidValidator.cs b/src/NzbDrone.Core/Validation/GuidValidator.cs index 99a491acd..19956a2fd 100644 --- a/src/NzbDrone.Core/Validation/GuidValidator.cs +++ b/src/NzbDrone.Core/Validation/GuidValidator.cs @@ -14,7 +14,7 @@ protected override bool IsValid(PropertyValidatorContext context) return false; } - return Guid.TryParse(context.PropertyValue.ToString(), out var guidOutput); + return Guid.TryParse(context.PropertyValue.ToString(), out _); } } }