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.
40 lines
1.4 KiB
40 lines
1.4 KiB
using FluentValidation;
|
|
using JetBrains.Annotations;
|
|
using TrashLib.Services.Radarr.Config;
|
|
|
|
namespace TrashLib.Config.Services;
|
|
|
|
[UsedImplicitly]
|
|
internal class ServiceConfigurationValidator : AbstractValidator<ServiceConfiguration>
|
|
{
|
|
public ServiceConfigurationValidator(
|
|
IServiceValidationMessages messages,
|
|
IValidator<CustomFormatConfig> customFormatConfigValidator)
|
|
{
|
|
RuleFor(x => x.BaseUrl).NotEmpty().WithMessage(messages.BaseUrl);
|
|
RuleFor(x => x.ApiKey).NotEmpty().WithMessage(messages.ApiKey);
|
|
RuleForEach(x => x.CustomFormats).SetValidator(customFormatConfigValidator);
|
|
}
|
|
}
|
|
|
|
[UsedImplicitly]
|
|
internal class CustomFormatConfigValidator : AbstractValidator<CustomFormatConfig>
|
|
{
|
|
public CustomFormatConfigValidator(
|
|
IServiceValidationMessages messages,
|
|
IValidator<QualityProfileScoreConfig> qualityProfileScoreConfigValidator)
|
|
{
|
|
RuleFor(x => x.TrashIds).NotEmpty().WithMessage(messages.CustomFormatTrashIds);
|
|
RuleForEach(x => x.QualityProfiles).SetValidator(qualityProfileScoreConfigValidator);
|
|
}
|
|
}
|
|
|
|
[UsedImplicitly]
|
|
internal class QualityProfileScoreConfigValidator : AbstractValidator<QualityProfileScoreConfig>
|
|
{
|
|
public QualityProfileScoreConfigValidator(IRadarrValidationMessages messages)
|
|
{
|
|
RuleFor(x => x.Name).NotEmpty().WithMessage(messages.QualityProfileName);
|
|
}
|
|
}
|