54 lines
804 B
GDScript
54 lines
804 B
GDScript
@tool
|
|
class_name ValidationResult
|
|
extends RefCounted
|
|
|
|
|
|
var errors: Array[String] = []
|
|
var warnings: Array[String] = []
|
|
|
|
|
|
func add_error(message: String) -> void:
|
|
errors.append(message)
|
|
|
|
|
|
func add_warning(message: String) -> void:
|
|
warnings.append(message)
|
|
|
|
|
|
func is_valid() -> bool:
|
|
return errors.is_empty()
|
|
|
|
|
|
func has_warnings() -> bool:
|
|
return not warnings.is_empty()
|
|
|
|
|
|
func get_summary() -> String:
|
|
if not is_valid():
|
|
return "%d error(s), %d warning(s)" % [
|
|
errors.size(),
|
|
warnings.size()
|
|
]
|
|
|
|
if has_warnings():
|
|
return "Valid with %d warning(s)" % warnings.size()
|
|
|
|
return "Valid"
|
|
|
|
func merge(
|
|
other: ValidationResult
|
|
) -> void:
|
|
|
|
if other == null:
|
|
return
|
|
|
|
errors.append_array(
|
|
other.errors
|
|
)
|
|
|
|
warnings.append_array(
|
|
other.warnings
|
|
)
|
|
|
|
var result := ValidationResult.new()
|