From 59a7605385b522d0c2782b214023fa79c755d592 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Sat, 20 May 2023 22:22:04 +0300 Subject: [PATCH] Improve validation message for AuthorFolderAsRootFolderValidator (cherry picked from commit a117001de673e80abd90d54a34a7c86292b3a649) --- .../Author/AuthorFolderAsRootFolderValidator.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Readarr.Api.V1/Author/AuthorFolderAsRootFolderValidator.cs b/src/Readarr.Api.V1/Author/AuthorFolderAsRootFolderValidator.cs index f835decef..4ff0a3b5c 100644 --- a/src/Readarr.Api.V1/Author/AuthorFolderAsRootFolderValidator.cs +++ b/src/Readarr.Api.V1/Author/AuthorFolderAsRootFolderValidator.cs @@ -15,7 +15,7 @@ public AuthorFolderAsRootFolderValidator(IBuildFileNames fileNameBuilder) _fileNameBuilder = fileNameBuilder; } - protected override string GetDefaultMessageTemplate() => "Root folder path contains author folder"; + protected override string GetDefaultMessageTemplate() => "Root folder path '{rootFolderPath}' contains author folder '{authorFolder}'"; protected override bool IsValid(PropertyValidatorContext context) { @@ -24,9 +24,7 @@ protected override bool IsValid(PropertyValidatorContext context) return true; } - var authorResource = context.ParentContext.InstanceToValidate as AuthorResource; - - if (authorResource == null) + if (context.ParentContext.InstanceToValidate is not AuthorResource authorResource) { return true; } @@ -36,6 +34,9 @@ protected override bool IsValid(PropertyValidatorContext context) var author = authorResource.ToModel(); var authorFolder = _fileNameBuilder.GetAuthorFolder(author); + context.MessageFormatter.AppendArgument("rootFolderPath", rootFolderPath); + context.MessageFormatter.AppendArgument("authorFolder", authorFolder); + if (authorFolder == rootFolder) { return false;