using Core.Entities; namespace Core.Validation.Rules.TeamRules; /// /// Validation rule that checks if a team-based event has an assigned captain /// public class MissingCaptainRule : IValidationRule { public ValidationWarning? Validate(Team entity, ValidationConfiguration config) { if (!config.RequireTeamCaptain) return null; // Individual events don't need captains if (entity.Event.EventFormat == EventFormat.Individual) return null; if (entity.Captain != null) return null; return new ValidationWarning { Code = "MISSING_CAPTAIN", Message = "Team has no captain assigned", Severity = config.MissingCaptainSeverity, Context = ValidationContext.Team, IconIdentifier = "Captain", Metadata = new Dictionary { { "TeamId", entity.Id }, { "EventName", entity.Event.Name }, { "TeamSize", entity.Students.Count } } }; } public bool AppliesTo(ValidationContext context) => context == ValidationContext.Team; }