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.
28 lines
817 B
28 lines
817 B
using FluentValidation.Validators;
|
|
using NzbDrone.Core.Profiles.Qualities;
|
|
|
|
namespace NzbDrone.Core.Validation
|
|
{
|
|
public class QualityProfileExistsValidator : PropertyValidator
|
|
{
|
|
private readonly IQualityProfileService _profileService;
|
|
|
|
public QualityProfileExistsValidator(IQualityProfileService profileService)
|
|
{
|
|
_profileService = profileService;
|
|
}
|
|
|
|
protected override string GetDefaultMessageTemplate() => "Quality Profile does not exist";
|
|
|
|
protected override bool IsValid(PropertyValidatorContext context)
|
|
{
|
|
if (context?.PropertyValue == null || (int)context.PropertyValue == 0)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
return _profileService.Exists((int)context.PropertyValue);
|
|
}
|
|
}
|
|
}
|