diff --git a/docs/for-developers/quick-start.md b/docs/for-developers/quick-start.md
index 77fa653..1a132d6 100644
--- a/docs/for-developers/quick-start.md
+++ b/docs/for-developers/quick-start.md
@@ -241,7 +241,9 @@ Console.WriteLine(string.Join(", ", validation.MissingVariables));
Each missing variable or loop collection is reported as an error of type `MissingVariable` (so `IsValid` is
`false` for that data) and listed in `MissingVariables`; call `ValidateTemplate(template)` without data to check
-the syntax only. `validation.Warnings` reports loops over empty collections (`EmptyLoopCollection`, controlled by
+the syntax only. Inside a loop, the whole path of an item (`{{line.product.name}}`) is checked against the loop's
+items: it counts as present when at least one item has it (a `null` on the way counts too), otherwise the outer
+scopes and the data are tried, as processing does. `validation.Warnings` reports loops over empty collections (`EmptyLoopCollection`, controlled by
`WarnOnEmptyLoopCollections`), condition keywords used as variable names (`ReservedWordAsVariable`) and conditions
that test a variable missing from the data on its own (`MissingConditionVariable`, see below). Warnings never make
`IsValid` false.
diff --git a/src/TriasDev.Templify/Core/ScopedVariableValidator.cs b/src/TriasDev.Templify/Core/ScopedVariableValidator.cs
index 3cd2dd3..966414e 100644
--- a/src/TriasDev.Templify/Core/ScopedVariableValidator.cs
+++ b/src/TriasDev.Templify/Core/ScopedVariableValidator.cs
@@ -397,10 +397,9 @@ private bool CanResolveInScope(string placeholder)
}
// Property access via the named iteration variable (e.g., {{item.Name}}) or implicit
- // property access (e.g., {{Name}}, {{Address.City}}).
- // Note: During static validation, only the root property is verified against the loop items;
- // runtime processing reports invalid nested paths.
- if (GetPathRelativeToScope(placeholder, scope) != null)
+ // property access (e.g., {{Name}}, {{Address.City}}): the whole path must resolve on an item
+ // (#299). Otherwise processing falls back to the outer scopes, and so does validation.
+ if (GetPathRelativeToScope(placeholder, scope) is { } relativePath && ResolvesOnAnItem(relativePath, scope.Items))
{
return true;
}
@@ -410,6 +409,21 @@ private bool CanResolveInScope(string placeholder)
return _resolver.TryResolveValue(_data, placeholder, out _);
}
+ ///
+ /// Whether a path relative to the loop items resolves on at least one item. A null on the way counts as present
+ /// (the item has the property, its value is empty), as in processing.
+ ///
+ internal static bool ResolvesOnAnItem(string relativePath, IReadOnlyList