Add validation warnings to critical imports
This commit is contained in:
@@ -383,6 +383,7 @@ This includes:
|
||||
|
||||
- overall validity
|
||||
- validation errors
|
||||
- validation warnings
|
||||
- row count
|
||||
- cell count
|
||||
|
||||
@@ -490,6 +491,12 @@ If validation fails:
|
||||
- SQLite load is aborted
|
||||
- the command returns an error
|
||||
|
||||
If validation succeeds with warnings:
|
||||
|
||||
- artifacts still record the warnings
|
||||
- SQLite load continues
|
||||
- the CLI prints each warning before reporting the successful load
|
||||
|
||||
This design is deliberate. It is safer to reject ambiguous extraction than to load a nearly-correct but wrong lookup table.
|
||||
|
||||
## Database Load Behavior
|
||||
|
||||
@@ -53,6 +53,11 @@ public sealed class CriticalImportCommandRunner
|
||||
$"Validation failed for '{entry.Slug}'. See {artifactPaths.ValidationReportPath} for details.");
|
||||
}
|
||||
|
||||
foreach (var warning in parseResult.ValidationReport.Warnings)
|
||||
{
|
||||
Console.WriteLine($"Warning: {warning}");
|
||||
}
|
||||
|
||||
var loader = new CriticalImportLoader(ResolveDatabasePath(options.DatabasePath));
|
||||
var result = await loader.LoadAsync(parseResult.Table);
|
||||
|
||||
|
||||
@@ -3,11 +3,13 @@ namespace RolemasterDb.ImportTool.Parsing;
|
||||
public sealed class ImportValidationReport(
|
||||
bool isValid,
|
||||
IReadOnlyList<string> errors,
|
||||
IReadOnlyList<string> warnings,
|
||||
int rowCount,
|
||||
int cellCount)
|
||||
{
|
||||
public bool IsValid { get; } = isValid;
|
||||
public IReadOnlyList<string> Errors { get; } = errors;
|
||||
public IReadOnlyList<string> Warnings { get; } = warnings;
|
||||
public int RowCount { get; } = rowCount;
|
||||
public int CellCount { get; } = cellCount;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ public sealed class StandardCriticalTableParser
|
||||
var fragments = LoadFragments(xmlContent);
|
||||
var headerFragments = FindHeaderFragments(fragments);
|
||||
var validationErrors = new List<string>();
|
||||
var validationWarnings = new List<string>();
|
||||
|
||||
var columnCenters = headerFragments
|
||||
.OrderBy(item => item.Left)
|
||||
@@ -147,6 +148,7 @@ public sealed class StandardCriticalTableParser
|
||||
var validationReport = new ImportValidationReport(
|
||||
validationErrors.Count == 0,
|
||||
validationErrors,
|
||||
validationWarnings,
|
||||
rowAnchors.Count,
|
||||
parsedCells.Count);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user