mirror of https://github.com/lidarr/Lidarr
24 lines
685 B
C#
24 lines
685 B
C#
using FluentValidation.Validators;
|
|
using NzbDrone.Common.Disk;
|
|
using NzbDrone.Common.Extensions;
|
|
|
|
namespace NzbDrone.Core.Validation
|
|
{
|
|
public class FolderValidator : PropertyValidator
|
|
{
|
|
protected override string GetDefaultMessageTemplate() => "Invalid Path: '{path}'";
|
|
|
|
protected override bool IsValid(PropertyValidatorContext context)
|
|
{
|
|
if (context.PropertyValue == null)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
context.MessageFormatter.AppendArgument("path", context.PropertyValue.ToString());
|
|
|
|
return context.PropertyValue.ToString().IsPathValid(PathValidationType.CurrentOs);
|
|
}
|
|
}
|
|
}
|