1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-04 10:02:40 +01:00

More descriptive validation error for Movie Path

This commit is contained in:
Qstick 2020-07-09 10:41:17 -04:00
parent c51fe81f41
commit 135251ec31

View File

@ -1,4 +1,4 @@
using FluentValidation.Validators; using FluentValidation.Validators;
using NzbDrone.Common.Extensions; using NzbDrone.Common.Extensions;
using NzbDrone.Core.Movies; using NzbDrone.Core.Movies;
@ -9,7 +9,7 @@ public class MoviePathValidator : PropertyValidator
private readonly IMovieService _moviesService; private readonly IMovieService _moviesService;
public MoviePathValidator(IMovieService moviesService) public MoviePathValidator(IMovieService moviesService)
: base("Path is already configured for another movie") : base("Path is already configured for another movie: {moviePath}")
{ {
_moviesService = moviesService; _moviesService = moviesService;
} }
@ -24,6 +24,8 @@ protected override bool IsValid(PropertyValidatorContext context)
dynamic instance = context.ParentContext.InstanceToValidate; dynamic instance = context.ParentContext.InstanceToValidate;
var instanceId = (int)instance.Id; var instanceId = (int)instance.Id;
context.MessageFormatter.AppendArgument("moviePath", context.PropertyValue.ToString());
return !_moviesService.GetAllMovies().Exists(s => s.Path.PathEquals(context.PropertyValue.ToString()) && s.Id != instanceId); return !_moviesService.GetAllMovies().Exists(s => s.Path.PathEquals(context.PropertyValue.ToString()) && s.Id != instanceId);
} }
} }