diff --git a/src/classes/validationsingle.gd b/src/classes/validationsingle.gd index bc2db1b..664daa9 100644 --- a/src/classes/validationsingle.gd +++ b/src/classes/validationsingle.gd @@ -30,7 +30,7 @@ var parent: Node ## [b]Note: [i]Don't modify.[/i][/b] var data # This is the only instance where we don't want to define what type this variable should have -## All rules to evalute in [method evaluate].[br] +## All rules to evaluate in [method evaluate].[br] ## [b]Note: [i]Don't modify.[/i][/b] var rules: Array[Dictionary] ## The amount of failures.[br] @@ -218,68 +218,94 @@ func evaluate() -> bool: return failures.size() == 0 # +++ types and classes +++ -## Validates if [param data] matches some [enum Variant.Type]. +## Validates if [param data] matches some [enum Variant.Type].[br] +## Applies to all data types (obviously). func matches_type(types: Array[Variant.Type]) -> CoreValidationSingle: rules.append({ "type": CoreTypes.ValidationType.MATCHES_TYPE, "types": types }) return self -## Validates if [param data] matches some class. +## Validates if [param data] matches some class.[br] +## Applies to [Object]. func matches_class(clazz: StringName, exact: bool) -> CoreValidationSingle: rules.append({ "type": CoreTypes.ValidationType.MATCHES_CLASS, "class": clazz, "exact": exact }) return self # +++ ranges +++ -## Validates if [param data] contains +## Validates if [param data] contains the specified integer range.[br] +## Applies to [int]. func in_range_int(from: int, to: int) -> CoreValidationSingle: rules.append({ "type": CoreTypes.ValidationType.IN_RANGE, "matched_against": "integer", "from": from, "to": to }) return self +## Validates if [param data] contains the specified float range.[br] +## Applies to [float]. func in_range_float(from: float, to: float) -> CoreValidationSingle: rules.append({ "type": CoreTypes.ValidationType.IN_RANGE, "matched_against": "float", "from": from, "to": to }) return self +## Ensures that [param data] is equal to or exceeds the specified integer.[br] +## Applies to [int]. func has_minimum_value_int(minimum: int) -> CoreValidationSingle: rules.append({ "type": CoreTypes.ValidationType.HAS_MINIMUM, "matched_against": "integer", "minimum": minimum }) return self +## Ensures that [param data] is under the specified integer.[br] +## Applies to [int]. func has_maximum_value_int(maximum: int) -> CoreValidationSingle: rules.append({ "type": CoreTypes.ValidationType.HAS_MAXIMUM, "matched_against": "integer", "maximum": maximum }) return self +## Ensures that [param data] is equal to or exceeds the specified float.[br] +## Applies to [float]. func has_minimum_value_float(minimum: float) -> CoreValidationSingle: rules.append({ "type": CoreTypes.ValidationType.HAS_MINIMUM, "matched_against": "float", "minimum": minimum }) return self +## Ensures that [param data] is under the specified float.[br] +## Applies to [float]. func has_maximum_value_float(maximum: float) -> CoreValidationSingle: rules.append({ "type": CoreTypes.ValidationType.HAS_MAXIMUM, "matched_against": "float", "maximum": maximum }) return self # +++ values +++ +## Checks whenether at least one value matches [param data].[br] +## Applies to all data types. func has_values(values: Array) -> CoreValidationSingle: rules.append({ "type": CoreTypes.ValidationType.HAS_VALUES, "values": values }) return self +## Ensures that [param data] contains at least [code][/code] values.[br] +## Applies to [String] & [StringName]. func contains(values: Array[String], minimum_matches: int = 1) -> CoreValidationSingle: rules.append({ "type": CoreTypes.ValidationType.HAS_VALUES, "values": values, "minimum_matches": minimum_matches }) return self +## Matches a regular expression against [param data].[br] +## Applies to [String] & [StringName]. func matches_regex(regex_string: String) -> CoreValidationSingle: rules.append({ "type": CoreTypes.ValidationType.MATCHES_REGEX, "regex_string": regex_string }) return self # +++ empty/null and booleans +++ +## Ensures that [param data] is not empty.[br] +## Applies to [String] & [StringName] ([code]!= ""[/code]), [int] ([code]!= 0[/code]) and [float] ([code]!= 0.0[/code]). func is_not_empty() -> CoreValidationSingle: rules.append({ "type": CoreTypes.ValidationType.IS_NOT_EMPTY }) return self +## Ensures that [param data] is not [code]null[/code]. func is_not_null() -> CoreValidationSingle: rules.append({ "type": CoreTypes.ValidationType.IS_NOT_NULL }) return self +## Ensures that [param data] is normalized.[br] +## Applies to [Vector2], [Vector3], [Vector4], [Plane] and [Quaternion]. func is_normalized() -> CoreValidationSingle: rules.append({ "type": CoreTypes.ValidationType.IS_NORMALIZED }) return self +## Ensures that [param data] is orthonormalized.[br] +## Applies to [Transform2D], [Transform3D] and [Basis]. func is_orthonormalized() -> CoreValidationSingle: rules.append({ "type": CoreTypes.ValidationType.IS_ORTHONORMALIZED }) return self