File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed
Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,6 @@ class_name FormLabel extends Label
1010 if input != null :
1111 input .gui_input .disconnect (_on_gui_input )
1212 input = new_val
13- nonstandard_input = false
1413 mode = mode # run setter
1514 indicate_required ()
1615 if validate_on_input && input != null :
@@ -21,6 +20,23 @@ class_name FormLabel extends Label
2120## "The selected input is not an input according to Form.is_input() or null"
2221@export var nonstandard_input := false
2322
23+ ## Validator
24+ @export var validator : Validator :
25+ set (new_val ):
26+ if validator != null && input != null :
27+ if has_property (input , subject ) && typeof (input [subject ]) != new_val .get_type ():
28+ push_error ("Validator must be compatible with the type of subject" )
29+ return
30+ if input .get_theme_stylebox ("normal" ) == null :
31+ validator .style_valid = input .get_theme_stylebox ("normal" )
32+ validator = new_val
33+
34+ ## Name of the property to validate
35+ @export var subject : StringName :
36+ set (new_val ):
37+ if input == null :
38+ subject = new_val
39+ elif has_property (input , new_val ) && (validator == null || typeof (input [new_val ]) == validator .get_type ()):
2440## "Input value must not be empty"
2541@export var input_required := false :
2642 set (new_val ):
Original file line number Diff line number Diff line change @@ -93,7 +93,7 @@ func _on_text_changed(
9393## Validates given text against all rules and returns validity
9494func validate (
9595 ## Text to validate
96- subject : String
96+ subject : Object
9797) -> bool :
9898 super .validate (subject )
9999 var _regex := RegEx .new ()
You can’t perform that action at this time.
0 commit comments