refactor: Validate all fields before settings them

This commit is contained in:
Inex Code 2024-07-23 17:08:48 +03:00
parent 969b3b1417
commit 3cf368588e

View file

@ -139,6 +139,10 @@ class Forgejo(Service):
@classmethod
def set_configuration(cls, config_items):
# First, validate the configuration
for key, value in config_items.items():
if cls.config_items[key].validate_value(value) is False:
raise ValueError(f"Value {value} is not valid for {key}")
with WriteUserData() as user_data:
if "modules" not in user_data:
user_data["modules"] = {}