parent
db03f43e30
commit
56f6b923e1
@ -0,0 +1,23 @@
|
||||
using FluentValidation.Validators;
|
||||
using NzbDrone.Core.Profiles.Metadata;
|
||||
|
||||
namespace NzbDrone.Core.Validation
|
||||
{
|
||||
public class MetadataProfileExistsValidator : PropertyValidator
|
||||
{
|
||||
private readonly IMetadataProfileService _profileService;
|
||||
|
||||
public MetadataProfileExistsValidator(IMetadataProfileService profileService)
|
||||
: base("Metadata profile does not exist")
|
||||
{
|
||||
_profileService = profileService;
|
||||
}
|
||||
|
||||
protected override bool IsValid(PropertyValidatorContext context)
|
||||
{
|
||||
if (context.PropertyValue == null) return true;
|
||||
|
||||
return _profileService.Exists((int)context.PropertyValue);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue