|
|
|
@ -17,6 +17,8 @@ namespace Radarr.Api.V3.Profiles.Quality
|
|
|
|
|
ruleBuilder.SetValidator(new ItemGroupIdValidator<T>());
|
|
|
|
|
ruleBuilder.SetValidator(new UniqueIdValidator<T>());
|
|
|
|
|
ruleBuilder.SetValidator(new UniqueQualityIdValidator<T>());
|
|
|
|
|
ruleBuilder.SetValidator(new AllQualitiesValidator<T>());
|
|
|
|
|
|
|
|
|
|
return ruleBuilder.SetValidator(new ItemGroupNameValidator<T>());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -151,4 +153,46 @@ namespace Radarr.Api.V3.Profiles.Quality
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class AllQualitiesValidator<T> : PropertyValidator
|
|
|
|
|
{
|
|
|
|
|
protected override string GetDefaultMessageTemplate() => "Must contain all qualities";
|
|
|
|
|
|
|
|
|
|
protected override bool IsValid(PropertyValidatorContext context)
|
|
|
|
|
{
|
|
|
|
|
if (context.PropertyValue is not IList<QualityProfileQualityItemResource> items)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var qualityIds = new HashSet<int>();
|
|
|
|
|
|
|
|
|
|
foreach (var item in items)
|
|
|
|
|
{
|
|
|
|
|
if (item.Id > 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (var quality in item.Items)
|
|
|
|
|
{
|
|
|
|
|
qualityIds.Add(quality.Quality.Id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
qualityIds.Add(item.Quality.Id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var allQualityIds = NzbDrone.Core.Qualities.Quality.All;
|
|
|
|
|
|
|
|
|
|
foreach (var quality in allQualityIds)
|
|
|
|
|
{
|
|
|
|
|
if (!qualityIds.Contains(quality.Id))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|