mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-25 13:31:27 +00:00
refactor: Validate all fields before settings them
This commit is contained in:
parent
969b3b1417
commit
3cf368588e
|
@ -139,6 +139,10 @@ class Forgejo(Service):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def set_configuration(cls, config_items):
|
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:
|
with WriteUserData() as user_data:
|
||||||
if "modules" not in user_data:
|
if "modules" not in user_data:
|
||||||
user_data["modules"] = {}
|
user_data["modules"] = {}
|
||||||
|
|
Loading…
Reference in a new issue