fix(form-validate): skip DataPath check for base elements in borrowed forms

In extension forms with BaseForm, elements with id < 1000000 belong to the
base configuration and their attributes are not present in the extension.
Skip DataPath→Attribute validation for these elements to avoid false errors.
Show "N base skipped" in output for transparency.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Nick Shirokov
2026-02-21 17:34:36 +03:00
parent 6f32e18e37
commit 5f7ee6fcae
@@ -76,6 +76,9 @@ if ($parentDir) {
Write-Host "=== Validation: $formName ==="
Write-Host ""
# Early BaseForm detection (used in Check 5 to skip base element DataPath validation)
$hasBaseForm = ($root.SelectSingleNode("f:BaseForm", $nsMgr) -ne $null)
# --- Check 1: Root element and version ---
if ($root.LocalName -ne "Form") {
@@ -297,6 +300,7 @@ if (-not $stopped) {
if (-not $stopped) {
$pathErrors = 0
$pathChecked = 0
$pathBaseSkipped = 0
foreach ($el in $allElements) {
if ($stopped) { break }
@@ -309,6 +313,11 @@ if (-not $stopped) {
continue
}
# In borrowed forms, skip DataPath check for base elements (id < 1000000)
if ($hasBaseForm -and $el.Id) {
try { if ([int]$el.Id -lt 1000000) { $pathBaseSkipped++; continue } } catch {}
}
$dpNode = $node.SelectSingleNode("f:DataPath", $nsMgr)
if (-not $dpNode) { continue }
@@ -328,9 +337,15 @@ if (-not $stopped) {
}
}
if ($pathErrors -eq 0 -and $pathChecked -gt 0) {
Report-OK "DataPath references: $pathChecked paths checked"
} elseif ($pathChecked -eq 0) {
$pathMsg = ""
if ($pathChecked -gt 0) { $pathMsg = "$pathChecked paths checked" }
if ($pathBaseSkipped -gt 0) {
$skipNote = "$pathBaseSkipped base skipped"
$pathMsg = if ($pathMsg) { "$pathMsg, $skipNote" } else { $skipNote }
}
if ($pathErrors -eq 0 -and $pathMsg) {
Report-OK "DataPath references: $pathMsg"
} elseif ($pathErrors -eq 0) {
Report-OK "DataPath references: none"
}
}