diff --git a/api/advent22_api/core/config.py b/api/advent22_api/core/config.py index 18af325..0c873e6 100644 --- a/api/advent22_api/core/config.py +++ b/api/advent22_api/core/config.py @@ -16,6 +16,9 @@ class User(BaseModel): class TransformedString(BaseModel): class __Whitespace(str, Enum): + # unverändert + KEEP = "KEEP" + # Leerzeichen an Anfang und Ende entfernen STRIP = "STRIP" @@ -23,6 +26,9 @@ class TransformedString(BaseModel): IGNORE = "IGNORE" class __Case(str, Enum): + # unverändert + KEEP = "KEEP" + # GROSSBUCHSTABEN UPPER = "UPPER" @@ -34,13 +40,12 @@ class TransformedString(BaseModel): value: str - whitespace: __Whitespace | None = __Whitespace.IGNORE - case: __Case | None = __Case.UPPER + whitespace: __Whitespace = __Whitespace.IGNORE + case: __Case = __Case.UPPER @field_validator("whitespace", "case", mode="before") - def transform_from_str(cls, v) -> str | None: - if (result := str(v).upper()) != "KEEP": - return result + def transform_from_str(cls, v) -> str: + return str(v).upper() @property def clean(self) -> str: diff --git a/api/advent22_api/routers/admin.py b/api/advent22_api/routers/admin.py index 26928fe..63b523f 100644 --- a/api/advent22_api/routers/admin.py +++ b/api/advent22_api/routers/admin.py @@ -24,8 +24,8 @@ async def is_admin( class ConfigModel(BaseModel): class __Solution(BaseModel): value: str - whitespace: str | None - case: str | None + whitespace: str + case: str clean: str class __Puzzle(BaseModel): diff --git a/ui/src/components/admin/ConfigView.vue b/ui/src/components/admin/ConfigView.vue index 21d9b17..80c77ae 100644 --- a/ui/src/components/admin/ConfigView.vue +++ b/ui/src/components/admin/ConfigView.vue @@ -179,8 +179,8 @@ export default class extends Vue { public config_model: ConfigModel = { solution: { value: "ABCDEFGHIJKLMNOPQRSTUVWXYZ", - whitespace: null, - case: null, + whitespace: "KEEP", + case: "KEEP", clean: "ABCDEFGHIJKLMNOPQRSTUVWXYZ", }, puzzle: { diff --git a/ui/src/lib/api.ts b/ui/src/lib/api.ts index 5da1534..d8f358a 100644 --- a/ui/src/lib/api.ts +++ b/ui/src/lib/api.ts @@ -1,8 +1,8 @@ export interface ConfigModel { solution: { value: string; - whitespace: string | null; - case: string | null; + whitespace: string; + case: string; clean: string; }; puzzle: {