Update plugins

This commit is contained in:
Adrien Ufferte
2026-03-09 09:17:36 +01:00
parent b517ab9897
commit b4f9fbe904
62 changed files with 237 additions and 236 deletions
@@ -18,10 +18,10 @@ func _ready() -> void:
func _configure_validator() -> void: func _configure_validator() -> void:
if validator != null: if validator != null:
return return
var parent: Node = get_parent() var parent = get_parent()
if not parent: if not parent:
return return
var found: Validator = Validation.find_validator(parent) var found = Validation.find_validator(parent)
if found: if found:
validator = found.duplicate(true) validator = found.duplicate(true)
else: else:
@@ -31,8 +31,8 @@ func _configure_validator() -> void:
func _get_configuration_warnings() -> PackedStringArray: func _get_configuration_warnings() -> PackedStringArray:
if not validator: if not validator:
return [] return []
var list: PackedStringArray = PackedStringArray() var list = PackedStringArray()
for rule: ValidatorRule in validator.rules: for rule in validator.rules:
if not rule.is_valid(): if not rule.is_valid():
list.append(rule.get_invalid_message()) list.append(rule.get_invalid_message())
return list return list
@@ -48,7 +48,7 @@ func _on_tree_exiting() -> void:
func _on_validator_added() -> void: func _on_validator_added() -> void:
var parent: Node = get_parent() var parent = get_parent()
if not parent or not validator: if not parent or not validator:
return return
Validation.validator_added.emit(parent, validator) Validation.validator_added.emit(parent, validator)
@@ -1 +1 @@
uid://dg4qit8mffvjh uid://ctfu2lhk6xaad
@@ -18,8 +18,6 @@ dest_files=["res://.godot/imported/editor_icon.png-6f130a2788dfaa185bebbdd85ed98
compress/mode=0 compress/mode=0
compress/high_quality=false compress/high_quality=false
compress/lossy_quality=0.7 compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1 compress/hdr_compression=1
compress/normal_map=0 compress/normal_map=0
compress/channel_pack=0 compress/channel_pack=0
@@ -27,10 +25,6 @@ mipmaps/generate=false
mipmaps/limit=-1 mipmaps/limit=-1
roughness/mode=0 roughness/mode=0
roughness/src_normal="" roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true process/fix_alpha_border=true
process/premult_alpha=false process/premult_alpha=false
process/normal_map_invert_y=false process/normal_map_invert_y=false
@@ -2,10 +2,9 @@ extends PanelContainer
@onready var form_validator_control: FormValidator = $MarginContainer/FormValidator @onready var form_validator_control: FormValidator = $MarginContainer/FormValidator
func _on_form_validator_control_control_validated(control, passed, messages) -> void:
func _on_form_validator_control_control_validated(control: Control, passed: bool, messages: PackedStringArray) -> void: var error_label = _get_error_label(control)
var error_label: Label = _get_error_label(control) var valid_label = _get_valid_label(control)
var valid_label: Label = _get_valid_label(control)
if passed: if passed:
if error_label: if error_label:
error_label.hide() error_label.hide()
@@ -1 +1 @@
uid://w3bvkvn7umfw uid://cfoxaclxhvx28
@@ -1,21 +1,20 @@
[gd_scene format=3 uid="uid://dpi5vv8r80o7r"] [gd_scene load_steps=41 format=3 uid="uid://dpi5vv8r80o7r"]
[ext_resource type="Script" uid="uid://w3bvkvn7umfw" path="res://addons/godot-form-validator/example/example.gd" id="1_8caq6"] [ext_resource type="Script" path="res://addons/godot-form-validator/example/example.gd" id="1_8caq6"]
[ext_resource type="Script" uid="uid://ddmyah1o42hwp" path="res://addons/godot-form-validator/form_validator.gd" id="2_mtxo0"] [ext_resource type="Script" path="res://addons/godot-form-validator/form_validator.gd" id="2_mtxo0"]
[ext_resource type="Script" uid="uid://dg4qit8mffvjh" path="res://addons/godot-form-validator/control_validator.gd" id="3_hkwup"] [ext_resource type="Script" path="res://addons/godot-form-validator/control_validator.gd" id="3_hkwup"]
[ext_resource type="Script" uid="uid://dg17cfvs2w257" path="res://addons/godot-form-validator/rules/validator_rule.gd" id="4_d7ctn"] [ext_resource type="Script" path="res://addons/godot-form-validator/rules/alpha_rule.gd" id="4_dq1df"]
[ext_resource type="Script" uid="uid://wgfr07ktmqap" path="res://addons/godot-form-validator/rules/alpha_rule.gd" id="4_dq1df"] [ext_resource type="Script" path="res://addons/godot-form-validator/rules/required_rule.gd" id="5_cu56g"]
[ext_resource type="Script" uid="uid://dw5aercmfe4" path="res://addons/godot-form-validator/rules/required_rule.gd" id="5_cu56g"] [ext_resource type="Script" path="res://addons/godot-form-validator/validators/line_edit_validator.gd" id="5_rknpr"]
[ext_resource type="Script" uid="uid://c1cqwb15yoqb3" path="res://addons/godot-form-validator/validators/line_edit_validator.gd" id="5_rknpr"] [ext_resource type="Script" path="res://addons/godot-form-validator/rules/numeric_rule.gd" id="7_6vtuw"]
[ext_resource type="Script" uid="uid://dgk131fex3ts2" path="res://addons/godot-form-validator/rules/numeric_rule.gd" id="7_6vtuw"] [ext_resource type="Script" path="res://addons/godot-form-validator/rules/alphanumeric_rule.gd" id="8_mu0ia"]
[ext_resource type="Script" uid="uid://bueqq0cpyjwtg" path="res://addons/godot-form-validator/rules/alphanumeric_rule.gd" id="8_mu0ia"] [ext_resource type="Script" path="res://addons/godot-form-validator/rules/email_rule.gd" id="9_4ynyw"]
[ext_resource type="Script" uid="uid://dvpln5snrt4mq" path="res://addons/godot-form-validator/rules/email_rule.gd" id="9_4ynyw"] [ext_resource type="Script" path="res://addons/godot-form-validator/rules/length_rule.gd" id="10_iuueu"]
[ext_resource type="Script" uid="uid://bj4s5o33vkcts" path="res://addons/godot-form-validator/rules/length_rule.gd" id="10_iuueu"] [ext_resource type="Script" path="res://addons/godot-form-validator/rules/greater_than_rule.gd" id="11_1tya3"]
[ext_resource type="Script" uid="uid://snmw7k006wch" path="res://addons/godot-form-validator/rules/greater_than_rule.gd" id="11_1tya3"] [ext_resource type="Script" path="res://addons/godot-form-validator/validators/range_validator.gd" id="11_51cp7"]
[ext_resource type="Script" uid="uid://kleihw30fvoh" path="res://addons/godot-form-validator/validators/range_validator.gd" id="11_51cp7"] [ext_resource type="Script" path="res://addons/godot-form-validator/validators/button_validator.gd" id="13_eri47"]
[ext_resource type="Script" uid="uid://couf48gpjy4yt" path="res://addons/godot-form-validator/validators/button_validator.gd" id="13_eri47"] [ext_resource type="Script" path="res://addons/godot-form-validator/rules/custom_rule.gd" id="13_ibg52"]
[ext_resource type="Script" uid="uid://c7tybiqm6xgvi" path="res://addons/godot-form-validator/rules/custom_rule.gd" id="13_ibg52"] [ext_resource type="Script" path="res://addons/godot-form-validator/rules/boolean_rule.gd" id="15_xjpko"]
[ext_resource type="Script" uid="uid://dsrxfoqxxycoi" path="res://addons/godot-form-validator/rules/boolean_rule.gd" id="15_xjpko"]
[sub_resource type="LabelSettings" id="LabelSettings_nw8ds"] [sub_resource type="LabelSettings" id="LabelSettings_nw8ds"]
font_size = 24 font_size = 24
@@ -30,8 +29,10 @@ fail_message = "Value must contain only alpha characters."
[sub_resource type="Resource" id="Resource_15man"] [sub_resource type="Resource" id="Resource_15man"]
script = ExtResource("5_rknpr") script = ExtResource("5_rknpr")
validation_order = 1
validation_method = 0 validation_method = 0
rules = Array[ExtResource("4_d7ctn")]([SubResource("Resource_i25hd"), SubResource("Resource_4mimn")]) skip_validation = false
rules = Array[Resource("res://addons/godot-form-validator/rules/validator_rule.gd")]([SubResource("Resource_i25hd"), SubResource("Resource_4mimn")])
[sub_resource type="LabelSettings" id="LabelSettings_su7t3"] [sub_resource type="LabelSettings" id="LabelSettings_su7t3"]
font_color = Color(1, 0.568627, 0.580392, 1) font_color = Color(1, 0.568627, 0.580392, 1)
@@ -49,12 +50,14 @@ fail_message = "Value must contain only numbers."
[sub_resource type="Resource" id="Resource_1t3q0"] [sub_resource type="Resource" id="Resource_1t3q0"]
script = ExtResource("5_rknpr") script = ExtResource("5_rknpr")
validation_order = 1
validation_method = 0 validation_method = 0
rules = Array[ExtResource("4_d7ctn")]([SubResource("Resource_j4pud"), SubResource("Resource_xxhfq")]) skip_validation = false
rules = Array[Resource("res://addons/godot-form-validator/rules/validator_rule.gd")]([SubResource("Resource_j4pud"), SubResource("Resource_xxhfq")])
[sub_resource type="Resource" id="Resource_ftvbf"] [sub_resource type="Resource" id="Resource_ftvbf"]
script = ExtResource("8_mu0ia") script = ExtResource("8_mu0ia")
fail_message = "Value must contain only alphanumeric characters." fail_message = "Value must contain only alphanumeric cahracters."
[sub_resource type="Resource" id="Resource_my5ss"] [sub_resource type="Resource" id="Resource_my5ss"]
script = ExtResource("5_cu56g") script = ExtResource("5_cu56g")
@@ -62,8 +65,10 @@ fail_message = "A value is required."
[sub_resource type="Resource" id="Resource_61y5a"] [sub_resource type="Resource" id="Resource_61y5a"]
script = ExtResource("5_rknpr") script = ExtResource("5_rknpr")
validation_order = 1
validation_method = 0 validation_method = 0
rules = Array[ExtResource("4_d7ctn")]([SubResource("Resource_ftvbf"), SubResource("Resource_my5ss")]) skip_validation = false
rules = Array[Resource("res://addons/godot-form-validator/rules/validator_rule.gd")]([SubResource("Resource_ftvbf"), SubResource("Resource_my5ss")])
[sub_resource type="Resource" id="Resource_f3i8j"] [sub_resource type="Resource" id="Resource_f3i8j"]
script = ExtResource("9_4ynyw") script = ExtResource("9_4ynyw")
@@ -75,8 +80,10 @@ fail_message = "A value is required."
[sub_resource type="Resource" id="Resource_q4oax"] [sub_resource type="Resource" id="Resource_q4oax"]
script = ExtResource("5_rknpr") script = ExtResource("5_rknpr")
validation_order = 1
validation_method = 0 validation_method = 0
rules = Array[ExtResource("4_d7ctn")]([SubResource("Resource_f3i8j"), SubResource("Resource_l5e3w")]) skip_validation = false
rules = Array[Resource("res://addons/godot-form-validator/rules/validator_rule.gd")]([SubResource("Resource_f3i8j"), SubResource("Resource_l5e3w")])
[sub_resource type="Resource" id="Resource_d1g5r"] [sub_resource type="Resource" id="Resource_d1g5r"]
script = ExtResource("5_cu56g") script = ExtResource("5_cu56g")
@@ -86,11 +93,14 @@ fail_message = "A value is required."
script = ExtResource("10_iuueu") script = ExtResource("10_iuueu")
min_length = 5 min_length = 5
max_length = 10 max_length = 10
fail_message = ""
[sub_resource type="Resource" id="Resource_62odm"] [sub_resource type="Resource" id="Resource_62odm"]
script = ExtResource("5_rknpr") script = ExtResource("5_rknpr")
validation_order = 1
validation_method = 0 validation_method = 0
rules = Array[ExtResource("4_d7ctn")]([SubResource("Resource_d1g5r"), SubResource("Resource_jqdfw")]) skip_validation = false
rules = Array[Resource("res://addons/godot-form-validator/rules/validator_rule.gd")]([SubResource("Resource_d1g5r"), SubResource("Resource_jqdfw")])
[sub_resource type="Resource" id="Resource_qm2iv"] [sub_resource type="Resource" id="Resource_qm2iv"]
script = ExtResource("5_cu56g") script = ExtResource("5_cu56g")
@@ -99,11 +109,14 @@ fail_message = "A value is required."
[sub_resource type="Resource" id="Resource_brbah"] [sub_resource type="Resource" id="Resource_brbah"]
script = ExtResource("11_1tya3") script = ExtResource("11_1tya3")
target_value = "3" target_value = "3"
fail_message = ""
[sub_resource type="Resource" id="Resource_smogv"] [sub_resource type="Resource" id="Resource_smogv"]
script = ExtResource("11_51cp7") script = ExtResource("11_51cp7")
validation_order = 1
validation_method = 0 validation_method = 0
rules = Array[ExtResource("4_d7ctn")]([SubResource("Resource_qm2iv"), SubResource("Resource_brbah")]) skip_validation = false
rules = Array[Resource("res://addons/godot-form-validator/rules/validator_rule.gd")]([SubResource("Resource_qm2iv"), SubResource("Resource_brbah")])
[sub_resource type="Resource" id="Resource_4riv3"] [sub_resource type="Resource" id="Resource_4riv3"]
script = ExtResource("13_ibg52") script = ExtResource("13_ibg52")
@@ -112,8 +125,10 @@ fail_message = "The red channel must be greater than 0.5."
[sub_resource type="Resource" id="Resource_mh7td"] [sub_resource type="Resource" id="Resource_mh7td"]
script = ExtResource("13_eri47") script = ExtResource("13_eri47")
validation_order = 1
validation_method = 0 validation_method = 0
rules = Array[ExtResource("4_d7ctn")]([SubResource("Resource_4riv3")]) skip_validation = false
rules = Array[Resource("res://addons/godot-form-validator/rules/validator_rule.gd")]([SubResource("Resource_4riv3")])
[sub_resource type="Resource" id="Resource_3nuq2"] [sub_resource type="Resource" id="Resource_3nuq2"]
script = ExtResource("15_xjpko") script = ExtResource("15_xjpko")
@@ -124,9 +139,10 @@ fail_message = "The check box must be checked."
script = ExtResource("13_eri47") script = ExtResource("13_eri47")
validation_order = -1 validation_order = -1
validation_method = 0 validation_method = 0
rules = Array[ExtResource("4_d7ctn")]([SubResource("Resource_3nuq2")]) skip_validation = false
rules = Array[Resource("res://addons/godot-form-validator/rules/validator_rule.gd")]([SubResource("Resource_3nuq2")])
[node name="Example" type="PanelContainer" unique_id=1143668754] [node name="Example" type="PanelContainer"]
anchors_preset = 15 anchors_preset = 15
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
@@ -134,20 +150,19 @@ grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
script = ExtResource("1_8caq6") script = ExtResource("1_8caq6")
[node name="MarginContainer" type="MarginContainer" parent="." unique_id=557209502] [node name="MarginContainer" type="MarginContainer" parent="."]
layout_mode = 2 layout_mode = 2
theme_override_constants/margin_left = 32 theme_override_constants/margin_left = 32
theme_override_constants/margin_top = 32 theme_override_constants/margin_top = 32
theme_override_constants/margin_right = 32 theme_override_constants/margin_right = 32
theme_override_constants/margin_bottom = 32 theme_override_constants/margin_bottom = 32
[node name="FormValidator" type="Control" parent="MarginContainer" unique_id=740375273] [node name="FormValidator" type="Control" parent="MarginContainer"]
layout_mode = 2 layout_mode = 2
script = ExtResource("2_mtxo0") script = ExtResource("2_mtxo0")
auto_validate = true auto_validate = true
validation_method = 0
[node name="VBoxContainer2" type="VBoxContainer" parent="MarginContainer/FormValidator" unique_id=1672024461] [node name="VBoxContainer2" type="VBoxContainer" parent="MarginContainer/FormValidator"]
layout_mode = 1 layout_mode = 1
anchors_preset = 15 anchors_preset = 15
anchor_right = 1.0 anchor_right = 1.0
@@ -155,267 +170,267 @@ anchor_bottom = 1.0
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
[node name="Title" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2" unique_id=1875744463] [node name="Title" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2"]
layout_mode = 2 layout_mode = 2
text = "Godot Form Validator Examples" text = "Godot Form Validator Examples"
label_settings = SubResource("LabelSettings_nw8ds") label_settings = SubResource("LabelSettings_nw8ds")
horizontal_alignment = 1 horizontal_alignment = 1
vertical_alignment = 1 vertical_alignment = 1
[node name="GridContainer" type="GridContainer" parent="MarginContainer/FormValidator/VBoxContainer2" unique_id=973575488] [node name="GridContainer" type="GridContainer" parent="MarginContainer/FormValidator/VBoxContainer2"]
layout_mode = 2 layout_mode = 2
size_flags_vertical = 3 size_flags_vertical = 3
theme_override_constants/h_separation = 16 theme_override_constants/h_separation = 16
theme_override_constants/v_separation = 16 theme_override_constants/v_separation = 16
columns = 4 columns = 4
[node name="Label" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer" unique_id=516411488] [node name="Label" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer"]
layout_mode = 2 layout_mode = 2
text = "Alpha" text = "Alpha"
vertical_alignment = 1 vertical_alignment = 1
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer" unique_id=1233638864] [node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer"]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
[node name="Alpha" type="LineEdit" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer" unique_id=195719562] [node name="Alpha" type="LineEdit" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer"]
layout_mode = 2 layout_mode = 2
[node name="ControlValidator" type="Node" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer/Alpha" unique_id=281329145] [node name="ControlValidator" type="Node" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer/Alpha"]
script = ExtResource("3_hkwup") script = ExtResource("3_hkwup")
validator = SubResource("Resource_15man") validator = SubResource("Resource_15man")
[node name="AlphaError" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer" unique_id=1627694098] [node name="AlphaError" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer"]
visible = false visible = false
layout_mode = 2 layout_mode = 2
text = "ERROR" text = "ERROR"
label_settings = SubResource("LabelSettings_su7t3") label_settings = SubResource("LabelSettings_su7t3")
autowrap_mode = 2 autowrap_mode = 2
[node name="AlphaValid" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer" unique_id=84059690] [node name="AlphaValid" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer"]
visible = false visible = false
layout_mode = 2 layout_mode = 2
text = "Valid!" text = "Valid!"
label_settings = SubResource("LabelSettings_urp4f") label_settings = SubResource("LabelSettings_urp4f")
[node name="Label2" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer" unique_id=1097468362] [node name="Label2" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer"]
layout_mode = 2 layout_mode = 2
text = "Numeric" text = "Numeric"
vertical_alignment = 1 vertical_alignment = 1
[node name="VBoxContainer2" type="VBoxContainer" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer" unique_id=1159405902] [node name="VBoxContainer2" type="VBoxContainer" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer"]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
[node name="Numeric" type="LineEdit" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer2" unique_id=1678871163] [node name="Numeric" type="LineEdit" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer2"]
layout_mode = 2 layout_mode = 2
[node name="ControlValidator" type="Node" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer2/Numeric" unique_id=714305967] [node name="ControlValidator" type="Node" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer2/Numeric"]
script = ExtResource("3_hkwup") script = ExtResource("3_hkwup")
validator = SubResource("Resource_1t3q0") validator = SubResource("Resource_1t3q0")
[node name="NumericError" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer2" unique_id=830938453] [node name="NumericError" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer2"]
visible = false visible = false
layout_mode = 2 layout_mode = 2
text = "ERROR" text = "ERROR"
label_settings = SubResource("LabelSettings_su7t3") label_settings = SubResource("LabelSettings_su7t3")
autowrap_mode = 2 autowrap_mode = 2
[node name="NumericValid" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer2" unique_id=835884425] [node name="NumericValid" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer2"]
visible = false visible = false
layout_mode = 2 layout_mode = 2
text = "Valid!" text = "Valid!"
label_settings = SubResource("LabelSettings_urp4f") label_settings = SubResource("LabelSettings_urp4f")
[node name="Label3" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer" unique_id=1149940543] [node name="Label3" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer"]
layout_mode = 2 layout_mode = 2
text = "Alphanumeric" text = "Alphanumeric"
vertical_alignment = 1 vertical_alignment = 1
[node name="VBoxContainer3" type="VBoxContainer" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer" unique_id=388333675] [node name="VBoxContainer3" type="VBoxContainer" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer"]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
[node name="Alphanumeric" type="LineEdit" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer3" unique_id=1804794614] [node name="Alphanumeric" type="LineEdit" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer3"]
layout_mode = 2 layout_mode = 2
[node name="ControlValidator" type="Node" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer3/Alphanumeric" unique_id=295749143] [node name="ControlValidator" type="Node" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer3/Alphanumeric"]
script = ExtResource("3_hkwup") script = ExtResource("3_hkwup")
validator = SubResource("Resource_61y5a") validator = SubResource("Resource_61y5a")
[node name="AlphanumericError" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer3" unique_id=1860584450] [node name="AlphanumericError" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer3"]
visible = false visible = false
layout_mode = 2 layout_mode = 2
text = "ERROR" text = "ERROR"
label_settings = SubResource("LabelSettings_su7t3") label_settings = SubResource("LabelSettings_su7t3")
autowrap_mode = 2 autowrap_mode = 2
[node name="AlphanumericValid" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer3" unique_id=493731166] [node name="AlphanumericValid" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer3"]
visible = false visible = false
layout_mode = 2 layout_mode = 2
text = "Valid!" text = "Valid!"
label_settings = SubResource("LabelSettings_urp4f") label_settings = SubResource("LabelSettings_urp4f")
[node name="Label4" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer" unique_id=539231275] [node name="Label4" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer"]
layout_mode = 2 layout_mode = 2
text = "Email" text = "Email"
vertical_alignment = 1 vertical_alignment = 1
[node name="VBoxContainer4" type="VBoxContainer" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer" unique_id=1263223546] [node name="VBoxContainer4" type="VBoxContainer" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer"]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
[node name="Email" type="LineEdit" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer4" unique_id=1555844645] [node name="Email" type="LineEdit" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer4"]
layout_mode = 2 layout_mode = 2
[node name="ControlValidator" type="Node" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer4/Email" unique_id=131516445] [node name="ControlValidator" type="Node" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer4/Email"]
script = ExtResource("3_hkwup") script = ExtResource("3_hkwup")
validator = SubResource("Resource_q4oax") validator = SubResource("Resource_q4oax")
[node name="EmailError" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer4" unique_id=1261830767] [node name="EmailError" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer4"]
visible = false visible = false
layout_mode = 2 layout_mode = 2
text = "ERROR" text = "ERROR"
label_settings = SubResource("LabelSettings_su7t3") label_settings = SubResource("LabelSettings_su7t3")
autowrap_mode = 2 autowrap_mode = 2
[node name="EmailValid" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer4" unique_id=384749791] [node name="EmailValid" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer4"]
visible = false visible = false
layout_mode = 2 layout_mode = 2
text = "Valid!" text = "Valid!"
label_settings = SubResource("LabelSettings_urp4f") label_settings = SubResource("LabelSettings_urp4f")
[node name="Label5" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer" unique_id=1714799108] [node name="Label5" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer"]
layout_mode = 2 layout_mode = 2
text = "Length" text = "Length"
vertical_alignment = 1 vertical_alignment = 1
[node name="VBoxContainer5" type="VBoxContainer" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer" unique_id=1293011567] [node name="VBoxContainer5" type="VBoxContainer" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer"]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
[node name="Length" type="LineEdit" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer5" unique_id=2064540250] [node name="Length" type="LineEdit" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer5"]
layout_mode = 2 layout_mode = 2
[node name="ControlValidator" type="Node" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer5/Length" unique_id=1845190839] [node name="ControlValidator" type="Node" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer5/Length"]
script = ExtResource("3_hkwup") script = ExtResource("3_hkwup")
validator = SubResource("Resource_62odm") validator = SubResource("Resource_62odm")
[node name="LengthError" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer5" unique_id=1875660447] [node name="LengthError" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer5"]
visible = false visible = false
layout_mode = 2 layout_mode = 2
text = "ERROR" text = "ERROR"
label_settings = SubResource("LabelSettings_su7t3") label_settings = SubResource("LabelSettings_su7t3")
autowrap_mode = 2 autowrap_mode = 2
[node name="LengthValid" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer5" unique_id=2021172312] [node name="LengthValid" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer5"]
visible = false visible = false
layout_mode = 2 layout_mode = 2
text = "Valid!" text = "Valid!"
label_settings = SubResource("LabelSettings_urp4f") label_settings = SubResource("LabelSettings_urp4f")
[node name="Label6" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer" unique_id=349007451] [node name="Label6" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer"]
layout_mode = 2 layout_mode = 2
text = "Value" text = "Value"
vertical_alignment = 1 vertical_alignment = 1
[node name="VBoxContainer6" type="VBoxContainer" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer" unique_id=1662292642] [node name="VBoxContainer6" type="VBoxContainer" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer"]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
[node name="Value" type="SpinBox" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer6" unique_id=255442278] [node name="Value" type="SpinBox" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer6"]
layout_mode = 2 layout_mode = 2
[node name="ControlValidator" type="Node" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer6/Value" unique_id=186846352] [node name="ControlValidator" type="Node" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer6/Value"]
script = ExtResource("3_hkwup") script = ExtResource("3_hkwup")
validator = SubResource("Resource_smogv") validator = SubResource("Resource_smogv")
[node name="ValueError" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer6" unique_id=1002570139] [node name="ValueError" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer6"]
visible = false visible = false
layout_mode = 2 layout_mode = 2
text = "ERROR" text = "ERROR"
label_settings = SubResource("LabelSettings_su7t3") label_settings = SubResource("LabelSettings_su7t3")
autowrap_mode = 2 autowrap_mode = 2
[node name="ValueValid" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer6" unique_id=1604137535] [node name="ValueValid" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer6"]
visible = false visible = false
layout_mode = 2 layout_mode = 2
text = "Valid!" text = "Valid!"
label_settings = SubResource("LabelSettings_urp4f") label_settings = SubResource("LabelSettings_urp4f")
[node name="Label7" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer" unique_id=2112194338] [node name="Label7" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer"]
layout_mode = 2 layout_mode = 2
text = "Custom" text = "Custom"
vertical_alignment = 1 vertical_alignment = 1
[node name="VBoxContainer7" type="VBoxContainer" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer" unique_id=418670733] [node name="VBoxContainer7" type="VBoxContainer" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer"]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
[node name="ColorPicker" type="ColorPickerButton" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer7" unique_id=1750844205] [node name="ColorPicker" type="ColorPickerButton" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer7"]
custom_minimum_size = Vector2(0, 32) custom_minimum_size = Vector2(0, 32)
layout_mode = 2 layout_mode = 2
size_flags_vertical = 3 size_flags_vertical = 3
[node name="ControlValidator" type="Node" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer7/ColorPicker" unique_id=807038440] [node name="ControlValidator" type="Node" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer7/ColorPicker"]
script = ExtResource("3_hkwup") script = ExtResource("3_hkwup")
validator = SubResource("Resource_mh7td") validator = SubResource("Resource_mh7td")
[node name="ColorPickerError" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer7" unique_id=582336359] [node name="ColorPickerError" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer7"]
visible = false visible = false
layout_mode = 2 layout_mode = 2
text = "ERROR" text = "ERROR"
label_settings = SubResource("LabelSettings_su7t3") label_settings = SubResource("LabelSettings_su7t3")
autowrap_mode = 2 autowrap_mode = 2
[node name="ColorPickerValid" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer7" unique_id=2137026177] [node name="ColorPickerValid" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer7"]
visible = false visible = false
layout_mode = 2 layout_mode = 2
text = "Valid!" text = "Valid!"
label_settings = SubResource("LabelSettings_urp4f") label_settings = SubResource("LabelSettings_urp4f")
[node name="Label8" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer" unique_id=1475169490] [node name="Label8" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer"]
layout_mode = 2 layout_mode = 2
text = "Checked" text = "Checked"
vertical_alignment = 1 vertical_alignment = 1
[node name="VBoxContainer8" type="VBoxContainer" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer" unique_id=1031839141] [node name="VBoxContainer8" type="VBoxContainer" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer"]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
[node name="Checked" type="CheckBox" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer8" unique_id=1249694583] [node name="Checked" type="CheckBox" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer8"]
custom_minimum_size = Vector2(0, 32) custom_minimum_size = Vector2(0, 32)
layout_mode = 2 layout_mode = 2
size_flags_vertical = 3 size_flags_vertical = 3
[node name="ControlValidator" type="Node" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer8/Checked" unique_id=1199739924] [node name="ControlValidator" type="Node" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer8/Checked"]
script = ExtResource("3_hkwup") script = ExtResource("3_hkwup")
validator = SubResource("Resource_kbsj8") validator = SubResource("Resource_kbsj8")
[node name="CheckedError" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer8" unique_id=1247191832] [node name="CheckedError" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer8"]
visible = false visible = false
layout_mode = 2 layout_mode = 2
text = "ERROR" text = "ERROR"
label_settings = SubResource("LabelSettings_su7t3") label_settings = SubResource("LabelSettings_su7t3")
autowrap_mode = 2 autowrap_mode = 2
[node name="CheckedValid" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer8" unique_id=1900555189] [node name="CheckedValid" type="Label" parent="MarginContainer/FormValidator/VBoxContainer2/GridContainer/VBoxContainer8"]
visible = false visible = false
layout_mode = 2 layout_mode = 2
text = "Valid!" text = "Valid!"
label_settings = SubResource("LabelSettings_urp4f") label_settings = SubResource("LabelSettings_urp4f")
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/FormValidator/VBoxContainer2" unique_id=566181778] [node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/FormValidator/VBoxContainer2"]
layout_mode = 2 layout_mode = 2
theme_override_constants/separation = 32 theme_override_constants/separation = 32
[node name="Validate" type="Button" parent="MarginContainer/FormValidator/VBoxContainer2/HBoxContainer" unique_id=742843249] [node name="Validate" type="Button" parent="MarginContainer/FormValidator/VBoxContainer2/HBoxContainer"]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
theme_override_font_sizes/font_size = 16 theme_override_font_sizes/font_size = 16
text = "Validate Form" text = "Validate Form"
[node name="Exit" type="Button" parent="MarginContainer/FormValidator/VBoxContainer2/HBoxContainer" unique_id=809646022] [node name="Exit" type="Button" parent="MarginContainer/FormValidator/VBoxContainer2/HBoxContainer"]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
theme_override_font_sizes/font_size = 16 theme_override_font_sizes/font_size = 16
+18 -27
View File
@@ -2,7 +2,7 @@
extends Control extends Control
class_name FormValidator class_name FormValidator
signal control_validated(control: Control, passed: bool, messages: PackedStringArray) signal control_validated(control, passed, messages)
class ValidatorInfo extends RefCounted: class ValidatorInfo extends RefCounted:
var control: Control var control: Control
@@ -14,8 +14,8 @@ class ValidatorInfo extends RefCounted:
validation_method = value validation_method = value
_update_validation_methods() _update_validation_methods()
var _control_validator_map: Dictionary[Control, Validator] = {} var _control_validator_map: Dictionary = {}
var _control_messages_map: Dictionary[Control, PackedStringArray] = {} var _control_messages_map: Dictionary = {}
func _ready() -> void: func _ready() -> void:
@@ -36,38 +36,29 @@ func get_messages_for_control(control: Control) -> PackedStringArray:
func validate() -> bool: func validate() -> bool:
_control_messages_map.clear() _control_messages_map.clear()
var list: Array[ValidatorInfo] = _get_validator_info_list() var list = _get_validator_info_list()
var valid: bool = true var valid = true
for info: ValidatorInfo in list: for info in list:
if info.validator.skip_validation: if info.validator.skip_validation:
continue continue
var control: Control = info.control as Control var passed = info.validator.validate(info.control)
if control == null: var messages = info.validator.get_messages()
Log.error("FormValidator: ValidatorInfo.control is not a Control: %s" % [info.control])
continue
var passed: bool = info.validator.validate(control)
var messages: PackedStringArray = info.validator.get_messages()
if not passed: if not passed:
_control_messages_map[control] = messages _control_messages_map[info.control] = messages
control_validated.emit(control, passed, messages) control_validated.emit(info.control, passed, messages)
valid = valid and passed valid = valid and passed
if not valid and validation_method == Validation.Method.IMMEDIATE: if not valid and validation_method == Validation.Method.IMMEDIATE:
return valid return valid
return valid return valid
func _get_validator_info_list() -> Array[ValidatorInfo]: func _get_validator_info_list() -> Array[ValidatorInfo]:
var list: Array[ValidatorInfo] = [] var list: Array[ValidatorInfo] = []
for controlKey: Control in _control_validator_map.keys(): for control in _control_validator_map.keys():
var control: Control = controlKey as Control var validator = _control_validator_map[control]
if control == null:
Log.error("FormValidator: _control_validator_map key is not a Control")
continue
var validator: Validator = _control_validator_map[control]
if not validator: if not validator:
continue continue
var info: ValidatorInfo = ValidatorInfo.new() var info = ValidatorInfo.new()
info.control = control info.control = control
info.validator = validator info.validator = validator
list.append(info) list.append(info)
@@ -78,9 +69,9 @@ func _get_validator_info_list() -> Array[ValidatorInfo]:
func _update_validation_methods() -> void: func _update_validation_methods() -> void:
var validators: Array = _control_validator_map.values() var validators = _control_validator_map.values()
for item in validators: for item in validators:
var validator: Validator = item as Validator var validator = item as Validator
if not validator: if not validator:
continue continue
validator.validation_method = validation_method validator.validation_method = validation_method
@@ -88,7 +79,7 @@ func _update_validation_methods() -> void:
func _find_validators(node: Node) -> void: func _find_validators(node: Node) -> void:
for child in node.get_children(): for child in node.get_children():
var control_validator: ControlValidator = child as ControlValidator var control_validator = child as ControlValidator
if control_validator: if control_validator:
control_validator._on_validator_added() control_validator._on_validator_added()
_find_validators(child) _find_validators(child)
@@ -97,10 +88,10 @@ func _find_validators(node: Node) -> void:
func _auto_validate(control: Control) -> void: func _auto_validate(control: Control) -> void:
if not auto_validate: if not auto_validate:
return return
var validator: Validator = _control_validator_map[control] as Validator var validator = _control_validator_map[control] as Validator
if not validator: if not validator:
return return
var passed: bool = validator.validate(control) var passed = validator.validate(control)
control_validated.emit(control, passed, validator.get_messages()) control_validated.emit(control, passed, validator.get_messages())
@@ -1 +1 @@
uid://ddmyah1o42hwp uid://bu80rel3g62k2
+1 -1
View File
@@ -1 +1 @@
uid://cqpt42wqcandl uid://cmj1fker1yns8
@@ -7,8 +7,8 @@ func _init() -> void:
fail_message = "Value must contain only alpha characters." fail_message = "Value must contain only alpha characters."
func apply(control: Control, value: Variant) -> RuleResult: func apply(control: Control, value) -> RuleResult:
var result: RuleResult = RuleResult.new() var result = RuleResult.new()
if value is String: if value is String:
result.passed = ValidatorFunctions.empty(value) or ValidatorFunctions.alpha(value) result.passed = ValidatorFunctions.empty(value) or ValidatorFunctions.alpha(value)
if not result.passed: if not result.passed:
@@ -1 +1 @@
uid://wgfr07ktmqap uid://buri6rr3thncv
@@ -1,14 +1,14 @@
@tool @tool
class_name AlphanumericRule
extends ValidatorRule extends ValidatorRule
class_name AlphanumericRule
func _init() -> void: func _init() -> void:
fail_message = "Value must contain only alphanumeric characters." fail_message = "Value must contain only alphanumeric cahracters."
func apply(control: Control, value: Variant) -> RuleResult: func apply(control: Control, value) -> RuleResult:
var result: RuleResult = RuleResult.new() var result = RuleResult.new()
if value is String: if value is String:
result.passed = ValidatorFunctions.empty(value) or ValidatorFunctions.alphanumeric(value) result.passed = ValidatorFunctions.empty(value) or ValidatorFunctions.alphanumeric(value)
if not result.passed: if not result.passed:
@@ -1 +1 @@
uid://bueqq0cpyjwtg uid://cevlkeecv848l
@@ -1,14 +1,14 @@
@tool @tool
class_name BooleanRule
extends ValidatorRule extends ValidatorRule
class_name BooleanRule
@export var target_value: bool @export var target_value: bool
func apply(control: Control, value: Variant) -> RuleResult: func apply(control: Control, value) -> RuleResult:
if ValidatorFunctions.empty(fail_message): if ValidatorFunctions.empty(fail_message):
fail_message = "The value must equal %s." % target_value fail_message = "The value must equal %s." % target_value
var result: RuleResult = RuleResult.new() var result = RuleResult.new()
result.passed = value is bool and value == target_value result.passed = value is bool and value == target_value
if not result.passed: if not result.passed:
result.message = fail_message result.message = fail_message
@@ -1 +1 @@
uid://dsrxfoqxxycoi uid://sf5t1a7k3682
@@ -7,13 +7,13 @@ class_name CustomRule
var _expression: Expression = Expression.new() var _expression: Expression = Expression.new()
func apply(control: Control, value: Variant) -> RuleResult: func apply(control: Control, value) -> RuleResult:
var result: RuleResult = RuleResult.new() var result = RuleResult.new()
if not _validate_expression(): if not _validate_expression():
result.passed = false result.passed = false
result.message = "Specified expression is not valid." result.message = "Specified expression is not valid."
return result return result
var res: Variant = _expression.execute([ control, value ]) var res = _expression.execute([ control, value ])
if _expression.has_execute_failed(): if _expression.has_execute_failed():
result.passed = false result.passed = false
result.message = "Execution of the specified expression has failed." result.message = "Execution of the specified expression has failed."
@@ -1 +1 @@
uid://c7tybiqm6xgvi uid://bd6nlgk6a0w6y
@@ -1,6 +1,6 @@
@tool @tool
class_name DoesNotMatchRule
extends ValidatorRule extends ValidatorRule
class_name DoesNotMatchRule
@export var pattern: String @export var pattern: String
@@ -9,8 +9,8 @@ func _init() -> void:
fail_message = "Invalid value." fail_message = "Invalid value."
func apply(control: Control, value: Variant) -> RuleResult: func apply(control: Control, value) -> RuleResult:
var result: RuleResult = RuleResult.new() var result = RuleResult.new()
if value is String: if value is String:
result.passed = ValidatorFunctions.empty(value) or ValidatorFunctions.does_not_match(pattern, value) result.passed = ValidatorFunctions.empty(value) or ValidatorFunctions.does_not_match(pattern, value)
if not result.passed: if not result.passed:
@@ -1 +1 @@
uid://ccdpwnb3t4u2d uid://dtmjb54l1b7r3
@@ -7,8 +7,8 @@ func _init() -> void:
fail_message = "Value must be a valid email address." fail_message = "Value must be a valid email address."
func apply(control: Control, value: Variant) -> RuleResult: func apply(control: Control, value) -> RuleResult:
var result: RuleResult = RuleResult.new() var result = RuleResult.new()
if value is String: if value is String:
result.passed = ValidatorFunctions.empty(value) or ValidatorFunctions.email(value) result.passed = ValidatorFunctions.empty(value) or ValidatorFunctions.email(value)
if not result.passed: if not result.passed:
@@ -1 +1 @@
uid://dvpln5snrt4mq uid://13fsle485u2d
@@ -1,14 +1,14 @@
@tool @tool
class_name EqualsRule
extends ValidatorRule extends ValidatorRule
class_name EqualsRule
@export var target_value: String @export var target_value: String
func apply(control: Control, value: Variant) -> RuleResult: func apply(control: Control, value) -> RuleResult:
if ValidatorFunctions.empty(fail_message): if ValidatorFunctions.empty(fail_message):
fail_message = "The value must equal %s." % target_value fail_message = "The value must equal %s." % target_value
var result: RuleResult = RuleResult.new() var result = RuleResult.new()
result.passed = str(value) == target_value result.passed = str(value) == target_value
if not result.passed: if not result.passed:
result.message = fail_message result.message = fail_message
@@ -1 +1 @@
uid://bkls54komg5df uid://dre0a1afr12rh
@@ -5,10 +5,10 @@ class_name GreaterThanRule
@export var target_value: String @export var target_value: String
func apply(control: Control, value: Variant) -> RuleResult: func apply(control: Control, value) -> RuleResult:
if ValidatorFunctions.empty(fail_message): if ValidatorFunctions.empty(fail_message):
fail_message = "The value must be greater than %s." % target_value fail_message = "The value must be greater than %s." % target_value
var result: RuleResult = RuleResult.new() var result = RuleResult.new()
result.passed = str(value) > target_value result.passed = str(value) > target_value
if not result.passed: if not result.passed:
result.message = fail_message result.message = fail_message
@@ -1 +1 @@
uid://snmw7k006wch uid://d3ovhn6swexko
@@ -8,8 +8,8 @@ const FAIL_MESSAGE: String = "The value must be between %d and %d characters lon
@export var max_length: int = 9999 @export var max_length: int = 9999
func apply(control: Control, value: Variant) -> RuleResult: func apply(control: Control, value) -> RuleResult:
var result: RuleResult = RuleResult.new() var result = RuleResult.new()
if value is String: if value is String:
result.passed = ValidatorFunctions.length(value, min_length, max_length) result.passed = ValidatorFunctions.length(value, min_length, max_length)
if not result.passed: if not result.passed:
@@ -1 +1 @@
uid://bj4s5o33vkcts uid://c0oej50oqmwva
@@ -5,10 +5,10 @@ class_name LessThanRule
@export var target_value: String @export var target_value: String
func apply(control: Control, value: Variant) -> RuleResult: func apply(control: Control, value) -> RuleResult:
if ValidatorFunctions.empty(fail_message): if ValidatorFunctions.empty(fail_message):
fail_message = "The value must be less than %s." % target_value fail_message = "The value must be less than %s." % target_value
var result: RuleResult = RuleResult.new() var result = RuleResult.new()
result.passed = str(value) < target_value result.passed = str(value) < target_value
if not result.passed: if not result.passed:
result.message = fail_message result.message = fail_message
@@ -1 +1 @@
uid://b3f8tsiq7rhu6 uid://dsdnnmgk43nbm
@@ -9,8 +9,8 @@ func _init() -> void:
fail_message = "Invalid value." fail_message = "Invalid value."
func apply(control: Control, value: Variant) -> RuleResult: func apply(control: Control, value) -> RuleResult:
var result: RuleResult = RuleResult.new() var result = RuleResult.new()
if value is String: if value is String:
result.passed = ValidatorFunctions.empty(value) or ValidatorFunctions.matches(pattern, value) result.passed = ValidatorFunctions.empty(value) or ValidatorFunctions.matches(pattern, value)
if not result.passed: if not result.passed:
@@ -1 +1 @@
uid://164beafe7555 uid://bsxs5hgtgulhx
@@ -1,14 +1,14 @@
@tool @tool
class_name NotBlankRule
extends ValidatorRule extends ValidatorRule
class_name NotBlankRule
func _init() -> void: func _init() -> void:
fail_message = "Value must not be blank." fail_message = "Value must not be blank."
func apply(control: Control, value: Variant) -> RuleResult: func apply(control: Control, value) -> RuleResult:
var result: RuleResult = RuleResult.new() var result = RuleResult.new()
if value is String: if value is String:
result.passed = ValidatorFunctions.not_blank(value) result.passed = ValidatorFunctions.not_blank(value)
if not result.passed: if not result.passed:
@@ -1 +1 @@
uid://ixvw8xkgkgji uid://dvrd8l4krg8p1
@@ -7,8 +7,8 @@ func _init() -> void:
fail_message = "Value must not be empty." fail_message = "Value must not be empty."
func apply(control: Control, value: Variant) -> RuleResult: func apply(control: Control, value) -> RuleResult:
var result: RuleResult = RuleResult.new() var result = RuleResult.new()
if value is String: if value is String:
result.passed = ValidatorFunctions.not_empty(value) result.passed = ValidatorFunctions.not_empty(value)
if not result.passed: if not result.passed:
@@ -1 +1 @@
uid://cus4ihk7x1j8b uid://c5h4qvxgkd8sg
@@ -7,8 +7,8 @@ func _init() -> void:
fail_message = "Value must contain only numbers." fail_message = "Value must contain only numbers."
func apply(control: Control, value: Variant) -> RuleResult: func apply(control: Control, value) -> RuleResult:
var result: RuleResult = RuleResult.new() var result = RuleResult.new()
if value is String: if value is String:
result.passed = ValidatorFunctions.empty(value) or ValidatorFunctions.numeric(value) result.passed = ValidatorFunctions.empty(value) or ValidatorFunctions.numeric(value)
if not result.passed: if not result.passed:
@@ -1 +1 @@
uid://dgk131fex3ts2 uid://c8vl0ds010lfe
@@ -3,12 +3,12 @@ extends ValidatorRule
class_name RequiredRule class_name RequiredRule
func _init() -> void: func _init():
fail_message = tr("VALUE_REQUIRED") fail_message = "A value is required."
func apply(control: Control, value: Variant) -> RuleResult: func apply(control: Control, value) -> RuleResult:
var result: RuleResult = RuleResult.new() var result = RuleResult.new()
if value is String: if value is String:
result.passed = ValidatorFunctions.not_blank(value) result.passed = ValidatorFunctions.not_blank(value)
else: else:
@@ -1 +1 @@
uid://dw5aercmfe4 uid://btw6a2qw2xnje
@@ -1,5 +1,5 @@
class_name RuleResult
extends RefCounted extends RefCounted
class_name RuleResult
var passed: bool = false var passed: bool = false
var message: String = "" var message: String = ""
@@ -1 +1 @@
uid://bumsh4iii0vl uid://6xm7ulqb0xku
@@ -1,11 +1,11 @@
@tool @tool
class_name ValidatorRule
extends Resource extends Resource
class_name ValidatorRule
@export var fail_message: String = "" @export var fail_message: String = ""
func apply(control: Control, value: Variant) -> RuleResult: func apply(control: Control, value) -> RuleResult:
return RuleResult.new() return RuleResult.new()
@@ -1 +1 @@
uid://dg17cfvs2w257 uid://dlg1muqj8qwau
@@ -1 +1 @@
uid://dprgt5c7gdii6 uid://bv3og5utuwv0c
@@ -3,20 +3,20 @@ class_name ValidatorFunctions
static func matches(pattern: String, text: String) -> bool: static func matches(pattern: String, text: String) -> bool:
var regex: RegEx = RegEx.create_from_string(pattern) var regex = RegEx.create_from_string(pattern)
if not regex.is_valid(): if not regex.is_valid():
Log.error("ValidatorFunctions: Invalid RegEx pattern supplied to matches function: %s" % pattern) print_debug("WARNING: Invalid RegEx pattern supplied to matches function: ", pattern)
return false return false
var result: RegExMatch = regex.search(text) var result = regex.search(text)
return result != null and result.strings.size() > 0 return result != null and result.strings.size() > 0
static func does_not_match(pattern: String, text: String) -> bool: static func does_not_match(pattern: String, text: String) -> bool:
var regex: RegEx = RegEx.create_from_string(pattern) var regex = RegEx.create_from_string(pattern)
if not regex.is_valid(): if not regex.is_valid():
Log.error("ValidatorFunctions: Invalid RegEx pattern supplied to does_not_match function: %s" % pattern) print_debug("WARNING: Invalid RegEx pattern supplied to matches function: ", pattern)
return false return false
var result: RegExMatch = regex.search(text) var result = regex.search(text)
return result == null return result == null
@@ -39,26 +39,26 @@ static func not_blank(text: String) -> bool:
static func alpha(text: String) -> bool: static func alpha(text: String) -> bool:
var regex: RegEx = RegEx.create_from_string("[^a-zA-Z]+") var regex = RegEx.create_from_string("[^a-zA-Z]+")
var result: RegExMatch = regex.search(text) var result = regex.search(text)
return result == null return result == null
static func numeric(text: String) -> bool: static func numeric(text: String) -> bool:
var regex: RegEx = RegEx.create_from_string("[^0-9]+") var regex = RegEx.create_from_string("[^0-9]+")
var result: RegExMatch = regex.search(text) var result = regex.search(text)
return result == null return result == null
static func alphanumeric(text: String) -> bool: static func alphanumeric(text: String) -> bool:
var regex: RegEx = RegEx.create_from_string("[^a-zA-Z0-9]+") var regex = RegEx.create_from_string("[^a-zA-Z0-9]+")
var result: RegExMatch = regex.search(text) var result = regex.search(text)
return result == null return result == null
static func email(text: String) -> bool: static func email(text: String) -> bool:
var regex: RegEx = RegEx.create_from_string("^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,6}$") var regex = RegEx.create_from_string("^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,6}$")
var result: RegExMatch = regex.search(text) var result = regex.search(text)
return result != null and result.strings.size() > 0 return result != null and result.strings.size() > 0
@@ -1 +1 @@
uid://dsyu33iiiigdp uid://cawrxiujs1y6g
@@ -3,12 +3,12 @@ extends Validator
class_name ButtonValidator class_name ButtonValidator
func get_value(control: Control) -> Variant: func get_value(control: Control):
var button: Button = control as Button var button = control as Button
if not button: if not button:
return null return null
return button.button_pressed return button.button_pressed
func is_type(node: Node) -> bool: func is_type(node) -> bool:
return node is Button return node is Button
@@ -1 +1 @@
uid://couf48gpjy4yt uid://cbcyqpjmcgaa7
@@ -3,12 +3,12 @@ extends Validator
class_name LineEditValidator class_name LineEditValidator
func get_value(control: Control) -> Variant: func get_value(control: Control):
var line_edit: LineEdit = control as LineEdit var line_edit = control as LineEdit
if not line_edit: if not line_edit:
return null return null
return line_edit.text return line_edit.text
func is_type(node: Node) -> bool: func is_type(node) -> bool:
return node is LineEdit return node is LineEdit
@@ -1 +1 @@
uid://c1cqwb15yoqb3 uid://cifi1fb8ie1d2
@@ -3,13 +3,13 @@ extends Validator
class_name RangeValidator class_name RangeValidator
func get_value(control: Control) -> Variant: func get_value(control: Control):
var range_control: Range = control as Range var range_control = control as Range
if not range_control: if not range_control:
return null return null
return range_control.value return range_control.value
func is_type(node: Node) -> bool: func is_type(node) -> bool:
return node is Range and \ return node is Range and \
not (node is ScrollBar or node is ProgressBar or node is TextureProgressBar) not (node is ScrollBar or node is ProgressBar or node is TextureProgressBar)
@@ -1 +1 @@
uid://kleihw30fvoh uid://dn88l3j5q46ud
@@ -3,12 +3,12 @@ extends Validator
class_name TextEditValidator class_name TextEditValidator
func get_value(control: Control) -> Variant: func get_value(control: Control):
var text_edit: TextEdit = control as TextEdit var text_edit = control as TextEdit
if not text_edit: if not text_edit:
return null return null
return text_edit.text return text_edit.text
func is_type(node: Node) -> bool: func is_type(node) -> bool:
return node is TextEdit return node is TextEdit
@@ -1 +1 @@
uid://r56xwqfa3rmp uid://b4rvkoui6nsld
@@ -10,7 +10,7 @@ class_name Validator
var _messages: PackedStringArray = PackedStringArray() var _messages: PackedStringArray = PackedStringArray()
func get_value(control: Control) -> Variant: func get_value(control: Control):
return null return null
@@ -24,9 +24,9 @@ func get_messages() -> PackedStringArray:
func validate(control: Control) -> bool: func validate(control: Control) -> bool:
_messages.clear() _messages.clear()
var valid: bool = true var valid = true
for rule: ValidatorRule in rules: for rule in rules:
var result: RuleResult = rule.apply(control, get_value(control)) var result = rule.apply(control, get_value(control))
if not result.passed: if not result.passed:
_messages.append(result.message) _messages.append(result.message)
valid = valid and result.passed valid = valid and result.passed
@@ -1 +1 @@
uid://deqj8i33tjewm uid://l8sih11d5alt
+1 -1
View File
@@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2019-2024 Piet Bronders & Jeroen De Geeter Copyright (c) 2019-2026 Piet Bronders & Jeroen De Geeter
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
+5 -3
View File
@@ -1,7 +1,7 @@
[configuration] [configuration]
entry_symbol = "sqlite_library_init" entry_symbol = "sqlite_library_init"
compatibility_minimum = "4.3" compatibility_minimum = "4.5"
[libraries] [libraries]
@@ -17,8 +17,10 @@ android.debug.x86_64 = "res://addons/godot-sqlite/bin/libgdsqlite.android.templa
android.release.x86_64 = "res://addons/godot-sqlite/bin/libgdsqlite.android.template_release.x86_64.so" android.release.x86_64 = "res://addons/godot-sqlite/bin/libgdsqlite.android.template_release.x86_64.so"
ios.debug = "res://addons/godot-sqlite/bin/libgdsqlite.ios.template_debug.xcframework" ios.debug = "res://addons/godot-sqlite/bin/libgdsqlite.ios.template_debug.xcframework"
ios.release = "res://addons/godot-sqlite/bin/libgdsqlite.ios.template_release.xcframework" ios.release = "res://addons/godot-sqlite/bin/libgdsqlite.ios.template_release.xcframework"
web.debug.wasm32 = "res://addons/godot-sqlite/bin/libgdsqlite.web.template_debug.wasm32.wasm" web.debug.threads.wasm32 = "res://addons/godot-sqlite/bin/libgdsqlite.web.template_debug.wasm32.wasm"
web.release.wasm32 = "res://addons/godot-sqlite/bin/libgdsqlite.web.template_release.wasm32.wasm" web.release.threads.wasm32 = "res://addons/godot-sqlite/bin/libgdsqlite.web.template_release.wasm32.wasm"
web.debug.wasm32 = "res://addons/godot-sqlite/bin/libgdsqlite.web.template_debug.wasm32.nothreads.wasm"
web.release.wasm32 = "res://addons/godot-sqlite/bin/libgdsqlite.web.template_release.wasm32.nothreads.wasm"
[dependencies] [dependencies]
+1 -1
View File
@@ -1 +1 @@
uid://dutfbxep8e0y4 uid://ca6ikrilfs4se
+3 -3
View File
@@ -1,5 +1,5 @@
# ############################################################################ # # ############################################################################ #
# Copyright © 2019-2024 Piet Bronders & Jeroen De Geeter <piet.bronders@gmail.com> # Copyright © 2019-2026 Piet Bronders & Jeroen De Geeter <piet.bronders@gmail.com>
# Licensed under the MIT License. # Licensed under the MIT License.
# See LICENSE in the project root for license information. # See LICENSE in the project root for license information.
# ############################################################################ # # ############################################################################ #
@@ -7,8 +7,8 @@
@tool @tool
extends EditorPlugin extends EditorPlugin
func _enter_tree() -> void: func _enter_tree():
pass pass
func _exit_tree() -> void: func _exit_tree():
pass pass
+1 -1
View File
@@ -1 +1 @@
uid://bw5eo1ofxly28 uid://cwsfv71x0jo4e
+1 -1
View File
@@ -3,5 +3,5 @@
name="Godot SQLite" name="Godot SQLite"
description="GDNative wrapper for SQLite (Godot 4.X+), making it possible to use SQLite databases as data storage in all your future games." description="GDNative wrapper for SQLite (Godot 4.X+), making it possible to use SQLite databases as data storage in all your future games."
author="Piet Bronders & Jeroen De Geeter" author="Piet Bronders & Jeroen De Geeter"
version="4.4" version="4.7"
script="godot-sqlite.gd" script="godot-sqlite.gd"