Add script documentation
This commit is contained in:
parent
2413e125ce
commit
13b682d24c
1 changed files with 30 additions and 4 deletions
|
@ -30,7 +30,7 @@ var parent: Node
|
||||||
## [b]Note: [i]Don't modify.[/i][/b]
|
## [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
|
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]
|
## [b]Note: [i]Don't modify.[/i][/b]
|
||||||
var rules: Array[Dictionary]
|
var rules: Array[Dictionary]
|
||||||
## The amount of failures.[br]
|
## The amount of failures.[br]
|
||||||
|
@ -218,68 +218,94 @@ func evaluate() -> bool:
|
||||||
return failures.size() == 0
|
return failures.size() == 0
|
||||||
|
|
||||||
# +++ types and classes +++
|
# +++ 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:
|
func matches_type(types: Array[Variant.Type]) -> CoreValidationSingle:
|
||||||
rules.append({ "type": CoreTypes.ValidationType.MATCHES_TYPE, "types": types })
|
rules.append({ "type": CoreTypes.ValidationType.MATCHES_TYPE, "types": types })
|
||||||
return self
|
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:
|
func matches_class(clazz: StringName, exact: bool) -> CoreValidationSingle:
|
||||||
rules.append({ "type": CoreTypes.ValidationType.MATCHES_CLASS, "class": clazz, "exact": exact })
|
rules.append({ "type": CoreTypes.ValidationType.MATCHES_CLASS, "class": clazz, "exact": exact })
|
||||||
return self
|
return self
|
||||||
|
|
||||||
# +++ ranges +++
|
# +++ 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:
|
func in_range_int(from: int, to: int) -> CoreValidationSingle:
|
||||||
rules.append({ "type": CoreTypes.ValidationType.IN_RANGE, "matched_against": "integer", "from": from, "to": to })
|
rules.append({ "type": CoreTypes.ValidationType.IN_RANGE, "matched_against": "integer", "from": from, "to": to })
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
## Validates if [param data] contains the specified float range.[br]
|
||||||
|
## Applies to [float].
|
||||||
func in_range_float(from: float, to: float) -> CoreValidationSingle:
|
func in_range_float(from: float, to: float) -> CoreValidationSingle:
|
||||||
rules.append({ "type": CoreTypes.ValidationType.IN_RANGE, "matched_against": "float", "from": from, "to": to })
|
rules.append({ "type": CoreTypes.ValidationType.IN_RANGE, "matched_against": "float", "from": from, "to": to })
|
||||||
return self
|
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:
|
func has_minimum_value_int(minimum: int) -> CoreValidationSingle:
|
||||||
rules.append({ "type": CoreTypes.ValidationType.HAS_MINIMUM, "matched_against": "integer", "minimum": minimum })
|
rules.append({ "type": CoreTypes.ValidationType.HAS_MINIMUM, "matched_against": "integer", "minimum": minimum })
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
## Ensures that [param data] is under the specified integer.[br]
|
||||||
|
## Applies to [int].
|
||||||
func has_maximum_value_int(maximum: int) -> CoreValidationSingle:
|
func has_maximum_value_int(maximum: int) -> CoreValidationSingle:
|
||||||
rules.append({ "type": CoreTypes.ValidationType.HAS_MAXIMUM, "matched_against": "integer", "maximum": maximum })
|
rules.append({ "type": CoreTypes.ValidationType.HAS_MAXIMUM, "matched_against": "integer", "maximum": maximum })
|
||||||
return self
|
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:
|
func has_minimum_value_float(minimum: float) -> CoreValidationSingle:
|
||||||
rules.append({ "type": CoreTypes.ValidationType.HAS_MINIMUM, "matched_against": "float", "minimum": minimum })
|
rules.append({ "type": CoreTypes.ValidationType.HAS_MINIMUM, "matched_against": "float", "minimum": minimum })
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
## Ensures that [param data] is under the specified float.[br]
|
||||||
|
## Applies to [float].
|
||||||
func has_maximum_value_float(maximum: float) -> CoreValidationSingle:
|
func has_maximum_value_float(maximum: float) -> CoreValidationSingle:
|
||||||
rules.append({ "type": CoreTypes.ValidationType.HAS_MAXIMUM, "matched_against": "float", "maximum": maximum })
|
rules.append({ "type": CoreTypes.ValidationType.HAS_MAXIMUM, "matched_against": "float", "maximum": maximum })
|
||||||
return self
|
return self
|
||||||
|
|
||||||
# +++ values +++
|
# +++ values +++
|
||||||
|
## Checks whenether at least one value matches [param data].[br]
|
||||||
|
## Applies to all data types.
|
||||||
func has_values(values: Array) -> CoreValidationSingle:
|
func has_values(values: Array) -> CoreValidationSingle:
|
||||||
rules.append({ "type": CoreTypes.ValidationType.HAS_VALUES, "values": values })
|
rules.append({ "type": CoreTypes.ValidationType.HAS_VALUES, "values": values })
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
## Ensures that [param data] contains at least [code]<minimum_matches>[/code] values.[br]
|
||||||
|
## Applies to [String] & [StringName].
|
||||||
func contains(values: Array[String], minimum_matches: int = 1) -> CoreValidationSingle:
|
func contains(values: Array[String], minimum_matches: int = 1) -> CoreValidationSingle:
|
||||||
rules.append({ "type": CoreTypes.ValidationType.HAS_VALUES, "values": values, "minimum_matches": minimum_matches })
|
rules.append({ "type": CoreTypes.ValidationType.HAS_VALUES, "values": values, "minimum_matches": minimum_matches })
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
## Matches a regular expression against [param data].[br]
|
||||||
|
## Applies to [String] & [StringName].
|
||||||
func matches_regex(regex_string: String) -> CoreValidationSingle:
|
func matches_regex(regex_string: String) -> CoreValidationSingle:
|
||||||
rules.append({ "type": CoreTypes.ValidationType.MATCHES_REGEX, "regex_string": regex_string })
|
rules.append({ "type": CoreTypes.ValidationType.MATCHES_REGEX, "regex_string": regex_string })
|
||||||
return self
|
return self
|
||||||
|
|
||||||
# +++ empty/null and booleans +++
|
# +++ 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:
|
func is_not_empty() -> CoreValidationSingle:
|
||||||
rules.append({ "type": CoreTypes.ValidationType.IS_NOT_EMPTY })
|
rules.append({ "type": CoreTypes.ValidationType.IS_NOT_EMPTY })
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
## Ensures that [param data] is not [code]null[/code].
|
||||||
func is_not_null() -> CoreValidationSingle:
|
func is_not_null() -> CoreValidationSingle:
|
||||||
rules.append({ "type": CoreTypes.ValidationType.IS_NOT_NULL })
|
rules.append({ "type": CoreTypes.ValidationType.IS_NOT_NULL })
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
## Ensures that [param data] is normalized.[br]
|
||||||
|
## Applies to [Vector2], [Vector3], [Vector4], [Plane] and [Quaternion].
|
||||||
func is_normalized() -> CoreValidationSingle:
|
func is_normalized() -> CoreValidationSingle:
|
||||||
rules.append({ "type": CoreTypes.ValidationType.IS_NORMALIZED })
|
rules.append({ "type": CoreTypes.ValidationType.IS_NORMALIZED })
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
## Ensures that [param data] is orthonormalized.[br]
|
||||||
|
## Applies to [Transform2D], [Transform3D] and [Basis].
|
||||||
func is_orthonormalized() -> CoreValidationSingle:
|
func is_orthonormalized() -> CoreValidationSingle:
|
||||||
rules.append({ "type": CoreTypes.ValidationType.IS_ORTHONORMALIZED })
|
rules.append({ "type": CoreTypes.ValidationType.IS_ORTHONORMALIZED })
|
||||||
return self
|
return self
|
||||||
|
|
Loading…
Reference in a new issue