feat(meta-validate): Check 10 — warn on empty registers and broken RegisterRecords refs

Add two new validations found via platform snapshot verification:
- Registers without any Dimensions/Resources/Attributes → platform rejects
- Document.RegisterRecords referencing non-existent register objects

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Nick Shirokov
2026-04-05 20:27:18 +03:00
co-authored by Claude Opus 4.6
parent 3ba6072660
commit 358830c65b
2 changed files with 102 additions and 2 deletions
@@ -1,4 +1,4 @@
# meta-validate v1.2 — Validate 1C metadata object structure
# meta-validate v1.3 — Validate 1C metadata object structure
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
param(
[Parameter(Mandatory)]
@@ -998,6 +998,18 @@ if ($propsNode) {
}
}
# CalculationRegister: ActionPeriod=true requires non-empty Schedule
if ($mdType -eq "CalculationRegister") {
$actionPeriod = $propsNode.SelectSingleNode("md:ActionPeriod", $ns)
if ($actionPeriod -and $actionPeriod.InnerText -eq "true") {
$schedule = $propsNode.SelectSingleNode("md:Schedule", $ns)
if (-not $schedule -or -not $schedule.InnerText.Trim()) {
Report-Warn "10. CalculationRegister: ActionPeriod=true but Schedule is empty — platform requires a schedule register"
$check10Issues++
}
}
}
# DocumentJournal: RegisteredDocuments should not be empty
if ($mdType -eq "DocumentJournal") {
$regDocs = $propsNode.SelectSingleNode("md:RegisteredDocuments", $ns)
@@ -1025,6 +1037,48 @@ if ($propsNode) {
}
}
# Register: must have at least one Dimension or Resource (platform rejects empty registers)
$regTypesAll = @("AccumulationRegister","AccountingRegister","CalculationRegister","InformationRegister")
if ($regTypesAll -contains $mdType -and $childObjNode) {
$dims = $childObjNode.SelectNodes("md:Dimension", $ns).Count
$ress = $childObjNode.SelectNodes("md:Resource", $ns).Count
$attrs = $childObjNode.SelectNodes("md:Attribute", $ns).Count
if (($dims + $ress + $attrs) -eq 0) {
Report-Warn "10. $mdType`: no Dimensions, Resources, or Attributes — platform will reject"
$check10Issues++
}
}
# Document: RegisterRecords references should point to existing objects in config
if ($mdType -eq "Document" -and $script:configDir) {
$regRecords = $propsNode.SelectSingleNode("md:RegisterRecords", $ns)
if ($regRecords) {
$items = $regRecords.SelectNodes("xr:Item", $ns)
foreach ($item in $items) {
$refVal = $item.InnerText.Trim()
if (-not $refVal) { continue }
# Parse "AccumulationRegister.Name" → dir AccumulationRegisters/Name
$parts = $refVal -split '\.',2
if ($parts.Count -eq 2) {
$refType = $parts[0]; $refName = $parts[1]
$dirMap = @{
"AccumulationRegister"="AccumulationRegisters"; "InformationRegister"="InformationRegisters"
"AccountingRegister"="AccountingRegisters"; "CalculationRegister"="CalculationRegisters"
}
$refDir = $dirMap[$refType]
if ($refDir) {
$refPath = Join-Path $script:configDir "$refDir/$refName"
$refXml = Join-Path $script:configDir "$refDir/$refName.xml"
if (-not (Test-Path $refPath) -and -not (Test-Path $refXml)) {
Report-Warn "10. Document.RegisterRecords references '$refVal' but object not found in config"
$check10Issues++
}
}
}
}
}
}
# Register: must have at least one registrar document
$registerTypes = @("AccumulationRegister","AccountingRegister","CalculationRegister","InformationRegister")
if ($registerTypes -contains $mdType -and $script:configDir -and $objName -ne "(unknown)") {