Settings loader mandatory fixes

- mandatory empty check if empty list ([''])
- skip regex check if replace value is None -> allowed empty as empty if not mandatory
This commit is contained in:
Clemens Schwaighofer
2025-07-14 16:23:55 +09:00
parent bcca43d774
commit 58c8447531
4 changed files with 16 additions and 5 deletions

View File

@@ -175,7 +175,9 @@ class SettingsLoader:
# - length: for string length
# - range: for int/float range check
# mandatory check
if check == "mandatory:yes" and not settings[config_id].get(entry):
if check == "mandatory:yes" and (
not settings[config_id].get(entry) or settings[config_id].get(entry) == ['']
):
error = True
self.__print(f"[!] Missing content entry for: {entry}", 'ERROR')
# skip if empty none
@@ -392,7 +394,8 @@ class SettingsLoader:
clean: re.Pattern[str] | None = None
if regex_clean is not None:
clean = re.compile(regex_clean, re.VERBOSE)
if not check.search(value):
# value must be set if clean is None, else empty value is allowed and will fail
if (clean is None and value or clean) and not check.search(value):
self.__print(
f"[!] Invalid content for '{entry}' with check '{validate}' and data: {value}",
'ERROR', print_error