From fde1401588d7ab49c6defc83902ce1060c14695a Mon Sep 17 00:00:00 2001 From: Sina Atalay Date: Fri, 13 Oct 2023 22:42:03 +0200 Subject: [PATCH] check if the selected theme exists --- rendercv/data_model.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/rendercv/data_model.py b/rendercv/data_model.py index e14ae7a..c89ced0 100644 --- a/rendercv/data_model.py +++ b/rendercv/data_model.py @@ -449,6 +449,19 @@ class Design(BaseModel): return font + @field_validator("theme") + @classmethod + def check_if_theme_exists(cls, theme: str) -> str: + # Go to templates directory and check if the theme exists: + templates_directory = os.path.join(os.path.dirname(__file__), "templates") + if f"{theme}.tex.j2" not in os.listdir(templates_directory): + raise ValueError( + f'The theme "{theme}" is not found in the "templates" directory! To add' + " a new theme, please see TO BE ADDED." + ) + + return theme + # ====================================================================================== # ======================================================================================