feat: enable validator for ReadonlySettings

This commit is contained in:
Vlad Stan 2022-12-09 11:06:43 +02:00
parent 7952a462e3
commit 68b4a20e26

View file

@ -21,6 +21,7 @@ def list_parse_fallback(v):
return []
# todo: remove
readonly_variables = [
"host",
"port",
@ -43,6 +44,7 @@ class LNbitsSetings(BaseSettings):
if type(val) == str:
val = val.split(",") if val else []
return val
class Config:
env_file = ".env"
env_file_encoding = "utf-8"
@ -170,12 +172,13 @@ class ReadOnlySettings(LNbitsSetings):
"LnTipsWallet",
]
)
# @validator(
# "lnbits_allowed_funding_sources",
# pre=True,
# )
# def validate(cls, val):
# return super().validate(cls, val)
@validator(
"lnbits_allowed_funding_sources",
pre=True,
)
def validate_readonly_settings(cls, val):
return super().validate(cls, val)
class Settings(EditableSetings, ReadOnlySettings):
@ -194,7 +197,6 @@ class AdminSettings(EditableSetings):
lnbits_allowed_funding_sources: Optional[List[str]]
settings = Settings()
settings.lnbits_path = str(path.dirname(path.realpath(__file__)))