2023-03-24 00:34:19 +00:00
|
|
|
using FluentValidation.Validators;
|
|
|
|
using NzbDrone.Common.Disk;
|
2014-12-02 06:26:25 +00:00
|
|
|
using NzbDrone.Common.Extensions;
|
2013-08-31 20:31:58 +00:00
|
|
|
|
2014-02-16 09:56:12 +00:00
|
|
|
namespace NzbDrone.Core.Validation
|
2013-08-31 20:31:58 +00:00
|
|
|
{
|
2014-02-16 09:56:12 +00:00
|
|
|
public class FolderValidator : PropertyValidator
|
2013-08-31 20:31:58 +00:00
|
|
|
{
|
2023-04-01 13:03:53 +00:00
|
|
|
protected override string GetDefaultMessageTemplate() => "Invalid Path";
|
2013-08-31 20:31:58 +00:00
|
|
|
|
|
|
|
protected override bool IsValid(PropertyValidatorContext context)
|
|
|
|
{
|
2019-12-22 22:08:53 +00:00
|
|
|
if (context.PropertyValue == null)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-03-24 00:34:19 +00:00
|
|
|
return context.PropertyValue.ToString().IsPathValid(PathValidationType.CurrentOs);
|
2013-08-31 20:31:58 +00:00
|
|
|
}
|
|
|
|
}
|
2019-12-22 21:24:10 +00:00
|
|
|
}
|