mirror of
https://code.lenaisten.de/Lenaisten/advent22.git
synced 2024-11-22 15:53:01 +00:00
make cfg.solution.* values non-null
This commit is contained in:
parent
aaa12683c8
commit
63b9f4e1d9
4 changed files with 16 additions and 11 deletions
|
@ -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:
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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: {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
export interface ConfigModel {
|
||||
solution: {
|
||||
value: string;
|
||||
whitespace: string | null;
|
||||
case: string | null;
|
||||
whitespace: string;
|
||||
case: string;
|
||||
clean: string;
|
||||
};
|
||||
puzzle: {
|
||||
|
|
Loading…
Reference in a new issue