From c5176325bf20beee6a99b388c9c45dc95a03896c Mon Sep 17 00:00:00 2001 From: JeremyStarTM Date: Fri, 10 May 2024 15:47:20 +0200 Subject: [PATCH] Update to d62467bd0576361f07f803cffb3e436b5885e1f7 --- src/validation.gd | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/validation.gd b/src/validation.gd index dec2687..eefdc52 100644 --- a/src/validation.gd +++ b/src/validation.gd @@ -23,8 +23,19 @@ var singles: Array[CoreValidationSingle] # +++ module +++ func _cleanup() -> void: + # Schemas + var schemas_remove_enty: Array[CoreValidationSchema] = [] + for schema in schemas: + schemas_remove_enty.append(schema) + if !is_instance_valid(schema): continue + if !is_instance_valid(schema.parent): + logger.diag("Removing schema '" + schema.name + "'") + schema.queue_free() + for schema in schemas_remove_enty: + schemas.remove_at(schemas.find(schema)) + # Singles - var singles_remove_enty: Array[CoreLoggerInstance] = [] + var singles_remove_enty: Array[CoreValidationSingle] = [] for single in singles: singles_remove_enty.append(single) if !is_instance_valid(single): continue @@ -33,17 +44,6 @@ func _cleanup() -> void: single.queue_free() for single in singles_remove_enty: singles.remove_at(singles.find(single)) - - # Schemas - var schemas_remove_enty: Array[CoreLoggerInstance] = [] - for schema in schemas: - singles_remove_enty.append(schema) - if !is_instance_valid(schema): continue - if !is_instance_valid(schema.parent): - logger.diag("Removing schema '" + schema.name + "'") - schema.queue_free() - for schema in schemas_remove_enty: - schemas.remove_at(schemas.find(schema)) func _schedule() -> void: # Singles @@ -61,10 +61,12 @@ func _schedule() -> void: # +++ data validation +++ ## Returns a new [CoreValidationSingle] func get_single(data, parent: Node) -> CoreValidationSingle: - singles.append(parent) - return CoreValidationSingle.new(core, data, parent) + var single: CoreValidationSingle = CoreValidationSingle.new(core, data, parent) + singles.append(single) + return single ## Returns a new [CoreValidationSchema] -func get_schema(schema: Dictionary, parent: Node) -> CoreValidationSchema: - schemas.append(parent) - return CoreValidationSchema.new(core, schema, parent) +func get_schema(schema_dict: Dictionary, parent: Node) -> CoreValidationSchema: + var schema: CoreValidationSchema = CoreValidationSchema.new(core, schema_dict, parent) + schemas.append(schema) + return schema