GFConfigValidationReport¶
API Reference / Standard / 类索引
- 路径:
addons/gf/standard/utilities/config/gf_config_validation_report.gd - 模块:
Standard - 继承:
RefCounted - API:
public - 类别:值对象 (
value_object) - 首次版本:
3.17.0
配置表校验报告构建工具。 统一创建、合并和补全配置表校验报告,保证 schema、导入器、引用解析和补丁合并使用相同问题结构。
成员概览¶
| 类型 | 名称 | 签名 |
|---|---|---|
| 常量 | CONTEXT_FIELDS |
const CONTEXT_FIELDS: Array[String] = [ |
| 方法 | make_report |
func make_report(table_name: StringName = &"", row_count: int = 0) -> Dictionary: |
| 方法 | make_error_report |
func make_error_report( table_name: StringName, kind: String, message: String, context: Dictionary = {} ) -> Dictionary: |
| 方法 | add_issue |
func add_issue( report: Dictionary, severity: String, kind: String, table_name: StringName, row_key: Variant, field_name: StringName, message: String, context: Dictionary = {} ) -> void: |
| 方法 | merge_report |
func merge_report(target: Dictionary, source: Dictionary, include_row_count: bool = false) -> void: |
| 方法 | finalize_report |
func finalize_report(report: Dictionary) -> void: |
常量¶
CONTEXT_FIELDS¶
- API:
public
从校验上下文复制到单条 issue 的字段名。
方法¶
make_report¶
- API:
public
创建空校验报告。
参数:
| 名称 | 说明 |
|---|---|
table_name |
表名。 |
row_count |
记录数量。 |
返回:校验报告字典。
结构:
return: GFConfigValidationReport 兼容 Dictionary,包含 ok、table_name、row_count、error_count、warning_count 和 issues。
make_error_report¶
- API:
public
func make_error_report( table_name: StringName, kind: String, message: String, context: Dictionary = {} ) -> Dictionary:
创建单错误校验报告。
参数:
| 名称 | 说明 |
|---|---|
table_name |
表名。 |
kind |
稳定问题类型。 |
message |
问题描述。 |
context |
可选上下文。 |
返回:校验报告字典。
结构:
context: Dictionary,可包含 row_key、field、source、line、column、row_index、column_index 和 rule_id 字段。return: GFConfigValidationReport 兼容 Dictionary,包含一条 error issue。
add_issue¶
- API:
public
func add_issue( report: Dictionary, severity: String, kind: String, table_name: StringName, row_key: Variant, field_name: StringName, message: String, context: Dictionary = {} ) -> void:
向报告写入一条问题。
参数:
| 名称 | 说明 |
|---|---|
report |
目标校验报告。 |
severity |
severity 字符串,支持 error 或 warning。 |
kind |
稳定问题类型。 |
table_name |
表名。 |
row_key |
行标识。 |
field_name |
字段名。 |
message |
问题描述。 |
context |
可选上下文。 |
结构:
report: GFConfigValidationReport 兼容 Dictionary,会被当前方法修改。row_key: Variant,复制到 issue 中的行标识。context: Dictionary,可包含 source、line、column、row_index、column_index 和 rule_id 字段。
merge_report¶
- API:
public
合并一份校验报告。
参数:
| 名称 | 说明 |
|---|---|
target |
目标报告。 |
source |
来源报告。 |
include_row_count |
为 true 时累加 row_count。 |
结构:
target: GFConfigValidationReport 兼容 Dictionary,会被当前方法修改。source: GFConfigValidationReport 兼容 Dictionary,会复制合并到 target。
finalize_report¶
- API:
public
根据 error_count 补全 ok 字段。
参数:
| 名称 | 说明 |
|---|---|
report |
校验报告。 |
结构:
report: GFConfigValidationReport 兼容 Dictionary,会被当前方法修改。