Repository navigation
fix: validate the whole path of a loop item, not only its first segment (#299) - #301
Merged
Merged
Conversation
…nt (#299) ValidateTemplate(stream, data) checked a loop item's path ({{line.product.name}}, {{product.name}} inside an unnamed loop) only by its first segment, so a removed nested field passed validation; a condition variable such a path names was not reported at all. Now the whole path is resolved against the loop's items, for values and condition variables, in DOCX and ODT: it counts as present when any item has it (a null on the way counts too); otherwise the outer scopes and the data are tried, as processing does. Behaviour change of ValidateTemplate with data (release notes): templates that read a nested item path no item has now report it (MissingVariable error for a value, MissingConditionVariable warning for a condition). Processing is unchanged; no public API change.
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
ValidateTemplate(stream, data)checked a loop item's path only by its first segment. With items that haveproduct.name, both{{line.product.removed}}and{{#if line.product.removed}}inside{{#foreach line in lines}}passed validation; the condition variable was reported by neither validation nor processing.Validation now resolves the whole path against the loop's items, for values and condition variables, in DOCX and ODT. A path counts as present when any item has it, and a
nullon the way also counts as present, as in processing. When no item has it, the outer scopes and the data are tried, which is the fallback processing uses.Type of Change
Public API impact: none. Behaviour change of
ValidateTemplatewith data (to mention in the release notes): a template that reads a nested item path no item has now reports it. A value is reported as aMissingVariableerror and listed inMissingVariables; a condition variable is reported as aMissingConditionVariablewarning. Processing is unchanged.Related Issues
Fixes #299
Relates to #261 (the builder's check of stored templates, #294, documented this as a known limit)
Changes Made
ScopedVariableValidator.CanResolveInScope(DOCX) andOdtTemplateValidator.CanResolveInScope(ODT) share the newResolvesOnAnItem. A one-segment path stays as before; a longer path must resolve on an item.Core/LoopItemPathValidationTestscovers both formats:nullon the way;OdtValidationParityTestshas a new case for nested item paths, so both formats give the same result.quick-start.mddescribes how loop item paths are validated.Testing
Test Environment
Tests Added/Updated
OpenDocument/)Documentation
docs/for-developers/quick-start.md)Performance Impact
Breaking Changes
None in the API. The behaviour change is described above and is intended: validation now reports what processing would not find.