Add comprehensive validation system with runtime configuration

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
This commit is contained in:
2025-12-13 22:15:16 -05:00
parent 215b9dccca
commit 1c7e704ad3
36 changed files with 1839 additions and 83 deletions
+3 -3
View File
@@ -17,9 +17,9 @@ namespace WebApp.Models
return loe switch
{
1 => "",
2 => "",
3 => "",
1 => "1",
2 => "2",
3 => "3",
_ => Icons.Material.Filled.QuestionMark
};
}
+37
View File
@@ -0,0 +1,37 @@
namespace WebApp.Models;
/// <summary>
/// Configuration for chapter-specific information
/// </summary>
public class ChapterSettings
{
/// <summary>
/// Full chapter name (e.g., "Your Chapter Name")
/// </summary>
public string Name { get; set; } = "Your Chapter Name";
/// <summary>
/// Short chapter name abbreviation (e.g., "YCN")
/// </summary>
public string ShortName { get; set; } = "YCN";
/// <summary>
/// National chapter ID (4 digits, e.g., "0000")
/// </summary>
public string NationalId { get; set; } = "0000";
/// <summary>
/// State chapter ID (5 digits, e.g., "00000")
/// </summary>
public string StateId { get; set; } = "00000";
/// <summary>
/// Regional chapter ID (5 digits, e.g., "00000")
/// </summary>
public string RegionalId { get; set; } = "00000";
/// <summary>
/// Competition year (e.g., "2026")
/// </summary>
public string CompetitionYear { get; set; } = "2026";
}