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

@@ -42,9 +42,10 @@ func (v *Validator) Validate(_ context.Context, req contracts.TypedValidationReq
if req.Stage == string(pipeline.StageExtract) && req.Chunk == nil {
issues = append(issues, "current extraction chunk must not be nil")
}
for index, scene := range req.Value.Scenes {
prefix := fmt.Sprintf("scenes[%d]", index)
if err := source.ValidateRef(req.Source, scene.SourceRef); err != nil {
index := source.NewDocumentIndex(req.Source)
for sceneIndex, scene := range req.Value.Scenes {
prefix := fmt.Sprintf("scenes[%d]", sceneIndex)
if err := index.ValidateRef(scene.SourceRef); err != nil {
issues = append(issues, prefix+".source_ref: "+diagnostics.Truncate(err.Error()))
continue
}