Reuse document indexes in D&D validators

This commit is contained in:
2026-07-25 12:57:31 +00:00
parent 7a66095912
commit 97cdb01357
9 changed files with 51 additions and 27 deletions

View File

@@ -37,10 +37,11 @@ func (v *Validator) Validate(_ context.Context, req contracts.TypedValidationReq
if err := npcshape.Validate(req.Value); err != nil {
return contracts.ValidationResult{Approved: true}, nil
}
index := source.NewDocumentIndex(req.Source)
issues := make([]string, 0)
for npcIndex, npc := range req.Value.NPCs {
for refIndex, ref := range npc.SourceRefs {
if err := source.ValidateRef(req.Source, ref); err != nil {
if err := index.ValidateRef(ref); err != nil {
issues = append(issues, fmt.Sprintf("npcs[%d].source_refs[%d]: %s", npcIndex, refIndex, diagnostics.Truncate(err.Error())))
}
}