Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New: Add Download Client validation for indexers
(cherry picked from commit e53b7f8c945e3597ca1719961e82540f1f01f0e9) Closes #3033
- Loading branch information
1 parent
c3c5a47
commit 2af3314
Showing
2 changed files
with
30 additions
and
1 deletion.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
src/NzbDrone.Core/Validation/DownloadClientExistsValidator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using FluentValidation.Validators; | ||
using NzbDrone.Core.Download; | ||
|
||
namespace NzbDrone.Core.Validation | ||
{ | ||
public class DownloadClientExistsValidator : PropertyValidator | ||
{ | ||
private readonly IDownloadClientFactory _downloadClientFactory; | ||
|
||
public DownloadClientExistsValidator(IDownloadClientFactory downloadClientFactory) | ||
{ | ||
_downloadClientFactory = downloadClientFactory; | ||
} | ||
|
||
protected override string GetDefaultMessageTemplate() => "Download Client does not exist"; | ||
|
||
protected override bool IsValid(PropertyValidatorContext context) | ||
{ | ||
if (context?.PropertyValue == null || (int)context.PropertyValue == 0) | ||
{ | ||
return true; | ||
} | ||
|
||
return _downloadClientFactory.Exists((int)context.PropertyValue); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters