Update plugins
This commit is contained in:
@@ -18,10 +18,10 @@ func _ready() -> void:
|
||||
func _configure_validator() -> void:
|
||||
if validator != null:
|
||||
return
|
||||
var parent: Node = get_parent()
|
||||
var parent = get_parent()
|
||||
if not parent:
|
||||
return
|
||||
var found: Validator = Validation.find_validator(parent)
|
||||
var found = Validation.find_validator(parent)
|
||||
if found:
|
||||
validator = found.duplicate(true)
|
||||
else:
|
||||
@@ -31,8 +31,8 @@ func _configure_validator() -> void:
|
||||
func _get_configuration_warnings() -> PackedStringArray:
|
||||
if not validator:
|
||||
return []
|
||||
var list: PackedStringArray = PackedStringArray()
|
||||
for rule: ValidatorRule in validator.rules:
|
||||
var list = PackedStringArray()
|
||||
for rule in validator.rules:
|
||||
if not rule.is_valid():
|
||||
list.append(rule.get_invalid_message())
|
||||
return list
|
||||
@@ -48,7 +48,7 @@ func _on_tree_exiting() -> void:
|
||||
|
||||
|
||||
func _on_validator_added() -> void:
|
||||
var parent: Node = get_parent()
|
||||
var parent = get_parent()
|
||||
if not parent or not validator:
|
||||
return
|
||||
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/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
@@ -27,10 +25,6 @@ mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
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/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
|
||||
@@ -2,10 +2,9 @@ extends PanelContainer
|
||||
|
||||
@onready var form_validator_control: FormValidator = $MarginContainer/FormValidator
|
||||
|
||||
|
||||
func _on_form_validator_control_control_validated(control: Control, passed: bool, messages: PackedStringArray) -> void:
|
||||
var error_label: Label = _get_error_label(control)
|
||||
var valid_label: Label = _get_valid_label(control)
|
||||
func _on_form_validator_control_control_validated(control, passed, messages) -> void:
|
||||
var error_label = _get_error_label(control)
|
||||
var valid_label = _get_valid_label(control)
|
||||
if passed:
|
||||
if error_label:
|
||||
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" uid="uid://ddmyah1o42hwp" 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" uid="uid://dg17cfvs2w257" path="res://addons/godot-form-validator/rules/validator_rule.gd" id="4_d7ctn"]
|
||||
[ext_resource type="Script" uid="uid://wgfr07ktmqap" path="res://addons/godot-form-validator/rules/alpha_rule.gd" id="4_dq1df"]
|
||||
[ext_resource type="Script" uid="uid://dw5aercmfe4" path="res://addons/godot-form-validator/rules/required_rule.gd" id="5_cu56g"]
|
||||
[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" uid="uid://dgk131fex3ts2" path="res://addons/godot-form-validator/rules/numeric_rule.gd" id="7_6vtuw"]
|
||||
[ext_resource type="Script" uid="uid://bueqq0cpyjwtg" path="res://addons/godot-form-validator/rules/alphanumeric_rule.gd" id="8_mu0ia"]
|
||||
[ext_resource type="Script" uid="uid://dvpln5snrt4mq" path="res://addons/godot-form-validator/rules/email_rule.gd" id="9_4ynyw"]
|
||||
[ext_resource type="Script" uid="uid://bj4s5o33vkcts" path="res://addons/godot-form-validator/rules/length_rule.gd" id="10_iuueu"]
|
||||
[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" uid="uid://kleihw30fvoh" path="res://addons/godot-form-validator/validators/range_validator.gd" id="11_51cp7"]
|
||||
[ext_resource type="Script" uid="uid://couf48gpjy4yt" path="res://addons/godot-form-validator/validators/button_validator.gd" id="13_eri47"]
|
||||
[ext_resource type="Script" uid="uid://c7tybiqm6xgvi" path="res://addons/godot-form-validator/rules/custom_rule.gd" id="13_ibg52"]
|
||||
[ext_resource type="Script" uid="uid://dsrxfoqxxycoi" path="res://addons/godot-form-validator/rules/boolean_rule.gd" id="15_xjpko"]
|
||||
[ext_resource type="Script" path="res://addons/godot-form-validator/example/example.gd" id="1_8caq6"]
|
||||
[ext_resource type="Script" path="res://addons/godot-form-validator/form_validator.gd" id="2_mtxo0"]
|
||||
[ext_resource type="Script" path="res://addons/godot-form-validator/control_validator.gd" id="3_hkwup"]
|
||||
[ext_resource type="Script" 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" 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" 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" 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" 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" 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"]
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_nw8ds"]
|
||||
font_size = 24
|
||||
@@ -30,8 +29,10 @@ fail_message = "Value must contain only alpha characters."
|
||||
|
||||
[sub_resource type="Resource" id="Resource_15man"]
|
||||
script = ExtResource("5_rknpr")
|
||||
validation_order = 1
|
||||
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"]
|
||||
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"]
|
||||
script = ExtResource("5_rknpr")
|
||||
validation_order = 1
|
||||
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"]
|
||||
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"]
|
||||
script = ExtResource("5_cu56g")
|
||||
@@ -62,8 +65,10 @@ fail_message = "A value is required."
|
||||
|
||||
[sub_resource type="Resource" id="Resource_61y5a"]
|
||||
script = ExtResource("5_rknpr")
|
||||
validation_order = 1
|
||||
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"]
|
||||
script = ExtResource("9_4ynyw")
|
||||
@@ -75,8 +80,10 @@ fail_message = "A value is required."
|
||||
|
||||
[sub_resource type="Resource" id="Resource_q4oax"]
|
||||
script = ExtResource("5_rknpr")
|
||||
validation_order = 1
|
||||
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"]
|
||||
script = ExtResource("5_cu56g")
|
||||
@@ -86,11 +93,14 @@ fail_message = "A value is required."
|
||||
script = ExtResource("10_iuueu")
|
||||
min_length = 5
|
||||
max_length = 10
|
||||
fail_message = ""
|
||||
|
||||
[sub_resource type="Resource" id="Resource_62odm"]
|
||||
script = ExtResource("5_rknpr")
|
||||
validation_order = 1
|
||||
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"]
|
||||
script = ExtResource("5_cu56g")
|
||||
@@ -99,11 +109,14 @@ fail_message = "A value is required."
|
||||
[sub_resource type="Resource" id="Resource_brbah"]
|
||||
script = ExtResource("11_1tya3")
|
||||
target_value = "3"
|
||||
fail_message = ""
|
||||
|
||||
[sub_resource type="Resource" id="Resource_smogv"]
|
||||
script = ExtResource("11_51cp7")
|
||||
validation_order = 1
|
||||
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"]
|
||||
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"]
|
||||
script = ExtResource("13_eri47")
|
||||
validation_order = 1
|
||||
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"]
|
||||
script = ExtResource("15_xjpko")
|
||||
@@ -124,9 +139,10 @@ fail_message = "The check box must be checked."
|
||||
script = ExtResource("13_eri47")
|
||||
validation_order = -1
|
||||
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
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
@@ -134,20 +150,19 @@ grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_8caq6")
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="." unique_id=557209502]
|
||||
[node name="MarginContainer" type="MarginContainer" parent="."]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 32
|
||||
theme_override_constants/margin_top = 32
|
||||
theme_override_constants/margin_right = 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
|
||||
script = ExtResource("2_mtxo0")
|
||||
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
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
@@ -155,267 +170,267 @@ anchor_bottom = 1.0
|
||||
grow_horizontal = 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
|
||||
text = "Godot Form Validator Examples"
|
||||
label_settings = SubResource("LabelSettings_nw8ds")
|
||||
horizontal_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
|
||||
size_flags_vertical = 3
|
||||
theme_override_constants/h_separation = 16
|
||||
theme_override_constants/v_separation = 16
|
||||
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
|
||||
text = "Alpha"
|
||||
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
|
||||
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
|
||||
|
||||
[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")
|
||||
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
|
||||
layout_mode = 2
|
||||
text = "ERROR"
|
||||
label_settings = SubResource("LabelSettings_su7t3")
|
||||
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
|
||||
layout_mode = 2
|
||||
text = "Valid!"
|
||||
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
|
||||
text = "Numeric"
|
||||
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
|
||||
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
|
||||
|
||||
[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")
|
||||
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
|
||||
layout_mode = 2
|
||||
text = "ERROR"
|
||||
label_settings = SubResource("LabelSettings_su7t3")
|
||||
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
|
||||
layout_mode = 2
|
||||
text = "Valid!"
|
||||
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
|
||||
text = "Alphanumeric"
|
||||
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
|
||||
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
|
||||
|
||||
[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")
|
||||
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
|
||||
layout_mode = 2
|
||||
text = "ERROR"
|
||||
label_settings = SubResource("LabelSettings_su7t3")
|
||||
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
|
||||
layout_mode = 2
|
||||
text = "Valid!"
|
||||
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
|
||||
text = "Email"
|
||||
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
|
||||
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
|
||||
|
||||
[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")
|
||||
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
|
||||
layout_mode = 2
|
||||
text = "ERROR"
|
||||
label_settings = SubResource("LabelSettings_su7t3")
|
||||
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
|
||||
layout_mode = 2
|
||||
text = "Valid!"
|
||||
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
|
||||
text = "Length"
|
||||
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
|
||||
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
|
||||
|
||||
[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")
|
||||
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
|
||||
layout_mode = 2
|
||||
text = "ERROR"
|
||||
label_settings = SubResource("LabelSettings_su7t3")
|
||||
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
|
||||
layout_mode = 2
|
||||
text = "Valid!"
|
||||
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
|
||||
text = "Value"
|
||||
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
|
||||
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
|
||||
|
||||
[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")
|
||||
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
|
||||
layout_mode = 2
|
||||
text = "ERROR"
|
||||
label_settings = SubResource("LabelSettings_su7t3")
|
||||
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
|
||||
layout_mode = 2
|
||||
text = "Valid!"
|
||||
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
|
||||
text = "Custom"
|
||||
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
|
||||
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)
|
||||
layout_mode = 2
|
||||
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")
|
||||
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
|
||||
layout_mode = 2
|
||||
text = "ERROR"
|
||||
label_settings = SubResource("LabelSettings_su7t3")
|
||||
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
|
||||
layout_mode = 2
|
||||
text = "Valid!"
|
||||
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
|
||||
text = "Checked"
|
||||
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
|
||||
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)
|
||||
layout_mode = 2
|
||||
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")
|
||||
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
|
||||
layout_mode = 2
|
||||
text = "ERROR"
|
||||
label_settings = SubResource("LabelSettings_su7t3")
|
||||
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
|
||||
layout_mode = 2
|
||||
text = "Valid!"
|
||||
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
|
||||
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
|
||||
size_flags_horizontal = 3
|
||||
theme_override_font_sizes/font_size = 16
|
||||
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
|
||||
size_flags_horizontal = 3
|
||||
theme_override_font_sizes/font_size = 16
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
extends Control
|
||||
class_name FormValidator
|
||||
|
||||
signal control_validated(control: Control, passed: bool, messages: PackedStringArray)
|
||||
signal control_validated(control, passed, messages)
|
||||
|
||||
class ValidatorInfo extends RefCounted:
|
||||
var control: Control
|
||||
@@ -14,8 +14,8 @@ class ValidatorInfo extends RefCounted:
|
||||
validation_method = value
|
||||
_update_validation_methods()
|
||||
|
||||
var _control_validator_map: Dictionary[Control, Validator] = {}
|
||||
var _control_messages_map: Dictionary[Control, PackedStringArray] = {}
|
||||
var _control_validator_map: Dictionary = {}
|
||||
var _control_messages_map: Dictionary = {}
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
@@ -36,38 +36,29 @@ func get_messages_for_control(control: Control) -> PackedStringArray:
|
||||
|
||||
func validate() -> bool:
|
||||
_control_messages_map.clear()
|
||||
var list: Array[ValidatorInfo] = _get_validator_info_list()
|
||||
var valid: bool = true
|
||||
for info: ValidatorInfo in list:
|
||||
var list = _get_validator_info_list()
|
||||
var valid = true
|
||||
for info in list:
|
||||
if info.validator.skip_validation:
|
||||
continue
|
||||
var control: Control = info.control as Control
|
||||
if control == null:
|
||||
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()
|
||||
var passed = info.validator.validate(info.control)
|
||||
var messages = info.validator.get_messages()
|
||||
if not passed:
|
||||
_control_messages_map[control] = messages
|
||||
control_validated.emit(control, passed, messages)
|
||||
_control_messages_map[info.control] = messages
|
||||
control_validated.emit(info.control, passed, messages)
|
||||
valid = valid and passed
|
||||
if not valid and validation_method == Validation.Method.IMMEDIATE:
|
||||
return valid
|
||||
return valid
|
||||
|
||||
|
||||
|
||||
func _get_validator_info_list() -> Array[ValidatorInfo]:
|
||||
var list: Array[ValidatorInfo] = []
|
||||
for controlKey: Control in _control_validator_map.keys():
|
||||
var control: Control = controlKey as Control
|
||||
if control == null:
|
||||
Log.error("FormValidator: _control_validator_map key is not a Control")
|
||||
continue
|
||||
var validator: Validator = _control_validator_map[control]
|
||||
for control in _control_validator_map.keys():
|
||||
var validator = _control_validator_map[control]
|
||||
if not validator:
|
||||
continue
|
||||
var info: ValidatorInfo = ValidatorInfo.new()
|
||||
var info = ValidatorInfo.new()
|
||||
info.control = control
|
||||
info.validator = validator
|
||||
list.append(info)
|
||||
@@ -78,9 +69,9 @@ func _get_validator_info_list() -> Array[ValidatorInfo]:
|
||||
|
||||
|
||||
func _update_validation_methods() -> void:
|
||||
var validators: Array = _control_validator_map.values()
|
||||
var validators = _control_validator_map.values()
|
||||
for item in validators:
|
||||
var validator: Validator = item as Validator
|
||||
var validator = item as Validator
|
||||
if not validator:
|
||||
continue
|
||||
validator.validation_method = validation_method
|
||||
@@ -88,7 +79,7 @@ func _update_validation_methods() -> void:
|
||||
|
||||
func _find_validators(node: Node) -> void:
|
||||
for child in node.get_children():
|
||||
var control_validator: ControlValidator = child as ControlValidator
|
||||
var control_validator = child as ControlValidator
|
||||
if control_validator:
|
||||
control_validator._on_validator_added()
|
||||
_find_validators(child)
|
||||
@@ -97,10 +88,10 @@ func _find_validators(node: Node) -> void:
|
||||
func _auto_validate(control: Control) -> void:
|
||||
if not auto_validate:
|
||||
return
|
||||
var validator: Validator = _control_validator_map[control] as Validator
|
||||
var validator = _control_validator_map[control] as Validator
|
||||
if not validator:
|
||||
return
|
||||
var passed: bool = validator.validate(control)
|
||||
var passed = validator.validate(control)
|
||||
control_validated.emit(control, passed, validator.get_messages())
|
||||
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
uid://ddmyah1o42hwp
|
||||
uid://bu80rel3g62k2
|
||||
|
||||
@@ -1 +1 @@
|
||||
uid://cqpt42wqcandl
|
||||
uid://cmj1fker1yns8
|
||||
|
||||
@@ -7,8 +7,8 @@ func _init() -> void:
|
||||
fail_message = "Value must contain only alpha characters."
|
||||
|
||||
|
||||
func apply(control: Control, value: Variant) -> RuleResult:
|
||||
var result: RuleResult = RuleResult.new()
|
||||
func apply(control: Control, value) -> RuleResult:
|
||||
var result = RuleResult.new()
|
||||
if value is String:
|
||||
result.passed = ValidatorFunctions.empty(value) or ValidatorFunctions.alpha(value)
|
||||
if not result.passed:
|
||||
|
||||
@@ -1 +1 @@
|
||||
uid://wgfr07ktmqap
|
||||
uid://buri6rr3thncv
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
@tool
|
||||
class_name AlphanumericRule
|
||||
extends ValidatorRule
|
||||
class_name AlphanumericRule
|
||||
|
||||
|
||||
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:
|
||||
var result: RuleResult = RuleResult.new()
|
||||
func apply(control: Control, value) -> RuleResult:
|
||||
var result = RuleResult.new()
|
||||
if value is String:
|
||||
result.passed = ValidatorFunctions.empty(value) or ValidatorFunctions.alphanumeric(value)
|
||||
if not result.passed:
|
||||
|
||||
@@ -1 +1 @@
|
||||
uid://bueqq0cpyjwtg
|
||||
uid://cevlkeecv848l
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
@tool
|
||||
class_name BooleanRule
|
||||
extends ValidatorRule
|
||||
class_name BooleanRule
|
||||
|
||||
@export var target_value: bool
|
||||
|
||||
|
||||
func apply(control: Control, value: Variant) -> RuleResult:
|
||||
func apply(control: Control, value) -> RuleResult:
|
||||
if ValidatorFunctions.empty(fail_message):
|
||||
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
|
||||
if not result.passed:
|
||||
result.message = fail_message
|
||||
|
||||
@@ -1 +1 @@
|
||||
uid://dsrxfoqxxycoi
|
||||
uid://sf5t1a7k3682
|
||||
|
||||
@@ -7,13 +7,13 @@ class_name CustomRule
|
||||
var _expression: Expression = Expression.new()
|
||||
|
||||
|
||||
func apply(control: Control, value: Variant) -> RuleResult:
|
||||
var result: RuleResult = RuleResult.new()
|
||||
func apply(control: Control, value) -> RuleResult:
|
||||
var result = RuleResult.new()
|
||||
if not _validate_expression():
|
||||
result.passed = false
|
||||
result.message = "Specified expression is not valid."
|
||||
return result
|
||||
var res: Variant = _expression.execute([ control, value ])
|
||||
var res = _expression.execute([ control, value ])
|
||||
if _expression.has_execute_failed():
|
||||
result.passed = false
|
||||
result.message = "Execution of the specified expression has failed."
|
||||
|
||||
@@ -1 +1 @@
|
||||
uid://c7tybiqm6xgvi
|
||||
uid://bd6nlgk6a0w6y
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
@tool
|
||||
class_name DoesNotMatchRule
|
||||
extends ValidatorRule
|
||||
class_name DoesNotMatchRule
|
||||
|
||||
@export var pattern: String
|
||||
|
||||
@@ -9,8 +9,8 @@ func _init() -> void:
|
||||
fail_message = "Invalid value."
|
||||
|
||||
|
||||
func apply(control: Control, value: Variant) -> RuleResult:
|
||||
var result: RuleResult = RuleResult.new()
|
||||
func apply(control: Control, value) -> RuleResult:
|
||||
var result = RuleResult.new()
|
||||
if value is String:
|
||||
result.passed = ValidatorFunctions.empty(value) or ValidatorFunctions.does_not_match(pattern, value)
|
||||
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."
|
||||
|
||||
|
||||
func apply(control: Control, value: Variant) -> RuleResult:
|
||||
var result: RuleResult = RuleResult.new()
|
||||
func apply(control: Control, value) -> RuleResult:
|
||||
var result = RuleResult.new()
|
||||
if value is String:
|
||||
result.passed = ValidatorFunctions.empty(value) or ValidatorFunctions.email(value)
|
||||
if not result.passed:
|
||||
|
||||
@@ -1 +1 @@
|
||||
uid://dvpln5snrt4mq
|
||||
uid://13fsle485u2d
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
@tool
|
||||
class_name EqualsRule
|
||||
extends ValidatorRule
|
||||
class_name EqualsRule
|
||||
|
||||
@export var target_value: String
|
||||
|
||||
|
||||
func apply(control: Control, value: Variant) -> RuleResult:
|
||||
func apply(control: Control, value) -> RuleResult:
|
||||
if ValidatorFunctions.empty(fail_message):
|
||||
fail_message = "The value must equal %s." % target_value
|
||||
var result: RuleResult = RuleResult.new()
|
||||
var result = RuleResult.new()
|
||||
result.passed = str(value) == target_value
|
||||
if not result.passed:
|
||||
result.message = fail_message
|
||||
|
||||
@@ -1 +1 @@
|
||||
uid://bkls54komg5df
|
||||
uid://dre0a1afr12rh
|
||||
|
||||
@@ -5,10 +5,10 @@ class_name GreaterThanRule
|
||||
@export var target_value: String
|
||||
|
||||
|
||||
func apply(control: Control, value: Variant) -> RuleResult:
|
||||
func apply(control: Control, value) -> RuleResult:
|
||||
if ValidatorFunctions.empty(fail_message):
|
||||
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
|
||||
if not result.passed:
|
||||
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
|
||||
|
||||
|
||||
func apply(control: Control, value: Variant) -> RuleResult:
|
||||
var result: RuleResult = RuleResult.new()
|
||||
func apply(control: Control, value) -> RuleResult:
|
||||
var result = RuleResult.new()
|
||||
if value is String:
|
||||
result.passed = ValidatorFunctions.length(value, min_length, max_length)
|
||||
if not result.passed:
|
||||
|
||||
@@ -1 +1 @@
|
||||
uid://bj4s5o33vkcts
|
||||
uid://c0oej50oqmwva
|
||||
|
||||
@@ -5,10 +5,10 @@ class_name LessThanRule
|
||||
@export var target_value: String
|
||||
|
||||
|
||||
func apply(control: Control, value: Variant) -> RuleResult:
|
||||
func apply(control: Control, value) -> RuleResult:
|
||||
if ValidatorFunctions.empty(fail_message):
|
||||
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
|
||||
if not result.passed:
|
||||
result.message = fail_message
|
||||
|
||||
@@ -1 +1 @@
|
||||
uid://b3f8tsiq7rhu6
|
||||
uid://dsdnnmgk43nbm
|
||||
|
||||
@@ -9,8 +9,8 @@ func _init() -> void:
|
||||
fail_message = "Invalid value."
|
||||
|
||||
|
||||
func apply(control: Control, value: Variant) -> RuleResult:
|
||||
var result: RuleResult = RuleResult.new()
|
||||
func apply(control: Control, value) -> RuleResult:
|
||||
var result = RuleResult.new()
|
||||
if value is String:
|
||||
result.passed = ValidatorFunctions.empty(value) or ValidatorFunctions.matches(pattern, value)
|
||||
if not result.passed:
|
||||
|
||||
@@ -1 +1 @@
|
||||
uid://164beafe7555
|
||||
uid://bsxs5hgtgulhx
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
@tool
|
||||
class_name NotBlankRule
|
||||
extends ValidatorRule
|
||||
class_name NotBlankRule
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
fail_message = "Value must not be blank."
|
||||
|
||||
|
||||
func apply(control: Control, value: Variant) -> RuleResult:
|
||||
var result: RuleResult = RuleResult.new()
|
||||
func apply(control: Control, value) -> RuleResult:
|
||||
var result = RuleResult.new()
|
||||
if value is String:
|
||||
result.passed = ValidatorFunctions.not_blank(value)
|
||||
if not result.passed:
|
||||
|
||||
@@ -1 +1 @@
|
||||
uid://ixvw8xkgkgji
|
||||
uid://dvrd8l4krg8p1
|
||||
|
||||
@@ -7,8 +7,8 @@ func _init() -> void:
|
||||
fail_message = "Value must not be empty."
|
||||
|
||||
|
||||
func apply(control: Control, value: Variant) -> RuleResult:
|
||||
var result: RuleResult = RuleResult.new()
|
||||
func apply(control: Control, value) -> RuleResult:
|
||||
var result = RuleResult.new()
|
||||
if value is String:
|
||||
result.passed = ValidatorFunctions.not_empty(value)
|
||||
if not result.passed:
|
||||
|
||||
@@ -1 +1 @@
|
||||
uid://cus4ihk7x1j8b
|
||||
uid://c5h4qvxgkd8sg
|
||||
|
||||
@@ -7,8 +7,8 @@ func _init() -> void:
|
||||
fail_message = "Value must contain only numbers."
|
||||
|
||||
|
||||
func apply(control: Control, value: Variant) -> RuleResult:
|
||||
var result: RuleResult = RuleResult.new()
|
||||
func apply(control: Control, value) -> RuleResult:
|
||||
var result = RuleResult.new()
|
||||
if value is String:
|
||||
result.passed = ValidatorFunctions.empty(value) or ValidatorFunctions.numeric(value)
|
||||
if not result.passed:
|
||||
|
||||
@@ -1 +1 @@
|
||||
uid://dgk131fex3ts2
|
||||
uid://c8vl0ds010lfe
|
||||
|
||||
@@ -3,12 +3,12 @@ extends ValidatorRule
|
||||
class_name RequiredRule
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
fail_message = tr("VALUE_REQUIRED")
|
||||
func _init():
|
||||
fail_message = "A value is required."
|
||||
|
||||
|
||||
func apply(control: Control, value: Variant) -> RuleResult:
|
||||
var result: RuleResult = RuleResult.new()
|
||||
func apply(control: Control, value) -> RuleResult:
|
||||
var result = RuleResult.new()
|
||||
if value is String:
|
||||
result.passed = ValidatorFunctions.not_blank(value)
|
||||
else:
|
||||
|
||||
@@ -1 +1 @@
|
||||
uid://dw5aercmfe4
|
||||
uid://btw6a2qw2xnje
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class_name RuleResult
|
||||
extends RefCounted
|
||||
class_name RuleResult
|
||||
|
||||
var passed: bool = false
|
||||
var message: String = ""
|
||||
|
||||
@@ -1 +1 @@
|
||||
uid://bumsh4iii0vl
|
||||
uid://6xm7ulqb0xku
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
@tool
|
||||
class_name ValidatorRule
|
||||
extends Resource
|
||||
class_name ValidatorRule
|
||||
|
||||
@export var fail_message: String = ""
|
||||
|
||||
|
||||
func apply(control: Control, value: Variant) -> RuleResult:
|
||||
func apply(control: Control, value) -> RuleResult:
|
||||
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:
|
||||
var regex: RegEx = RegEx.create_from_string(pattern)
|
||||
var regex = RegEx.create_from_string(pattern)
|
||||
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
|
||||
var result: RegExMatch = regex.search(text)
|
||||
var result = regex.search(text)
|
||||
return result != null and result.strings.size() > 0
|
||||
|
||||
|
||||
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():
|
||||
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
|
||||
var result: RegExMatch = regex.search(text)
|
||||
var result = regex.search(text)
|
||||
return result == null
|
||||
|
||||
|
||||
@@ -39,26 +39,26 @@ static func not_blank(text: String) -> bool:
|
||||
|
||||
|
||||
static func alpha(text: String) -> bool:
|
||||
var regex: RegEx = RegEx.create_from_string("[^a-zA-Z]+")
|
||||
var result: RegExMatch = regex.search(text)
|
||||
var regex = RegEx.create_from_string("[^a-zA-Z]+")
|
||||
var result = regex.search(text)
|
||||
return result == null
|
||||
|
||||
|
||||
static func numeric(text: String) -> bool:
|
||||
var regex: RegEx = RegEx.create_from_string("[^0-9]+")
|
||||
var result: RegExMatch = regex.search(text)
|
||||
var regex = RegEx.create_from_string("[^0-9]+")
|
||||
var result = regex.search(text)
|
||||
return result == null
|
||||
|
||||
|
||||
static func alphanumeric(text: String) -> bool:
|
||||
var regex: RegEx = RegEx.create_from_string("[^a-zA-Z0-9]+")
|
||||
var result: RegExMatch = regex.search(text)
|
||||
var regex = RegEx.create_from_string("[^a-zA-Z0-9]+")
|
||||
var result = regex.search(text)
|
||||
return result == null
|
||||
|
||||
|
||||
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 result: RegExMatch = regex.search(text)
|
||||
var regex = RegEx.create_from_string("^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,6}$")
|
||||
var result = regex.search(text)
|
||||
return result != null and result.strings.size() > 0
|
||||
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
uid://dsyu33iiiigdp
|
||||
uid://cawrxiujs1y6g
|
||||
|
||||
@@ -3,12 +3,12 @@ extends Validator
|
||||
class_name ButtonValidator
|
||||
|
||||
|
||||
func get_value(control: Control) -> Variant:
|
||||
var button: Button = control as Button
|
||||
func get_value(control: Control):
|
||||
var button = control as Button
|
||||
if not button:
|
||||
return null
|
||||
return button.button_pressed
|
||||
|
||||
|
||||
func is_type(node: Node) -> bool:
|
||||
func is_type(node) -> bool:
|
||||
return node is Button
|
||||
|
||||
@@ -1 +1 @@
|
||||
uid://couf48gpjy4yt
|
||||
uid://cbcyqpjmcgaa7
|
||||
|
||||
@@ -3,12 +3,12 @@ extends Validator
|
||||
class_name LineEditValidator
|
||||
|
||||
|
||||
func get_value(control: Control) -> Variant:
|
||||
var line_edit: LineEdit = control as LineEdit
|
||||
func get_value(control: Control):
|
||||
var line_edit = control as LineEdit
|
||||
if not line_edit:
|
||||
return null
|
||||
return line_edit.text
|
||||
|
||||
|
||||
func is_type(node: Node) -> bool:
|
||||
func is_type(node) -> bool:
|
||||
return node is LineEdit
|
||||
|
||||
@@ -1 +1 @@
|
||||
uid://c1cqwb15yoqb3
|
||||
uid://cifi1fb8ie1d2
|
||||
|
||||
@@ -3,13 +3,13 @@ extends Validator
|
||||
class_name RangeValidator
|
||||
|
||||
|
||||
func get_value(control: Control) -> Variant:
|
||||
var range_control: Range = control as Range
|
||||
func get_value(control: Control):
|
||||
var range_control = control as Range
|
||||
if not range_control:
|
||||
return null
|
||||
return range_control.value
|
||||
|
||||
|
||||
func is_type(node: Node) -> bool:
|
||||
func is_type(node) -> bool:
|
||||
return node is Range and \
|
||||
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
|
||||
|
||||
|
||||
func get_value(control: Control) -> Variant:
|
||||
var text_edit: TextEdit = control as TextEdit
|
||||
func get_value(control: Control):
|
||||
var text_edit = control as TextEdit
|
||||
if not text_edit:
|
||||
return null
|
||||
return text_edit.text
|
||||
|
||||
|
||||
func is_type(node: Node) -> bool:
|
||||
func is_type(node) -> bool:
|
||||
return node is TextEdit
|
||||
|
||||
@@ -1 +1 @@
|
||||
uid://r56xwqfa3rmp
|
||||
uid://b4rvkoui6nsld
|
||||
|
||||
@@ -10,7 +10,7 @@ class_name Validator
|
||||
var _messages: PackedStringArray = PackedStringArray()
|
||||
|
||||
|
||||
func get_value(control: Control) -> Variant:
|
||||
func get_value(control: Control):
|
||||
return null
|
||||
|
||||
|
||||
@@ -24,9 +24,9 @@ func get_messages() -> PackedStringArray:
|
||||
|
||||
func validate(control: Control) -> bool:
|
||||
_messages.clear()
|
||||
var valid: bool = true
|
||||
for rule: ValidatorRule in rules:
|
||||
var result: RuleResult = rule.apply(control, get_value(control))
|
||||
var valid = true
|
||||
for rule in rules:
|
||||
var result = rule.apply(control, get_value(control))
|
||||
if not result.passed:
|
||||
_messages.append(result.message)
|
||||
valid = valid and result.passed
|
||||
|
||||
@@ -1 +1 @@
|
||||
uid://deqj8i33tjewm
|
||||
uid://l8sih11d5alt
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
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
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[configuration]
|
||||
|
||||
entry_symbol = "sqlite_library_init"
|
||||
compatibility_minimum = "4.3"
|
||||
compatibility_minimum = "4.5"
|
||||
|
||||
[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"
|
||||
ios.debug = "res://addons/godot-sqlite/bin/libgdsqlite.ios.template_debug.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.release.wasm32 = "res://addons/godot-sqlite/bin/libgdsqlite.web.template_release.wasm32.wasm"
|
||||
web.debug.threads.wasm32 = "res://addons/godot-sqlite/bin/libgdsqlite.web.template_debug.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]
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
uid://dutfbxep8e0y4
|
||||
uid://ca6ikrilfs4se
|
||||
|
||||
@@ -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.
|
||||
# See LICENSE in the project root for license information.
|
||||
# ############################################################################ #
|
||||
@@ -7,8 +7,8 @@
|
||||
@tool
|
||||
extends EditorPlugin
|
||||
|
||||
func _enter_tree() -> void:
|
||||
func _enter_tree():
|
||||
pass
|
||||
|
||||
func _exit_tree() -> void:
|
||||
func _exit_tree():
|
||||
pass
|
||||
|
||||
@@ -1 +1 @@
|
||||
uid://bw5eo1ofxly28
|
||||
uid://cwsfv71x0jo4e
|
||||
|
||||
@@ -3,5 +3,5 @@
|
||||
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."
|
||||
author="Piet Bronders & Jeroen De Geeter"
|
||||
version="4.4"
|
||||
version="4.7"
|
||||
script="godot-sqlite.gd"
|
||||
|
||||
Reference in New Issue
Block a user