Fix validator screaming about new columns
This commit is contained in:
+52
-23
@@ -432,10 +432,14 @@ func validateDataObject(path string, obj map[string]any, report *ValidationRepor
|
||||
validateRowsFile(path, obj, report, false)
|
||||
return
|
||||
}
|
||||
if _, hasColumns := obj["columns"]; hasColumns {
|
||||
validateColumnsFile(path, obj, report)
|
||||
return
|
||||
}
|
||||
report.Diagnostics = append(report.Diagnostics, Diagnostic{
|
||||
Severity: SeverityWarning,
|
||||
Path: path,
|
||||
Message: "module file does not use a recognized canonical shape yet; expected one of entries, overrides, or rows",
|
||||
Message: "module file does not use a recognized canonical shape yet; expected one of columns, entries, overrides, or rows",
|
||||
})
|
||||
return
|
||||
}
|
||||
@@ -832,28 +836,8 @@ func validateRowsFile(path string, obj map[string]any, report *ValidationReport,
|
||||
if rowsList, ok := rows.([]any); ok {
|
||||
validateRowCollection(path, obj, rowsList, report)
|
||||
}
|
||||
if columns, ok := obj["columns"]; ok {
|
||||
if list, ok := columns.([]any); !ok {
|
||||
report.Diagnostics = append(report.Diagnostics, Diagnostic{
|
||||
Severity: SeverityError,
|
||||
Path: path,
|
||||
Message: "columns must be a JSON array when present",
|
||||
})
|
||||
} else {
|
||||
for _, raw := range list {
|
||||
column, ok := raw.(string)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
if isAuthoringOnlyField(column) && !preserveLegacyWikiColumnForPath(path, column) {
|
||||
report.Diagnostics = append(report.Diagnostics, Diagnostic{
|
||||
Severity: SeverityError,
|
||||
Path: path,
|
||||
Message: fmt.Sprintf("deprecated wiki column %q must be moved into meta.wiki", column),
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
if _, ok := obj["columns"]; ok {
|
||||
validateColumnsFile(path, obj, report)
|
||||
} else if requireColumns {
|
||||
report.Diagnostics = append(report.Diagnostics, Diagnostic{
|
||||
Severity: SeverityError,
|
||||
@@ -863,6 +847,45 @@ func validateRowsFile(path string, obj map[string]any, report *ValidationReport,
|
||||
}
|
||||
}
|
||||
|
||||
func validateColumnsFile(path string, obj map[string]any, report *ValidationReport) {
|
||||
columns, ok := obj["columns"]
|
||||
if !ok {
|
||||
report.Diagnostics = append(report.Diagnostics, Diagnostic{
|
||||
Severity: SeverityError,
|
||||
Path: path,
|
||||
Message: "columns file must contain a columns array",
|
||||
})
|
||||
return
|
||||
}
|
||||
list, ok := columns.([]any)
|
||||
if !ok {
|
||||
report.Diagnostics = append(report.Diagnostics, Diagnostic{
|
||||
Severity: SeverityError,
|
||||
Path: path,
|
||||
Message: "columns must be a JSON array when present",
|
||||
})
|
||||
return
|
||||
}
|
||||
for _, raw := range list {
|
||||
column, ok := raw.(string)
|
||||
if !ok {
|
||||
report.Diagnostics = append(report.Diagnostics, Diagnostic{
|
||||
Severity: SeverityError,
|
||||
Path: path,
|
||||
Message: "columns must contain only strings",
|
||||
})
|
||||
continue
|
||||
}
|
||||
if isAuthoringOnlyField(column) && !preserveLegacyWikiColumnForPath(path, column) {
|
||||
report.Diagnostics = append(report.Diagnostics, Diagnostic{
|
||||
Severity: SeverityError,
|
||||
Path: path,
|
||||
Message: fmt.Sprintf("deprecated wiki column %q must be moved into meta.wiki", column),
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func validateEntriesFile(path string, obj map[string]any, report *ValidationReport) {
|
||||
entries, ok := obj["entries"]
|
||||
if !ok {
|
||||
@@ -899,6 +922,9 @@ func validateEntriesFile(path string, obj map[string]any, report *ValidationRepo
|
||||
validateInlineTextUsage(path, key, entry, report)
|
||||
}
|
||||
}
|
||||
if _, ok := obj["columns"]; ok {
|
||||
validateColumnsFile(path, obj, report)
|
||||
}
|
||||
}
|
||||
|
||||
func validateOverridesFile(path string, obj map[string]any, report *ValidationReport) {
|
||||
@@ -922,6 +948,9 @@ func validateOverridesFile(path string, obj map[string]any, report *ValidationRe
|
||||
container := map[string]any{"rows": overrideList}
|
||||
validateRowCollection(path, container, overrideList, report)
|
||||
}
|
||||
if _, ok := obj["columns"]; ok {
|
||||
validateColumnsFile(path, obj, report)
|
||||
}
|
||||
}
|
||||
|
||||
func validateStateObject(path string, obj map[string]any, report *ValidationReport) {
|
||||
|
||||
Reference in New Issue
Block a user