1c7e704ad3
Implements a flexible validation framework for student rankings, team assignments, and team composition with administrator-configurable rules and thresholds. Validation System: - Reflection-based rule discovery eliminates manual registration - Base classes (RequiredEventTypeRuleBase, EventCountThresholdRuleBase) reduce code duplication by ~250 lines - 12 validation rules covering event requirements, counts, and team constraints - Configurable severity levels (Warning/Error) per rule type - ValidationService with caching for optimal performance - Rules apply contextually (StudentRanking, StudentAssignment, TeamComposition) Configuration & Admin UI: - ValidationSettings admin page for editing thresholds and severity levels - ChapterSettings admin page for editing chapter information - Settings stored in Data/appsettings.json for runtime configuration - JSON config works in both development and production environments - Auto-creates Data directory and config template on first run User Experience: - ValidationWarnings component displays inline warnings/errors - Integrated in Event Ranking, Registration, and Team Assignment pages - Color-coded severity indicators (warning yellow, error red) - Includes "Too Many Regional Events" rule (max 3 recommended) Technical Improvements: - Template Method pattern for rule base classes - Singleton rule instances with lazy initialization - Configuration loaded via IConfiguration with fallback to defaults - Safe JSON updates preserve other appsettings sections
38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
namespace Core.Validation;
|
|
|
|
/// <summary>
|
|
/// Represents a validation warning or error for a student, team, or assignment
|
|
/// </summary>
|
|
public class ValidationWarning
|
|
{
|
|
/// <summary>
|
|
/// Human-readable warning message
|
|
/// </summary>
|
|
public required string Message { get; init; }
|
|
|
|
/// <summary>
|
|
/// Unique code identifying the validation rule (e.g., "NO_REGIONAL_EVENT")
|
|
/// </summary>
|
|
public required string Code { get; init; }
|
|
|
|
/// <summary>
|
|
/// Severity level of the warning
|
|
/// </summary>
|
|
public required ValidationSeverity Severity { get; init; }
|
|
|
|
/// <summary>
|
|
/// Context in which this warning applies
|
|
/// </summary>
|
|
public required ValidationContext Context { get; init; }
|
|
|
|
/// <summary>
|
|
/// Icon identifier for UI display (maps to AppIcons constants in WebApp)
|
|
/// </summary>
|
|
public string? IconIdentifier { get; init; }
|
|
|
|
/// <summary>
|
|
/// Additional contextual information about the warning
|
|
/// </summary>
|
|
public Dictionary<string, object> Metadata { get; init; } = new();
|
|
}
|