mirror of https://github.com/Sonarr/Sonarr
27 lines
683 B
C#
27 lines
683 B
C#
![]() |
using FluentValidation.Validators;
|
|||
|
using NzbDrone.Common.Disk;
|
|||
|
|
|||
|
namespace NzbDrone.Core.Validation.Paths
|
|||
|
{
|
|||
|
public class FileExistsValidator : PropertyValidator
|
|||
|
{
|
|||
|
private readonly IDiskProvider _diskProvider;
|
|||
|
|
|||
|
public FileExistsValidator(IDiskProvider diskProvider)
|
|||
|
: base("File does not exist")
|
|||
|
{
|
|||
|
_diskProvider = diskProvider;
|
|||
|
}
|
|||
|
|
|||
|
protected override bool IsValid(PropertyValidatorContext context)
|
|||
|
{
|
|||
|
if (context.PropertyValue == null)
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
|
|||
|
return _diskProvider.FileExists(context.PropertyValue.ToString());
|
|||
|
}
|
|||
|
}
|
|||
|
}
|