Files
Kalulu/addons/godot-form-validator/rules/does_not_match_rule.gd
T
2025-09-05 15:55:48 +02:00

27 lines
593 B
GDScript

@tool
class_name DoesNotMatchRule
extends ValidatorRule
@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."