Add enum validation for MetaDataLink

pull/6613/head
Ivar Stangeby 3 months ago
parent 54540c3c7f
commit f7addbf607

@ -1,3 +1,4 @@
using System;
using System.ComponentModel;
using FluentValidation;
using NzbDrone.Core.Annotations;
@ -14,6 +15,13 @@ namespace NzbDrone.Core.Notifications.Telegram
RuleFor(c => c.ChatId).NotEmpty();
RuleFor(c => c.TopicId).Must(topicId => !topicId.HasValue || topicId > 1)
.WithMessage("Topic ID must be greater than 1 or empty");
RuleFor(c => c.MetadataLinkType).Custom((metadataLinkType, context) =>
{
if (!Enum.IsDefined(typeof(MetadataLinkType), metadataLinkType))
{
context.AddFailure($"MetadataLinkType is not valid: {0}");
}
});
}
}

Loading…
Cancel
Save