Prevent empty path from breaking custom script validation

This commit is contained in:
Mark McDowall 2025-12-30 12:29:25 -08:00
parent 06c6062531
commit 0d80c093ff

View file

@ -1,4 +1,5 @@
using FluentValidation;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Annotations;
using NzbDrone.Core.Validation;
using NzbDrone.Core.Validation.Paths;
@ -9,9 +10,16 @@ public class CustomScriptSettingsValidator : AbstractValidator<CustomScriptSetti
{
public CustomScriptSettingsValidator()
{
RuleFor(c => c.Path).IsValidPath();
RuleFor(c => c.Path).SetValidator(new SystemFolderValidator()).WithMessage("Must not be a descendant of '{systemFolder}'");
RuleFor(c => c.Arguments).Empty().WithMessage("Arguments are no longer supported for custom scripts");
RuleFor(c => c.Path)
.Cascade(CascadeMode.Stop)
.NotEmpty()
.IsValidPath()
.SetValidator(new SystemFolderValidator())
.WithMessage("Must not be a descendant of '{systemFolder}'");
RuleFor(c => c.Arguments)
.Empty()
.WithMessage("Arguments are no longer supported for custom scripts");
}
}