using Core.Entities;
using Core.Validation.Rules.BaseRules;
namespace Core.Validation.Rules.StudentRankingRules;
///
/// Validation rule that checks if a student has too many regional events in their rankings
///
public class TooManyRegionalEventsRule : EventCountThresholdRankingRuleBase
{
protected override int GetCount(Student student) =>
student.RankedEvents.Count(e => e.RegionalEvent);
protected override int GetThreshold(ValidationConfiguration config) => config.MaxRegionalEvents;
protected override bool ViolatesThreshold(int count, int threshold) => count > threshold;
protected override ValidationSeverity GetSeverity(ValidationConfiguration config) =>
config.TooManyRegionalEventsSeverity;
protected override string Code => "TOO_MANY_REGIONAL_EVENTS";
protected override string GetMessage(int count, int threshold) =>
$"Student has {count} regional events (max recommended: {threshold})";
protected override string? IconIdentifier => "RegionalEvent";
protected override Dictionary BuildAdditionalMetadata(Student student, ValidationConfiguration config)
{
return new Dictionary
{
{ "RegionalEventCount", GetCount(student) },
{ "MaxRegionalEvents", config.MaxRegionalEvents }
};
}
}