mirror of
https://code.lenaisten.de/Lenaisten/advent22.git
synced 2024-11-23 00:03:07 +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 TransformedString(BaseModel):
|
||||||
class __Whitespace(str, Enum):
|
class __Whitespace(str, Enum):
|
||||||
|
# unverändert
|
||||||
|
KEEP = "KEEP"
|
||||||
|
|
||||||
# Leerzeichen an Anfang und Ende entfernen
|
# Leerzeichen an Anfang und Ende entfernen
|
||||||
STRIP = "STRIP"
|
STRIP = "STRIP"
|
||||||
|
|
||||||
|
@ -23,6 +26,9 @@ class TransformedString(BaseModel):
|
||||||
IGNORE = "IGNORE"
|
IGNORE = "IGNORE"
|
||||||
|
|
||||||
class __Case(str, Enum):
|
class __Case(str, Enum):
|
||||||
|
# unverändert
|
||||||
|
KEEP = "KEEP"
|
||||||
|
|
||||||
# GROSSBUCHSTABEN
|
# GROSSBUCHSTABEN
|
||||||
UPPER = "UPPER"
|
UPPER = "UPPER"
|
||||||
|
|
||||||
|
@ -34,13 +40,12 @@ class TransformedString(BaseModel):
|
||||||
|
|
||||||
value: str
|
value: str
|
||||||
|
|
||||||
whitespace: __Whitespace | None = __Whitespace.IGNORE
|
whitespace: __Whitespace = __Whitespace.IGNORE
|
||||||
case: __Case | None = __Case.UPPER
|
case: __Case = __Case.UPPER
|
||||||
|
|
||||||
@field_validator("whitespace", "case", mode="before")
|
@field_validator("whitespace", "case", mode="before")
|
||||||
def transform_from_str(cls, v) -> str | None:
|
def transform_from_str(cls, v) -> str:
|
||||||
if (result := str(v).upper()) != "KEEP":
|
return str(v).upper()
|
||||||
return result
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def clean(self) -> str:
|
def clean(self) -> str:
|
||||||
|
|
|
@ -24,8 +24,8 @@ async def is_admin(
|
||||||
class ConfigModel(BaseModel):
|
class ConfigModel(BaseModel):
|
||||||
class __Solution(BaseModel):
|
class __Solution(BaseModel):
|
||||||
value: str
|
value: str
|
||||||
whitespace: str | None
|
whitespace: str
|
||||||
case: str | None
|
case: str
|
||||||
clean: str
|
clean: str
|
||||||
|
|
||||||
class __Puzzle(BaseModel):
|
class __Puzzle(BaseModel):
|
||||||
|
|
|
@ -179,8 +179,8 @@ export default class extends Vue {
|
||||||
public config_model: ConfigModel = {
|
public config_model: ConfigModel = {
|
||||||
solution: {
|
solution: {
|
||||||
value: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
value: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
||||||
whitespace: null,
|
whitespace: "KEEP",
|
||||||
case: null,
|
case: "KEEP",
|
||||||
clean: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
clean: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
||||||
},
|
},
|
||||||
puzzle: {
|
puzzle: {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
export interface ConfigModel {
|
export interface ConfigModel {
|
||||||
solution: {
|
solution: {
|
||||||
value: string;
|
value: string;
|
||||||
whitespace: string | null;
|
whitespace: string;
|
||||||
case: string | null;
|
case: string;
|
||||||
clean: string;
|
clean: string;
|
||||||
};
|
};
|
||||||
puzzle: {
|
puzzle: {
|
||||||
|
|
Loading…
Reference in a new issue