You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
1.3 KiB
30 lines
1.3 KiB
using FluentValidation;
|
|
using FluentValidation.Results;
|
|
using NzbDrone.Common.Extensions;
|
|
using NzbDrone.Core.Download.Clients.RTorrent;
|
|
using NzbDrone.Core.Validation.Paths;
|
|
|
|
namespace NzbDrone.Core.Download.Clients.rTorrent
|
|
{
|
|
public interface IRTorrentDirectoryValidator
|
|
{
|
|
ValidationResult Validate(RTorrentSettings instance);
|
|
}
|
|
|
|
public class RTorrentDirectoryValidator : AbstractValidator<RTorrentSettings>, IRTorrentDirectoryValidator
|
|
{
|
|
public RTorrentDirectoryValidator(RootFolderValidator rootFolderValidator,
|
|
PathExistsValidator pathExistsValidator,
|
|
MappedNetworkDriveValidator mappedNetworkDriveValidator)
|
|
{
|
|
RuleFor(c => c.MusicDirectory).Cascade(CascadeMode.Stop)
|
|
.IsValidPath()
|
|
.SetValidator(rootFolderValidator)
|
|
.SetValidator(mappedNetworkDriveValidator)
|
|
.SetValidator(pathExistsValidator)
|
|
.When(c => c.MusicDirectory.IsNotNullOrWhiteSpace())
|
|
.When(c => c.Host == "localhost" || c.Host == "127.0.0.1");
|
|
}
|
|
}
|
|
}
|