From 3cf368588e817c64df6fe8e8d67eecac961ef98c Mon Sep 17 00:00:00 2001 From: Inex Code Date: Tue, 23 Jul 2024 17:08:48 +0300 Subject: [PATCH] refactor: Validate all fields before settings them --- selfprivacy_api/services/forgejo/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/selfprivacy_api/services/forgejo/__init__.py b/selfprivacy_api/services/forgejo/__init__.py index 8c6ef4f..d882771 100644 --- a/selfprivacy_api/services/forgejo/__init__.py +++ b/selfprivacy_api/services/forgejo/__init__.py @@ -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"] = {}