Files
Kalulu/addons/godot-form-validator/rules/does_not_match_rule.gd
T
Adrien Ufferte b4f9fbe904 Update plugins
2026-03-09 09:17:36 +01:00

27 lines
593 B
GDScript

@tool
extends ValidatorRule
class_name DoesNotMatchRule
@export var pattern: String
func _init() -> void:
fail_message = "Invalid value."
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:
result.message = fail_message
return result
func is_valid() -> bool:
return RegEx.create_from_string(pattern).is_valid()
func get_invalid_message() -> String:
return "Specified regular expression is not valid."