Skip to content

Commit

Permalink
refactor: ♻️ Added is_semver_version_array_valid() (#171)
Browse files Browse the repository at this point in the history
* refactor: ♻️ split off dep and inc validation function

splited `validate_dependencies_and_incompatibilities()` in to `validate_dependencies()`, `validate_incompatibilities()` and `is_mod_id_array_valid()`. Will be used in the ModTool to validate the fields separately.

* refactor: ♻️ Added `is_semver_version_array_valid()`

Added `is_semver_version_array_valid()` to check an array of semver versions. For example the *compatible_mod_loader_version* field.

* refactor: ♻️ use version array validation where applicable

Use `is_semver_version_array_valid()` in `_handle_compatible_mod_loader_version()`

* refactor: 🔥 Removed `break` in `is_semver_version_array_valid()`

Removed the `break` in `is_semver_version_array_valid()`, so all invalid values get logged at once and the user doesn't have to fix one error to get the next one.
  • Loading branch information
KANAjetzt committed Mar 5, 2023
1 parent 547c437 commit dcdbbef
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions addons/mod_loader/classes/mod_manifest.gd
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,8 @@ func _handle_compatible_mod_loader_version(godot_details: Dictionary) -> Array:
# If there are array values
if array_value.size() > 0:
# Check for valid versions
for value in array_value:
var value_string := str(value)
if not is_semver_valid(value_string):
return []
if not is_semver_version_array_valid(array_value):
return []

return array_value

Expand Down Expand Up @@ -176,6 +174,16 @@ static func is_name_or_namespace_valid(check_name: String, is_silent := false) -
return true


static func is_semver_version_array_valid(version_array: PoolStringArray, is_silent := false) -> bool:
var is_valid := true

for version in version_array:
if not is_semver_valid(version, is_silent):
is_valid = false

return is_valid


# A valid semantic version should follow this format: {mayor}.{minor}.{patch}
# reference https://semver.org/ for details
# {0-9}.{0-9}.{0-9} (no leading 0, shorter than 16 characters total)
Expand Down

0 comments on commit dcdbbef

Please sign in to comment.