fix YYYY date issue (#5)

This commit is contained in:
Sina Atalay 2023-11-16 21:17:47 +01:00 committed by Jeffrey Goldberg
parent a4304f0ed2
commit b139817bfa
1 changed files with 5 additions and 1 deletions

View File

@ -115,6 +115,7 @@ def parse_date_string(date_string: str) -> Date | int:
raise ValueError( raise ValueError(
f'The date string "{date_string}" is not in YYYY-MM-DD, YYYY-MM, or YYYY' f'The date string "{date_string}" is not in YYYY-MM-DD, YYYY-MM, or YYYY'
" format." " format."
" format."
) )
if isinstance(date, Date): if isinstance(date, Date):
@ -628,8 +629,11 @@ class Design(BaseModel):
# ====================================================================================== # ======================================================================================
LaTeXString = Annotated[str, AfterValidator(escape_latex_characters)] LaTeXString = Annotated[str, AfterValidator(escape_latex_characters)]
SpellCheckedString = Annotated[LaTeXString, AfterValidator(check_spelling)]
PastDate = Annotated[ PastDate = Annotated[
str, Field(pattern=r"\d{4}-?(\d{2})?-?(\d{2})?"), AfterValidator(parse_date_string) str,
Field(pattern=r"\d{4}-?(\d{2})?-?(\d{2})?"),
AfterValidator(parse_date_string),
] ]