2
0
Fork 0

Update to 48380cd8c33172e3aeee310e14e9ee622b31d551

This commit is contained in:
JeremyStar™ 2024-05-11 02:40:26 +02:00
parent 3e75e46115
commit b5d37fdbb1
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D

View file

@ -166,12 +166,14 @@ func evaluate() -> bool:
if !result: failures.append(core.stringify_variables("Data doesn't match regex %regex%", { "regex": rule["regex_string"] }))
CoreTypes.ValidationType.IS_NOT_EMPTY:
match(typeof(data)):
Variant.Type.TYPE_STRING: if data == "": failures.append("Data string is empty")
Variant.Type.TYPE_STRING_NAME: if data == "": failures.append("Data string name is empty")
Variant.Type.TYPE_INT: if data == 0: failures.append("Data integer is zero")
Variant.Type.TYPE_FLOAT: if data == 0.0: failures.append("Data float is zero")
# If not a String, StringName, int or float, skip
_: logger.warn("Can't determine if data is null as data is not of type String, StringName, int or float")
Variant.Type.TYPE_STRING: if data == "": failures.append("Data (String) is empty")
Variant.Type.TYPE_STRING_NAME: if data == "": failures.append("Data (StringName) is empty")
Variant.Type.TYPE_INT: if data == 0: failures.append("Data (int) is zero")
Variant.Type.TYPE_FLOAT: if data == 0.0: failures.append("Data (float) is zero")
Variant.Type.TYPE_ARRAY: if data == []: failures.append("Data (Array) is empty")
Variant.Type.TYPE_DICTIONARY: if data == {}: failures.append("Data (Dictionary) is empty")
# If not supported, skip
_: logger.warn("Can't determine if data is null as data is not of type String, StringName, int, float, Array or Dictionary")
CoreTypes.ValidationType.IS_NOT_NULL:
# ⡴⠑⡄⠀⠀⠀⠀⠀⠀⠀ ⣀⣀⣤⣤⣤⣀⡀
# ⠸⡇⠀⠿⡀⠀⠀⠀⣀⡴⢿⣿⣿⣿⣿⣿⣿⣿⣷⣦⡀
@ -221,7 +223,7 @@ func evaluate() -> bool:
# +++ types and classes +++
## 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) -> CoreValidationSingle:
rules.append({ "type": CoreTypes.ValidationType.MATCHES_TYPE, "types": types })
return self
@ -289,7 +291,7 @@ func matches_regex(regex_string: String) -> CoreValidationSingle:
# +++ 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]).
## Applies to [String] & [StringName] ([code]!= ""[/code]), [int] ([code]!= 0[/code]), [float] ([code]!= 0.0[/code]), [Array] ([code]!= [][/code]) and [Dictionary] ([code]!= {}[/code]).
func is_not_empty() -> CoreValidationSingle:
rules.append({ "type": CoreTypes.ValidationType.IS_NOT_EMPTY })
return self