Harden diagnostic handling and warning presentation
This commit is contained in:
@@ -49,18 +49,18 @@ func (v *Validator) Validate(_ context.Context, req contracts.TypedValidationReq
|
||||
}
|
||||
citedTexts[npcIndex] = citedText
|
||||
}
|
||||
var warnings []diagnostics.Finding
|
||||
var findings []diagnostics.Finding
|
||||
for npcIndex, npc := range req.Value.NPCs {
|
||||
if npcAppearsInCitedText(citedTexts[npcIndex], npc) {
|
||||
continue
|
||||
}
|
||||
warnings = append(warnings, diagnostics.Finding{
|
||||
findings = append(findings, diagnostics.Finding{
|
||||
Scope: fmt.Sprintf("npcs[%d]", npcIndex),
|
||||
ReasonCode: ReasonCode,
|
||||
Message: fmt.Sprintf("NPC %s was not found in cited source text", diagnostics.Quote(npc.Name)),
|
||||
})
|
||||
}
|
||||
return diagnostics.DataQualityResult(warnings)
|
||||
return diagnostics.DataQualityResult(findings)
|
||||
}
|
||||
|
||||
func npcAppearsInCitedText(citedText string, npc dnd.NPC) bool {
|
||||
|
||||
Reference in New Issue
Block a user